Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: passing arrays

by Not_a_Number (Prior)
on Apr 19, 2008 at 21:00 UTC ( #681703=note: print w/replies, xml ) Need Help??


in reply to Re^2: passing arrays
in thread passing arrays

Actually all three arguments to split [pattern;[, expression, limit]] are optional.

I find that statement misleading. See the 'template' at the top of spilt:

split /PATTERN/,EXPR,LIMIT split /PATTERN/,EXPR split /PATTERN/ split

This implicitly (and rightly) excludes:

split EXPR

Which is exactly what the OP tries to do in the line:

@mails = split ('$line');

This is why the OP's code generates the following error:

Use of uninitialized value $_ in split at XX.pl line YY.

IOW, the 'expression' argument is optional only if the 'pattern' argument is present.

Replies are listed 'Best First'.
Re^4: passing arrays
by Fletch (Chancellor) on Apr 20, 2008 at 04:07 UTC

    In that case the expression to be split is defaulting to $_, but at the time of his call it contains undef. You don't have to explicitly provide the text to split, but if you don't do so you should have what you want to split in $_ or it's not going to be very useful.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://681703]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2021-10-24 18:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (89 votes). Check out past polls.

    Notices?