--- Sean O'Leary <[EMAIL PROTECTED]> wrote:
> 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. 

"split ' '" is a pretty common idiom, though it still confuses me.
I suppose it's hardcoded?

> 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. 

Cool! a new toy! lol!

> 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.) 

I think i grok that one.
Giving the numeric argument tells Perl when to stop splitting.
If you ask for 4 things and don't give it that limiting factor, it
decides looks at the context and figures out that it would be a waste
of time to keep splitting, so leaves the 5th chunk unsplit since it's
just going to be tossed anyway. Just guessing, though.

> 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.

I didn't read it that way. 
What I saw was that *any* character would qualify as a seperator, and
so all it had to return was the empty space between chars.

Paul

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

Reply via email to