Re: reopen the file
- From: Ben Morrow <ben@xxxxxxxxxxxx>
- Date: Thu, 27 Dec 2007 19:46:50 +0000
Quoth "vijay@xxxxxxxxxx" <vijay@xxxxxxxxxx>:
open(MAPFILE, $FTP_MAPFILE);
Use three-arg open.
Use lexical filehandles.
Check the return value of open.
open(my $MAPFILE, '<', $FTP_MAPFILE)
or die "can't open '$FTP_MAPFILE': $!";
while(<MAPFILE>){
chop;
Don't use chop, use chomp instead.
($user,$file) = split /=/;
Why aren't you using strict?
if(uc($user) eq uc($userid)){
It's generally better to normalise case with lc than with uc. Unicode
defines three cases (upper, lower and title), and while upper->lower and
title->lower are well-defined, title->upper isn't.
push(@files,$file);
}
}
close(MAPFILE);
open(MAPFILE, $FTP_MAPFILE);
while(<MAPFILE>){
#do something;
}
In the above code i open the file twice to read . How do i do
something without reopening the file
See perldoc -f seek.
Ben
.
- Follow-Ups:
- Re: reopen the file
- From: Joost Diepenmaat
- Re: reopen the file
- References:
- reopen the file
- From: vijay@xxxxxxxxxx
- reopen the file
- Prev by Date: Re: compare 2 data files and extract fields for matched lines
- Next by Date: Re: reopen the file
- Previous by thread: Re: reopen the file
- Next by thread: Re: reopen the file
- Index(es):
Relevant Pages
|