>>>>> "s" == siegfried  <siegfr...@heintze.com> 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  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to