in reply to Re: How to remove the $1 hard coding
in thread How to remove the $1 hard coding
Elegant solution. Assuming that the search string is not $_ (and is $string) they probably want:
my @res = $string =~ m/\s*(\S+)\s*(\S+)\s*(\S+)\s*(\S+)\s*/ ; push @sps, $res[ $columnNumber ];
However a regex is total overkill when you could just:
@res = split ' ', $string; push @sps, $res[ $columnNumber ]; # or if you want one line push @sps, (split ' ', $string)[$columNumber];
Fixed typo thanks chunlou
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: How to remove the $1 hard coding
by MidLifeXis (Monsignor) on Aug 22, 2003 at 17:06 UTC | |
by graff (Chancellor) on Aug 22, 2003 at 23:56 UTC | |
by tachyon (Chancellor) on Aug 23, 2003 at 10:28 UTC | |
by MidLifeXis (Monsignor) on Aug 23, 2003 at 20:40 UTC | |
by tachyon (Chancellor) on Aug 25, 2003 at 12:25 UTC | |
by chunlou (Curate) on Aug 22, 2003 at 19:37 UTC | |
Re: Re: Re: How to remove the $1 hard coding
by chunlou (Curate) on Aug 22, 2003 at 16:04 UTC | |
by ajdelore (Pilgrim) on Aug 22, 2003 at 21:34 UTC | |
by chunlou (Curate) on Aug 22, 2003 at 21:46 UTC |