Ritu says: Hi i dont no anything about PERL, only read a beginners online tutorial.

You might want to continue reading this site's Tutorials to learn some more?

There are output data files which some simulation runs are generating. I need a simple perl script to extract results from the files using perl script and use it to plot graphs in gnuplot. Can anybody please help me.

my @output_data_files = qw( filename1 filename2 more_filenames... ); my $pattern = qr/result/; # a regular expression that will find "resul +t" my @results_found; # here goes everything that was found. foreach my $file ( @output_data_files ) { open ( FILE, "< $file" ) or die qq(could not open file "$file" for reading: $!); while ( <FILE> ) { # on every line of the file if ( my @matches = m/$pattern/g ) { # matches of the pattern push @results_found, @matches; # add them to @results_fou +nd } } close FILE; }

Now you have got the results in the array   @results_found.
Tell us how gnuplot expects the data and we might know how to proceed from here.

Cheerio, Sören


In reply to Re: pattern match in text file by Happy-the-monk
in thread pattern match in text file by Ritu

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.