>>>>> "SHC" == Shawn H Corey <shawnhco...@gmail.com> writes:

  SHC> Noah wrote:
  >> 
  >> Hi there,
  >> 
  >> is there a way to easily just get the number itself saved into an array?
  >> i dont need the 'link' text.
  >> 
  >> if (@ARGV) {
  >> @link_numbers = grep(/^link([0-9]+)/,@ARGV);
  >> }

  SHC> Use the block form:

  SHC> if (@ARGV) {
  SHC>       @link_numbers = grep { /^link([0-9]+)/; $_ = $1; } @ARGV;
  SHC> }

that modifies @ARGV so it is a bad idea. also it bypasses grep's purpose
of filtering a list. and as i posted, map is the correct solution

  SHC> Doesn't work with "link0".

another reason to not use this solution.

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