[sf-perl] Anyone know why won't this work?
Francisco Obispo
fobispo at isc.org
Wed Jul 24 09:53:25 PDT 2013
Is this what you intended?
#!/usr/bin/env perl
my $string = "The good\n\nThe bad\n\nThe Ugly";
my @str = split /\n\n/, $string;
print "Second thru last element: " . join(", ", at str[1..$#str]) . "\n";
Look at the double quotes on "my $string", don't use a string literal.
And look at the last line, using a slice of @str.
On Jul 24, 2013, at 9:42 AM, Richard Reina <gatorreina at gmail.com> wrote:
> Can anyone tell me what I'm doing wrong?
>
> #!/usr/bin/perl -w
>
> my $string = 'The good\n\nThe bad\n\nThe Ugly';
>
> my @str = split /\n\n/, $string;
>
> print "Second thru last element: " . $str[1..$#str] . "\n";
>
>
> GIVES ME:
>
> Use of uninitialized value within @str in range (or flip) at
> test_split.pl line 7.
> Argument "" isn't numeric in array element at test_split.pl line 7.
> Second thru last element: The good\n\nThe bad\n\nThe Ugly
> _______________________________________________
> SanFrancisco-pm mailing list
> SanFrancisco-pm at pm.org
> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm
Francisco Obispo
Director of Applications and Services - ISC
email: fobispo at isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/sanfrancisco-pm/attachments/20130724/d526389e/attachment.html>
More information about the SanFrancisco-pm
mailing list