>>>>> "s" == siegfried <[email protected]> writes:
s> I posted this on the news group comp.lang.perl yesterday and since I have
s> not received a response (and it does not look very active) I am cross
s> posting it here.
that group was removed over a decade ago. your news feed shouldn't even
have it. the group you want is comp.lang.perl.misc.
s> This works:
s> @p= split "\\.", @ARGV[0];
don't use quotes for the first arg to split. it is always a regex so use
// like other regexes.
s> print "$p[0]\n"
s> I want to write it as a onliner. How so I do that? Here is my attempt:
s> print (@{split "\\.", @ARGV[0]})[0];
s> How do I index directly without explicitly creating a temporary variable?
just slice it. no need for the anon array:
(split m{\\.}, @ARGV[0])[0];
i used m{} for the regex since // would look badly with \\ inside.
uri
--
Uri Guttman ------ [email protected] -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/