develooper Front page | perl.beginners | Postings from April 2012

Re: File::Find::Object::Rule problem

Thread Previous | Thread Next
From:
Shlomi Fish
Date:
April 23, 2012 00:19
Subject:
Re: File::Find::Object::Rule problem
Message ID:
20120423101233.47eb57a6@lap.shlomifish.org
Hi Jack,

On Mon, 23 Apr 2012 06:02:55 +0000
Jack Maney <jmaney@adknowledge.com> wrote:

> 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.
> 

Thanks for helping Manfred! However, as he noted, the documentation on
https://metacpan.org/module/File::Find::Object::Rule is misleading and ought to be corrected. Since
I've originated File::Find::Object::Rule (after forking it from the original
File::Find::Rule) and still maintain it, then I can do it now. So thanks to
Manfred as well for spotting this issue.

Regards,

	Shlomi Fish

> Jack
> 
> 
[SNIPPED]

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Best Introductory Programming Language - http://shlom.in/intro-lang

Real programmers don’t write workarounds. They tell their users to upgrade
their software.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About