This is a regex for unpacking URL-encoded strings. Your input string contains no encoded entities, and it passes through unchanged.
URL encoded text entities are of the form %FF where FF is an arbitrary byte in hex. The represent the character with the ordinal value of that byte. The regex grabs these three character sequences and translates them back into the ASCII equivalent.
update: see hex and pack for details of the hex-to-char translation.
| [reply] [d/l] |
Hi fishbot..
thanks for the help...i am kiran from india & just started learning perl.....once again thanks for spending your precious time to help novices like me....
| [reply] |
What the output is ?
I'll skip this one - it takes nothing to put the text inside a text file, and execute it using the Perl interpreter. perlrun can help you with this, anyway.
Explanation ?
For regex in general, the main reference is perlre, but a look to perlretut is worth a look as well. In your case, perlop is also a good starting point, in particular the "Regexp Quote-Like Operators".
In general, the "s/SOMETHING/OTHER/" construct makes substitutions. Wherever it finds "SOMETHING", it puts "OTHER". In this case, this substitution operator is applied to the $value variable, via the =~ binding operator. This can be found in perlop, of course.
The "e" switch indicates that the "OTHER" (i.e. the 'pack("C", hex($1))' in your case) is to be considered an expression and not a pure sequence of characters, and the "g" switch indicates that the substitution has to be applied to every occurence of the text matched in the first "SOMETHING" part (i.e. the '%(..)' in your case). Globally, this seems born to replace every occurrence of "%XX" with the character whose hexadecimal representation is "XX".
Could any one help me .......
A whole lot is willing to help you here. But please take a look around, and in particular to the About the PerlMonks FAQ and How do I post a question effectively?. You forgot to use proper code tagging, and forced a janitor to do it for you. Welcome to the Monastery!
Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf
Don't fool yourself.
| [reply] [d/l] [select] |
hi frodo......thanks for the help....the explanation was simple awesome & amazing......especially the "e" switch.......i now find that the expression was "ADVANCED REGEX" only for me and not for you people...and i have to learn a lot...........................i am kiran from india...thanks for spending your precious time to help newbies like me.....
| [reply] |
I'm going to post this here instead of using private message because I hope other people see it.
Please, in the future, take some time to actually properly format your messages. This makes it much easier for everyone else who uses the site to read it. For example, you don't capitalize the first letter of your sentences and you over use periods. Periods should be singular and used to denote the end of the sentence. Please do not put long strings of them between your sentences. I realize typing like that may be "easier" for you, but it's a really arrogant form of laziness, as it makes it much harder for everyone else who has to decipher it.
| [reply] |
Considering the regex looks for 3-character substrings starting with a %-sign, and $value doesn't contain any %-signs, the snippet will print "w/115/271/2337/14-11575/".
| [reply] |