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 $element (@cddb_track)
{
$element =~ s/^.*?([0-9,a-f]{8}):.*$/$1/;
}
--------
The above fragment seems to be a good candidate for generalizing into a
subroutine. I have two questions regarding this:
1. Can this particular regular expression, involving as it does, matched
sub-pattern variables like $1, be used as a subroutine argument, and if so, how?
2. Can arbitrary regular expressions, including /PATTERN/REPLACEMENT/ versions
for substitutions, be used as subroutine arguments, and if so, how?
TIA.
Chandra
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/