달력

11

« 2024/11 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

'PERL'에 해당되는 글 2

  1. 2009.11.11 Perl로 urlendode, urldecode 함수 구현2
  2. 2009.11.11 Perl로 urlendode, urldecode 함수 구현
2009. 11. 11. 15:28

Perl로 urlendode, urldecode 함수 구현2 PERL2009. 11. 11. 15:28


sub urlencode {
my $str = shift;
$str =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
return $str;
}

sub urldecode {
my $str = shift;
$str =~ s/%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg;
return $str;
}
:
Posted by 비개인오후
2009. 11. 11. 15:27

Perl로 urlendode, urldecode 함수 구현 PERL2009. 11. 11. 15:27

sub URLEncode {
    my $theURL = $_[0];
   $theURL =~ s/([\W])/"%" . uc(sprintf("%2.2x",ord($1)))/eg;
   return $theURL;
}

sub URLDecode {
    my $theURL = $_[0];
    $theURL =~ tr/+/ /;
    $theURL =~ s/%([a-fA-F0-9]{2,2})/chr(hex($1))/eg;
    $theURL =~ s/<!--(.|\n)*-->//g;
    return $theURL;
}

:
Posted by 비개인오후