On Fri, Jan 16, 2004 at 11:47:59AM -0800, John W. Krahn wrote:
> Paul Johnson wrote:
> > 
> > chad kellerman said:
> > >
> > >    I am starting to work on a script that is going to process a few
> > > files in some users directories.  I thought I would do some checking on
> > > the file to make sure they are there and to make sure they are really
> > > files.  I thought it was going to be pretty straight forward, until I
> > > ran it for the first time.  Sometimes the script sees the file for one
> > > user but not the next ( that I know is there)?
> > >    I must be misunderstanding something small, but I can't figure it
> > > out.
> > >    Can anyone offer any suggestions?
> > 
> > You are using glob in a scalar context.  This is not what you want.
> > 
> > perldoc -f glob
> 
> Interestingly enough it works on my system.  Scalar and list context
> both return the first file name from the glob.

Right, the first time round the loop.  But the behaviour is different
the next time, as chad originally reported.

$ cat globtest
#!/bin/perl -l
mkdir "tst";
chdir "tst";
open  F, ">tst1";
close F;
print scalar glob "*" for 1..4;
print        glob "*" for 1..4;
$ perl globtest
tst1

tst1

tst1
tst1
tst1
tst1
$

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to