Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Oneliner with substring trimming and padding

by Neighbour (Friar)
on Jul 17, 2012 at 11:59 UTC ( #982210=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    perl -pi -e 'substr($_,589,35) =~ s/(\s*)(\w+)*/$2$1/ if /^(.{589})(\s
    +{1,34})/' file.txt
    
  2. or download this
    perl -pi -e 'substr($_,589,35) =~ s/(0*)(\w+)*/$2($?{ ' ' x length($1)
    + })/ if /^(.{589})(0{1,34})/' file.txt
    
  3. or download this
    perl -pi -e 'substr($_,589,35) =~ s/(0*)(\w+)*/$2($?{ " " x length($1)
    + })/ if /^(.{589})(0{1,34})/' file.txt
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://982210]
Approved by Ratazong
help
Chatterbox?
talexb sits in on the bi-weekly conference call.
[shmem]: a good fart in the right place often does win the case.

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2017-04-27 14:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (508 votes). Check out past polls.