you don't really need that if conditional: the substitution operator $_ =~ s/hue/someword/g; will anyway do the substitution only if the input line matches /hue/, so that the three code lines above can be summarized toif($_ =~ /hue/){ $_ =~ s/hue/someword/g; }
It can actually be simplified further by noting that that the substitution operator works by default on $_, so that it can be rewritten:$_ =~ s/hue/someword/g;
but not everyone agrees with that further simplification, some people prefer to explicitly use the $_ variable and the =~ binding operator. The same simplification could have been done in the if conditional (if (/hue/) { # ...), but there is no point of discussing that further since it has already been removed.s/hue/someword/g;
In reply to Re: Writing all relevant data in one file to a new file with adjustments
by Laurent_R
in thread Writing all relevant data in one file to a new file with adjustments
by The_Last_Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |