#!/usr/local/bin/perl -w # getting the source code from the file ##################################################################### open(IN,"/home/uila3/rhuff/doh/090809.txt") or die "cannot open file1 for reading\n"; open(OUT,">/home/uila3/rhuff/doh/test.txt") or die "cannot open file2 for writing\n"; my $start = 0; my $count=0; while() { chomp; $count++; next if( /^\s*$/ ); #skip empty lines if( /^END_DATA\s*$/ ) #end if this word found { $start = 0; next; } if( /VARIABLE,\s*(.*)$/ ) { my ($sec,$min,$hour,$day,$month,$yr19,@rest) = localtime(time); print OUT $_ ; next; } if( ($start==0) && ( /^BEGIN_DATA\s*$/ ) ) #starts with this word only { $start = 1; next; } print OUT $1," ",$2,"\n" if( (($start==1)) && ( /^([^,]*),.*,\s*([0-9.-]*)$/ ) ); } close(OUT); close(IN); print "No. of lines parsed $count";