Can regular expressions be used as subroutine arguments?

2008-03-08 Thread R (Chandra) Chandrasekhar
Hello Folks, I need to make a substitution in place for each element of an array, and I need to do this to two arrays. Currently the relevant code fragment (without pragmas) is: foreach my $element (@cddb_artist) { $element =~ s/^.*?([0-9,a-f]{8}):.*$/$1/; } foreach my

Re: Can regular expressions be used as subroutine arguments?

2008-03-08 Thread Dr.Ruud
R (Chandra) Chandrasekhar schreef: foreach my $element (@cddb_artist) { $element =~ s/^.*?([0-9,a-f]{8}):.*$/$1/; } foreach my $element (@cddb_track) { $element =~ s/^.*?([0-9,a-f]{8}):.*$/$1/; } You can write all that as this single

Re: Can regular expressions be used as subroutine arguments?

2008-03-08 Thread Chas. Owens
On Sat, Mar 8, 2008 at 9:59 AM, Dr.Ruud [EMAIL PROTECTED] wrote: snip 2. Can arbitrary regular expressions, including /PATTERN/REPLACEMENT/ versions for substitutions, be used as subroutine arguments, and if so, how? Store the parts in variables. snip Specifically, use the qr//

Re: Can regular expressions be used as subroutine arguments?

2008-03-08 Thread John W. Krahn
R (Chandra) Chandrasekhar wrote: Hello Folks, I need to make a substitution in place for each element of an array, and I need to do this to two arrays. Currently the relevant code fragment (without pragmas) is: foreach my $element (@cddb_artist) { $element =~