Manfred,
The issue is that you're storing the return value of the start method into
$plf, and if you look at the source code, the start method returns 1.
In fact, using Data::Dumper,
print Dumper($plf) . "\n";
returns
$VAR1 = 1;
The start method is a method that doesn't return anything important, but
manipulates things for other methods to use. What you want to do instead is
set up the rules for $plf and then call the start method separately:
use strict;
use warnings;
use Data::Dumper;
use File::Find::Object::Rule ;
my $plf = File::Find::Object::Rule->file->name("*.pl");
$plf->start("./");
while ( my $perl_file = $plf->match ){
print "$perl_file\n";
}
If you're familiar with DBI, you can think of $plf as a statement handle,
setting up the rules ('->file->name("*.pl")', etc) as analogous to DBI's
prepare method, and start as analogous to execute.
Jack
-----Original Message-----
From: Manfred Lotz [mailto:[email protected]]
Sent: Sunday, April 22, 2012 10:22 PM
To: [email protected]
Subject: File::Find::Object::Rule problem
Hi,
I'm trying out File::Find::Object::Rule and get a problem.
Here a minimal example:
#! /usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use File::Find::Object::Rule ;
my $plf = File::Find::Object::Rule->file->name("*.pl")->start( "./" );
while ( my $perl_file = $plf->match ){
print "$perl_file\n";
}
This yields:
Can't call method "match" without a package or object reference
at ./test_find_object_rule.pl line 12.
The example is pretty much modelled after what the man page gave. Any
idea what I'm doing wrong?
--
Manfred
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/