siegfried wrote:
I posted this on the news group comp.lang.perl yesterday and since I have
not received a response (and it does not look very active) I am cross
posting it here.
This works:
@p= split "\\.", @ARGV[0];
That is usually written as:
@p = split /\./, $ARGV[0];
Why use an array slice when you only need a scalar?
print "$p[0]\n"
I want to write it as a onliner. How so I do that? Here is my attempt:
print (@{split "\\.", @ARGV[0]})[0];
print +( split /\./, $ARGV[0] )[0], "\n";
Or:
print( ( split /\./, $ARGV[0] )[0], "\n" );
How do I index directly without explicitly creating a temporary variable?
Lookup "slices" in perldata.pod
perldoc perldata
John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction. -- Albert Einstein
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/