Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: raw data formatting

by Kenosis (Priest)
on Nov 16, 2012 at 01:52 UTC ( #1004099=note: print w/ replies, xml ) Need Help??


in reply to Re^2: raw data formatting
in thread raw data formatting

Your version of Perl doesn't support the non-destructive substitution modifier (/r). Use the following:

print for map { s/\s+/$letter++ . ' '/e; $_ } @lines;

Will make that change in the original posting.


Comment on Re^3: raw data formatting
Select or Download Code
Re^4: raw data formatting
by teamassociated (Novice) on Nov 16, 2012 at 02:24 UTC
    Thank you that worked! This code technique is new 2 me, but thanks! I need to skip certain lines ...working in original code, but tried using it here. how do i skip indexes as opposed to lines?
    while ( my @lines = $it->() ) { next if ($. == 1..88); my $letter = 'A'; my $acctNum = do { $lines[0] =~ /\s+(\d+)\s+(\d+)/; $1 . $2 }; push @lines, " acctnum=$acctNum"; print for map { s/\s+/$letter++ . ' '/e; $_ } @lines; print "\n"; }

      What do the indexes look like, i.e., how do they appear in your file?

      Noticed that line "F" doesn't wrap if it's the very last DATA line, since it doesn't have a newline at it's end. Thus, make the following two changes and I'll do the same in the original posting:

      while ( chomp( my @lines = $it->() ) ) {

      and

      print for map { s/\s+/$letter++ . ' '/e; "$_\n" } @lines;

      Remove the print "\n"; line.

        Here is the entire file: I need to skip the 1st 88 indexes and do not need any line that do not start w/ a space then a digit...this seemed to of work:
        next if ($lines[0] !~ /\A\s+\d+/);
        thank you again!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2014-08-22 06:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (147 votes), past polls