Monday, July 27, 2009

Perl programming???

$file = 'C:\PERL\BIN\ABC.XML';


open(INFO, $file) or die "Can't Open the File";





while (%26lt;INFO%26gt;)


{


chomp; #works on $_ by default


print $_,"\n"; #Don't need the "\n" if you don't chomp


if ($_ =~ /Prostate Cancer/)


{


print "ALRIGHT";


close (INFO);


}


else


{


print "NOOOOOOOOOOO";


}


}


close (INFO);





Above program reads the entire file and finds the word /prostate cancer/. However I want to is copy the data of the from the beginning up to the word 'prostate cancer' and save it to another file and th other half to another file.





Please help I'm new in perl???

Perl programming???
Here's some pseudocode:





open output file1 as FileHandle $fh


while (%26lt;%26gt;)


{


print line to $fh


if (line of interest)


{


close $fh


open $fh on output file2


}


}


No comments:

Post a Comment