in reply to Will a substitution in an if/else control structure default to $_?
What it looks like you're trying to do is take an lvalue to the result of $table->cell($rownum, 0..2). This is, generally, not something that's recommended to be done (though it is doable, kinda). Much better would be to have the $table object be asked to normalize the value that would be returned by $table->cell($rownum, 0..2) within the object itself. That way, you're probably using some sort of hash value. Even then, you can't do the whole $_ lvalue thing. Honestly, I don't like code that overuses $_. Just be explicit about what you're doing.
Now, instead of trying to reuse the operand, you could make the match and substitution a little smarter.
That requires coding up another method that would do something likemy $strip = '\x0'; $strip .= '\d+' if $table->cell($rownum, 0..2) =~ $strip; $table->strip( $strip, $rownum, 0..2 );
# The ... indicates "Whatever" - it's not meant to be syntatically-cor +rect Perl. sub strip { my $self = shift; my ($pattern, ... ) = @_; $self->{cells}[...] =~ s/$pattern//; }
See how that could work better?
|
|---|