Re: reopen the file




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

.



Relevant Pages

  • Perl style chomp()
    ... I noticed, while perusing the chop() manual page, that some people were giving examples of Perl's chopand chomp() functions. ... # Test for input being an array() ... "Some men are born to greatness, some achieve greatness, ...
    (php.general)
  • Cutting stainless with a small plasma unit?
    ... I'm past the point that I can chomp parts with a chop saw and grind/file a smooth edge. ...
    (rec.crafts.metalworking)
  • Re: Why chop fails?
    ... Why are you using chop() instead of chomp? ... The usual method is to chomp() first, ... chopwill remove only the last character (I think ... You didn't compare the string length before and after ...
    (comp.lang.perl.misc)
  • Re: parse newline
    ... generated by another program, I cannot see the source code, and manual ... using chop, chomp or to use replace cannot help. ... chop $identiy; ...
    (comp.lang.perl.misc)
  • Re: array
    ... since you mentioned chomp - what is the difference between ... > chomp and chop? ... >>also chompthe $guess variable to remove the unneeded newline. ... perldoc -f chomp ...
    (perl.beginners)