Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.

Quick

  • ($a, $b....) = unpack("A2A7...", $packed)
  • push( array, list )

Tuesday, March 27, 2012

Perl file::find

wanted

When you give File::Find a subroutine reference, the 'wanted' subroutine will find $_ set to the file base name - it will not find element 0 of @_ set to the file base name. Element 0 of @_ appears to be a reference to a hash whose keys resemble the File::Find variables (so it's probably a reference to a File::Find object).

So I should have

sub process {
local ($file) = ($_);
...

not
sub process {
local ($file) = (@_);
...


as I normally would.

preprocess

The 'preprocess' sub does get passed arguments in @_ - an array of strings representing the directory's contents. The strings don't have the directory path prefixed.

If a name isn't included in the list you return from preprocess, not only does it not get passed to wanted, it doesn't get searched (if it's a directory) either.

Followers

Blog Archive