Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

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

chorobas solution and commentary is excellent; I don't disagree with any of it. I offer this as an alternate possible solution. (I was doing this before I saw that was posted.) Here I slurp the file in by paragraphs then pick out the lines I want to save.

#!usr/bin/perl use strict; use warnings; use Tk; use Cwd; use Data::Dumper; # ###################################################################### +##################### # GUI Building ###################################################################### +##################### # # Create Main Window my $mw = MainWindow->new; my $n = 0; my %temp; my $ms_button = $mw->Button( -text=>"MS", -command=> \&BJSFM_MS )->pack(); MainLoop; sub BJSFM_MS { my $filename = 'BJSFM_out.prn'; #open my $infile, '<', $filename or die "Can't open $filename! $!" +; my $infile = *DATA; local $/="FAILURE CRITERIA PER PLY\n"; while (my $paragraph = <$infile>) { chomp $paragraph; $paragraph =~ s/^\s+\n|\s+$//g; my @lines = split "\n", $paragraph; next if @lines < 4; map {$temp{$n++} = $_ } @lines[3..$#lines]; } close $infile; print Dumper \%temp; } __DATA__ FAILURE CRITERIA PER PLY DIST ANGLE PLY FAILURE NUMBERS 1 2 SHEAR 0.000 0.00 -45.00 0.238 0.282 -1.459 0.000 0.00 0.00 0.971 1.369 0.004 0.000 5.00 -45.00 0.475 0.142 -1.585 0.000 5.00 0.00 1.003 1.531 -0.274 0.000 10.00 -45.00 0.721 0.037 -1.623 FAILURE CRITERIA PER PLY DIST ANGLE PLY FAILURE NUMBERS 1 2 SHEAR 0.000 0.00 -45.00 0.247 0.293 -1.514 0.000 0.00 0.00 1.008 1.422 0.004 0.000 5.00 -45.00 0.493 0.147 -1.645 0.000 5.00 0.00 1.042 1.589 -0.284

In reply to Re: File Parsing by thundergnat
in thread File Parsing by shortyfw06

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 admiring the Monastery: (2)
As of 2024-04-26 01:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found