On Jan 9, 2008 1:07 PM, Kevin Viel <[EMAIL PROTECTED]> wrote: > Happy New Year. > > I have a series of values with the following form: > > TO_Chr10_final.txt > > I would like to obtain the value 10, for accounting purposes: > > my $chr = ( split /_/ , $value ) [ 1 ] ; > $chr =~ /chr/i ; > > $chr = $' ; > > This seems convoluted. Could someone please criticize this approach or > offer a better one? snip
First off, never use $`, $&, or $', they slow down every regex in your program. They are only in modern versions of Perl for backwards compatibility. Use captures instead. You are right that the split is a waste of effort, just use a better regex: my ($chr) = $value =~ /_chr(.*)_/i; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/