On Thu, 23 Sep 2004 13:43:08 -0600, Siegfried Heintze
<[EMAIL PROTECTED]> wrote:
> This works and does what I want it to:
>
> perl -e '@x = split("\\.", "a.b.c"); print $x[0];'
>
> Why does not this work?
> perl -e 'print @{split("\\.", "a.b.c")}[0];'
Because split doesn't return an array reference, it returns a list.
print( (split(/\./, "a.b.c"))[0] );
>
> Is there a compact way to take a slice of a split (or other function that
> returns an array) without creating a temporary variable?
>
> Thanks,
> Siegfried
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
--
-will
http://www.wgunther.tk
(the above message is double rot13 encoded for security reasons)
Most Useful Perl Modules
-strict
-warnings
-Devel::DProf
-Benchmark
-B::Deparse
-Data::Dumper
-Clone
-Perl::Tidy
-Beautifier
-DBD::SQLite
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>