A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: PERL special characters issue???

  1. #1
    I am writing a perl script that will edit text files and write them back out in URL encoding. The problem is PERL isn't converting special characters. Ex. "%" is showing up as "=%25". I am using the following to decode:
    foreach $pair (@pairs) {
    	($key, $value) = split (/=/, $pair);
    	$key =~ tr/+/ /;
    	$key =~ s/%([a-fA-F0-9] [a-fA-F0-9])/pack("C", hex($1))/eg;
    	$value =~ tr/+/ /;
    	$value =~ s/%([a-fA-F0-9] [a-fA-F0-9])/pack("C", hex($1))/eg;
    	#$value =~s/<!--(.|\n)*-->//g;
    	if ($formdata{$key}) {
    		$formdata{$key} .= ", $value";
    	} else {
    		$formdata{$key} = $value;
    Any Ideas?

  2. #2

    use CGI.pm

    Use CGI.pm.

    Life is just soooo much easier.

    #!/usr/bin/perl -w
    use strict;
    use CGI;
    my $query = new CGI;
    # name1=value1 passed from flash.
    # all http escaping dealt with.
    my $value1 = $query->param('name1');
    # value2 from db/text file/internals etc - needs
    # escaping before sending back
    use CGI::Util;
    my $value2 = q|Something with !"$%^&*()+' chars in it|;
    $value2= CGI::Util::escape($value2);
    # print HTTP header
    print $query->header;
    #pass vars to flash
    print "value1=$value1&value2=$value2&loaded=true";
    Hope this helps...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center