View Single Post
  #2 (permalink)  
Old Aug 9th, 2007, 17:53
DPhahn DPhahn is offline
Junior Member
Join Date: Aug 2007
Location: chesterfield
Age: 37
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Understadning Perl Basics

try this
Code: Select all
my $lin = "Lines: \n";
chomp($lin);
enter:
{
print("Please enter a file name: ");
$fileName = <STDIN>;
chomp($fileName);
 
if($fileName !~ m/\.TXT$/i)
 {
  open(READFILE, "$fileName.txt") || die "couldn't open file: $!";
        }
else
 {
 print("re-enter filename!\n");
 redo enter;
}
}
while(<READFILE>)
{
package Lines;
 $count += split(/\n\n/, $_);
}
print("$lin $Lines::count\n");
close(READFILE);

Last edited by karinne; Aug 9th, 2007 at 17:54. Reason: Please use [ code ]...[ /code ] tags when displaying code.
Reply With Quote