12345678910111213141516 |
- #!/usr/bin/perl
- sub UrlEncode {
- my @letters = split(//,shift);
- my @safe = ('a' .. 'z', 'A' .. 'Z', '0' .. '9', '-', '_', '.', '!', '~', '*', "'", '(', ')');
- foreach my $letter (@letters) {
- my $pattern = quotemeta($letter);
- if (not grep(/$pattern/, @safe)) {
- $letter = sprintf("%%%02x", ord($letter));
- }
- }
- return join('', @letters);
- }
- print UrlEncode(join(' ', @ARGV)), "\n";
|