go ahead... be a heretic | |
PerlMonks |
Re^3: One-liner to rule them all...by davido (Cardinal) |
on Jul 11, 2012 at 16:00 UTC ( [id://981178]=note: print w/replies, xml ) | Need Help?? |
I'm assuming that you're going to set up your one-liner such that the target string is held in @ARGV (A special variable documented in perlvar). That's one simple possibility. So $ARGV[0] will hold the first string passed on the command line. To bind your transliteration operator to $ARGV[0] you use the =~ operator like this: $ARGV[0] =~ tr/a-z/x-za-w/. Now $ARGV[0] holds the transliterated string, and all you need to do is pass it to system, just as you would pass any parameter to any function. If your target string contains whitespace you will have to wrap it in quotes that your shell respects. I still don't understand why this is useful. It's not really a form of security, and if the goal is to hide keystrokes, it is easy to unravel. Plus any system call will still show up in the process list. Dave
In Section
Seekers of Perl Wisdom
|
|