Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Increaing a field size for a record

by flexvault (Parson)
on Oct 16, 2012 at 18:53 UTC ( #999394=note: print w/ replies, xml ) Need Help??


in reply to Increaing a field size for a record

Thomas Kennll,

A very simple way to insert spaces is:

my $record = <$fh>; # read the record substr( $record, 15, 0, " " x 39 ); # insert 39 spaces
This will insert 39 spaces after the 15th character. If your counting starting at 1, test that it is going into the correct location :-)

Good Luck!

"Well done is better than well said." - Benjamin Franklin


Comment on Re: Increaing a field size for a record
Download Code
Re^2: Increaing a field size for a record
by Thomas Kennll (Acolyte) on Oct 16, 2012 at 19:27 UTC
    Thanks!! But this doesn't seam to be working for me. :( #!/usr/bin/perl open FILE, rij1.dat"; my @lines = <FILE>; foreach my $lin (@lines) { my $btw = substr($lin, 15, 0, "1" x 39); print "$btw"; } close FILE;

      Thomas Kennll,

      That's not what I showed you, please note:

      foreach my $lin (@lines) { substr($lin, 15, 0, "1" x 39); print "$lin\ +n"; }

      "Well done is better than well said." - Benjamin Franklin

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://999394]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2014-09-16 11:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (10 votes), past polls