in reply to Re: Upload a file from home dir
in thread Upload a file from home dir

Cheers, So i take it that i just ahve to code to search for stuff i need like regEx's i.e. can now be used instead sub checkFile() { print("File is now open"); @file = <FILE>; print("

@file

"); while($line = <FILE>) { chomp($line); if($line =~ /(^ACGTacgt)/) {next;} else { @cols = split(/\s/, $line); print("@cols"); } print("File is now closed"); } }

Replies are listed 'Best First'.
Re^2: Upload a file from home dir
by eieio (Pilgrim) on Apr 01, 2005 at 16:21 UTC
    Well, I'm not entirely sure what you are trying to do. First, you would use the $filehandle rather than FILE when reading from the file. Second, you are trying to read the entire file twice from the same file handle which won't work. If you want to print the entire contents of the file and then possibly print some additional information based on the regular expression, the following code may help (though I haven't tested it):
    sub checkFile() { my @file = <$filehandle>; print( "&lt;BR&gt;&lt;BR&gt;@file&lt;BR&gt;&lt;BR&gt;" ); foreach my $line ( @file ) { chomp( $line ); if( $line =~ /([^ACGTacgt])/ ) { next; } else { my @cols = split( /\s/, $line ); print( "@cols" ); } } }