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