G
gibbering poster
Suppose I has some coderefs in an array, and wanted to loop through them
and apply them... more specifically to a string:
my @subs = (
{ s/\s+//g }, { s/-/ /g },
);
my $string = "\tJoe-Smith ";
for (@subs) {
local *_ = $string;
do &{$_}; # I know this is horribly wrong
}
print $string; # Want this to print "Joe Smith"
Can someone please show me the way here? Sorry in advance if I missed a
perldoc.
Thanks!
PS ... Is there a way to catch the return value of those substitions
(i.e. their success or failure)?
and apply them... more specifically to a string:
my @subs = (
{ s/\s+//g }, { s/-/ /g },
);
my $string = "\tJoe-Smith ";
for (@subs) {
local *_ = $string;
do &{$_}; # I know this is horribly wrong
}
print $string; # Want this to print "Joe Smith"
Can someone please show me the way here? Sorry in advance if I missed a
perldoc.
Thanks!
PS ... Is there a way to catch the return value of those substitions
(i.e. their success or failure)?