I always find myself writing code like this:
my $var = $result[0];
my $var_changed = $var;
$var_changed =~ s/somepattern/somechange/g;
What would be a better way to do this? And by 'better' I mean: less typing while remaining understandable.
Thanks.
This would do the same thing as the second and third lines;
(my $var_changed = $var) =~ s/somepattern/somechange/g;
How legible it is is your call.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With