SPUG: File::Find dumping core

Chris Wilkes cwilkes at singingfish.com
Fri May 11 19:06:26 CDT 2001


I was playing around with File;:Find and wanted to find .cgi files while
ignoring those under .snapshot directories.

I came up with this simple routine.  I hate doing @files as  a
Main:: variable but didn't see a way around it.

It worked w/o the .snapshot ignoring line.  When I added that in it does a
seg fault.  I'm using Perl 5.6.

Any ideas on why this is happening?  The problem only seems to show up if
the pattern match is not the entire string (for some reason putting the
entire pathname in for \.snapshot causes it to work).

Also if you know of a better way to use File::Find please let me know.

Chris


#!/usr/bin/perl

use File::Find;
use strict;

my @files;
find (\&wanted, "./");

foreach (@files) {
  print "'$_'\n";
}

sub wanted {
  next if ($File::Find::name =~ /\.snapshot/);
  -f && /\.cgi$/ && push @files, $File::Find::name;
}


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/





More information about the spug-list mailing list