Don Coyote has asked for the wisdom of the Perl Monks concerning the following question:
After rolling a FORMAT oneliner! :) I echo'd this into a file. Now my laziness is starting to niggle and I decide it is about time to edit in place those semicolons into newlines rather than doing this manually.
After clobbering the file a number of times. I could not get a 'simple' s/// or tr/// to operate on a perl -ni -e command. I eventually split the looping stdin file at the semi-colons and joined with newlines, and this was fine. But I wonder why I wasn't able to s/// or y/// on a looping file? some examples:
file to which one-liner echo'd
#! \usr\bin\perl use strict; use warnings; "my $fs = q!.\funkisym.pm!;open(FUNKISYM, q(>),qq($fs)); my $flashbang + = q{#! \usr\bin\perl};my $pra = q!use strict;!; my $pra2 = q!use war +nings;!;my @fstr = (q(format FUNKISYM = ),q(@).q(<) x 16,q($flashban +g).qq(\n),q(@).q(<) x 11,q($pra),q(@).q(<) x 13,q($pra2),qq(.\n));eva +l(join($/,@fstr));select FUNKISYM;write;exec(qq!notepad\.exe $fs!);"
attempted commands which either clobbered file and/or produced bareword deaths on tr///
perl -n -i.bak -e "tr/;/\n/;" .\funkisym.pm perl -n -i.bak -e "y/\Q;\E/\n/;" .\funkisym.pm perl -n -i.bak -e "s/(;)/$1\n/g;" .\funkisym.pm
I tried variations further to those shown, and settled for the following solution;
perl -ni.bak -e "my @text = split(q{;});print join(qq(;$/), @text);" . +\funkisym.pm"
Please can you suggest what I may be assuming incorrectly, in relation to this problem?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: s/// + tr/// when perl -ni -e on semi-colons in one liners echoed to files
by Anonymous Monk on Nov 18, 2012 at 12:37 UTC | |
by Don Coyote (Hermit) on Nov 18, 2012 at 12:47 UTC | |
by Anonymous Monk on Nov 18, 2012 at 12:57 UTC | |
by Don Coyote (Hermit) on Nov 18, 2012 at 13:12 UTC | |
|
Re: s/// + tr/// when perl -ni -e on semi-colons in one liners echoed to files
by aitap (Curate) on Nov 18, 2012 at 13:06 UTC | |
|
Re: s/// + tr/// when perl -ni -e on semi-colons in one liners echoed to files
by Anonymous Monk on Nov 18, 2012 at 12:31 UTC |