#! c:\Perl\bin\perl5_8 #Read lines from a text file; create RE's that will find certain stuff #use strict; take this out for now open (MYFILE, "< Lori.txt") || die("Can't open Lori.txt"); #find lines starting with a c and end with a d print "lines starting with a c and end with a d:\n"; while (chomp($line =)) { if ($line =~ /^[cC].*d$/o) { print "$line\n"; } } #find blank lines seek MYFILE, 0,0; print "\nblank lines:\n"; while (chomp($line =)) { if ($line =~ /^$/o) { print "$line\n"; print "blank line above\n"; } } #find lines with only spaces seek MYFILE, 0,0; print "\nlines with only spaces:\n"; while (chomp($line =)) { if ($line =~ /^ *$/o) { print "$line\n"; print "spaced out line above\n"; } } #find lines that contain the same number twice seek MYFILE, 0,0; print "\nlines that contain the same number twice:\n"; while (chomp($line =)) { if ($line =~ /(\d+)[^\d]*\1[^\d]/o) { print "$line\n"; } } #find lines that contain a negative number with a decimal point seek MYFILE, 0,0; print "\nlines that contain a - number with a decimal point:\n"; while (chomp($line =)) { if ($line =~ /-\d*\.\d*/o) { print "$line\n"; } } close MYFILE;