Re: [PBML] Command line arguments to perl script: apostrophe?
On Tuesday 26 October 2010 01:49:04 Bull Durham wrote:
> I downloaded and studied the O'Reilly Into and Intermediate Perl
> books, and pressed on with my own project. This project aims to solve
> those word-substitution CryptoQuotes you often see in your daily
> I'm pretty well pleased with what I have to-date. It takes the
> scrambled letters of several words from the CryptoQuote and sorts out
> the possible solutions.
> I thought I could improve it by adding contractions to the mix. This
> means the scrambled letters I enter have an apostrophe (').
> The crypto words are read in to my script as command line arguments.
> ./nCrypto.pl xyzxqy xyrbzy
> Which compiles my nCrypto.pl script and reads in the arguments and
> decrypts them (in this case, probably decrypted as people person).
> To enter contractions, I hoped to read in the argument list and scan
> for words with an apostrophe ('). However, in test cases, putting an
> apostrophe in the command line sends me off into some perlish limbo.
> The entry
> ./nCrypto.pl xyzxqy xyrbzy wkz'r
> Where the wkz'r is something like don't. My script just gives me a
> What is perl waiting for? Is an apostrophe in the invocation of a
> perl script through its arguments special? I guess it is, but I don't
> see what it means.
The problem is likely with your Unix shell which treats an apostrophe as a
delimiter of a string:
shlomif:~$ echo Hello
shlomif:~$ echo 'Hello'
shlomif:~$ echo One\'Two\'Three
shlomif:~$ echo "Hello"
shlomif:~$ echo "Hello 'World'"
This is standard Unix shell behaviour and does not only affect Perl. For more
information see a shell tutorial/book such as:
Shlomi Fish http://www.shlomifish.org/
"Star Trek: We, the Living Dead" - http://shlom.in/st-wtld
<rindolf> She's a hot chick. But she smokes.
<go|dfish> She can smoke as long as she's smokin'.
Please reply to list if it's a mailing list post - http://shlom.in/reply .