Stories
Slash Boxes
Comments

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

grinder (1100)

grinder
  (email not shown publicly)
http://www.landgren.net/perl/
Yahoo! ID: perlgrinder (Add User, Send Message)

Editor of p5p summaries, member of the p5p peanut gallery.

Journal of grinder (1100)

Thursday September 27, 2007
07:05 AM

Bitten by glob crypto context

[ #34555 ]

/me is annoyed

I just spent a while chasing a stupid bug. I have an big log directory that I have to clean up. The number of files caused the shell's wildcard expansion to fail. So I wrote some perl to move things around.

And it didn't do anything. To cut a long story short, I needed the total number of files in the directory. So I had something along the lines of:

perl -le 'print scalar(glob("*"))'

That does not return the number of files. It returns the name of the first file. Or the last. I don't care.

You have to force array context and throw it away:

perl -le 'print scalar(()=glob("*"))'

This prints 31192. I wish Perl didn't do this. Nice interview question though, I guess.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.