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 |