Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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?


In reply to s/// + tr/// when perl -ni -e on semi-colons in one liners echoed to files by Don Coyote

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-04-16 08:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found