At 10:48 AM 4/25/2001, you wrote:

>Thanks for that Steven,
>
>I knew it was obvious
>
>Gary

Well, it's not obvious.  To tell you honestly, I was initially shocked that 
split didn't complain about the string, demanding a pattern instead.  Then 
I looked more at and played a bit, and found the Perl coerces the string 
into becoming a pattern.

If you have a recent Perl, run your script like this:

perl -MO=Deparse myscript.pl <args>

The output from Deparse will show you what Perl really thought of your 
script, after the compilation phase is done.  If you'll look, you see that 
your

split (".", $ARGV[0])

becomes

split (/./, $ARGV[0], 5)

I don't know what the 5 is doing there ( I think it should be a 4, because 
you are assigning the result of the split to 4 a list of variables, but the 
compiler knows about many things that I don't.)  but you can see what 
happens.  The string is made into a pattern, and since that pattern is a 
single dot, it matches everything in the string, so there's nothing to 
split on, so you get nothing back, and as it is, your variables stay empty.

Wow.  That was a cool one.  Thanks!  : )

Oh, BTW, check out perlrun for info on running modules form the command 
line (like the -MO=Deparse above) and perlfunc for all of the info about split.
There is an interesting note about a special case with split when the 
argument is a string with a single space, but that doesn't apply here.

Thank you for your time,

Sean.

Reply via email to