rea...@newsguy.com (Harry Putnam) writes:
> What surprised me is the that when I ran them prefaced with the `time'
> utility, I see the sloppy mess I wrote is nearly twice as fast.
I may have found a reason.
in the find sub {}
part you did two returns
return unless -f;
return un
jimsgib...@gmail.com (Jim Gibson) writes:
> You have a logic error in your code somewhere. Your logic for counting
> the files with a name matching a certain pattern is too complicated to
> follow and point out where your error lies and how to fix it. The
> basic problem is that your logic depends
You have a logic error in your code somewhere. Your logic for counting the
files with a name matching a certain pattern is too complicated to follow and
point out where your error lies and how to fix it. The basic problem is that
your logic depends upon detecting when the directory name changes,
jimsgib...@gmail.com (Jim Gibson) writes:
[...]
> I don’t see how the code you have posted can possibly produce the
> output you have reported. The code above looks like error checking
> that the user of the program has entered one argument, and that
> argument is the name of a directory.
Egad,
jimsgib...@gmail.com (Jim Gibson) writes:
[...]
> I don’t see how the code you have posted can possibly produce the
> output you have reported. The code above looks like error checking
> that the user of the program has entered one argument, and that
> argument is the name of a directory.
Egad,
On Jun 28, 2017, at 2:10 PM, Harry Putnam wrote:
>
> 1) I want to count numeric named files in each directory.
>
> 2) I want to capture the name of the directory those files are in
>
> 3) I want to print the directory name and the count (if any) for each
> directory.
>
> I know that all the i
I think the issue is as you mentioned exporting find from File::Find::Rule.
However File::Find I am not sure I will get that flexibility to search only
1 level depth.
On Thu, Jan 10, 2013 at 6:07 PM, David Precious wrote:
> On Thu, 10 Jan 2013 17:56:18 +0530
> punit jain wrote:
>
> > I need to
punit jain wrote:
Hi,
Hello,
I have a requirement where I have directory structure like : -
test --> test/user1/files/, test/user2/files/, test/user3/files/ etc.
under sub-directories with usernames I have file with name usersettings.
So the final structure as : -
test / user1 / usersett
On Thu, 10 Jan 2013 17:56:18 +0530
punit jain wrote:
> I need to get all the subdirectories of test and then read the file
> usersettings under that later on to do some processing. I wrote code
> below :-
> #!/usr/bin/perl
> use strict;
> use warnings;
> use File::Basename qw(basename dirname);
>
ׁHi Manfred,
On Mon, 23 Apr 2012 12:24:49 +0200
Manfred Lotz wrote:
> On Mon, 23 Apr 2012 11:01:33 +0300
> Shlomi Fish wrote:
>
> > Hi all,
> >
> > On Mon, 23 Apr 2012 10:12:33 +0300
> > Shlomi Fish wrote:
> >
> > > Hi Jack,
> > >
> > > On Mon, 23 Apr 2012 06:02:55 +
> > > Jack Maney
On Mon, 23 Apr 2012 06:02:55 +
Jack Maney 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
On Mon, 23 Apr 2012 11:01:33 +0300
Shlomi Fish wrote:
> Hi all,
>
> On Mon, 23 Apr 2012 10:12:33 +0300
> Shlomi Fish wrote:
>
> > Hi Jack,
> >
> > On Mon, 23 Apr 2012 06:02:55 +
> > Jack Maney wrote:
> >
> > > Manfred,
> > >
> > > The issue is that you're storing the return value of th
Hi all,
On Mon, 23 Apr 2012 10:12:33 +0300
Shlomi Fish wrote:
> Hi Jack,
>
> On Mon, 23 Apr 2012 06:02:55 +
> Jack Maney 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 metho
Hi Jack,
On Mon, 23 Apr 2012 06:02:55 +
Jack Maney 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";
>
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 impo
> "M" == Marc writes:
M>Thanks to both Uri and John for their input. I've added your
suggestions and the script is much cleaner and more concise now.
M>I decided to keep the header info in the sub because I'm now setting
the subject to the path of the error log, so at a glance
Thanks to both Uri and John for their input. I've added your
suggestions and the script is much cleaner and more concise now.
I decided to keep the header info in the sub because I'm now setting
the subject to the path of the error log, so at a glance I know where there's a
pro
> "M" == Marc writes:
M>The script works great but I'd like to get advice on how I can
M>clean up my code, so any comments are welcome.
M>Also, do I really need the foreach block in there? I couldn't
M>get it to work without it, but it seems like I should be able
> "HW" == Hal Wigoda writes:
HW> Why clean it up when it works and is not obfusticating.
because he asked for comments and it will be educational to all on the
list.
uri
--
Uri Guttman -- uri AT perlhunter DOT com --- http://www.perlhunter.com --
Perl Developer Recruit
Marc wrote:
I've written a script to traverse my web server, find any files called
"error_log", e-mail them to me, and then delete them. It is triggered
by cron twice a day.
The script works great but I'd like to get advice on how I can clean
up my code, so any comments are welcome.
Also, do I
Why clean it up when it works and is not obfusticating.
On Mon, Jul 18, 2011 at 8:59 PM, Marc wrote:
> I've written a script to traverse my web server, find any files called
> "error_log", e-mail them to me, and then delete them. It is triggered by
> cron twice a day.
>
> The scr
Unknown User wrote:
I have this script to find out where a perl module is on my machine:
[unkn...@knowme:~/bin]$ cat findmodule
#!/usr/bin/perl -w
use File::Find;
use strict;
if ($ENV{"INC"} ) { # INC=PATH1:PATH2 ./getmodule
perldoc perlrun
[ SNIP ]
PERL5LIBA list
On Saturday 24 Apr 2010 22:00:56 Harry Putnam wrote:
> When using File::Find;
> Is there any built in way to know when you are in the top level of one
> of the directories in @directories?
>
> I mean besides grepping $File::Find::dir.
>
> I know that give the current directory name and of course
On Monday 01 Mar 2010 19:31:15 Shawn H Corey wrote:
> Shlomi Fish wrote:
> > Well, Matt S. Trout shared his sentiments about "I cannot use CPAN" here:
> >
> > http://www.shadowcat.co.uk/blog/matt-s-trout/but-i-cant-use-cpan/
>
> Well, Matt is wrong. You can't always use CPAN. Yes, you can set i
Shlomi Fish wrote:
> Well, Matt S. Trout shared his sentiments about "I cannot use CPAN" here:
>
> http://www.shadowcat.co.uk/blog/matt-s-trout/but-i-cant-use-cpan/
>
Well, Matt is wrong. You can't always use CPAN. Yes, you can set it up
so you can use it in development, but that doesn't mean
On Monday 01 Mar 2010 15:00:26 raphael() wrote:
> On Mon, Mar 1, 2010 at 6:18 PM, Shawn H Corey wrote:
> > raphael() wrote:
> > > Hi,
> > >
> > > How can I stop File::Find to go below current dir? i.e. no recursion.
> > >
> > > Although I can use glob or <*> to get file names in current dir.
> >
On Mon, Mar 1, 2010 at 6:18 PM, Shawn H Corey wrote:
> raphael() wrote:
> > Hi,
> >
> > How can I stop File::Find to go below current dir? i.e. no recursion.
> >
> > Although I can use glob or <*> to get file names in current dir.
> > But I wanted to know if File::Find has a maxdepth limit like l
On Monday 01 Mar 2010 13:23:16 raphael() wrote:
> Hi,
>
> How can I stop File::Find to go below current dir? i.e. no recursion.
>
> Although I can use glob or <*> to get file names in current dir.
> But I wanted to know if File::Find has a maxdepth limit like linux "find".
>
Not, by itself, but
raphael() wrote:
> Hi,
>
> How can I stop File::Find to go below current dir? i.e. no recursion.
>
> Although I can use glob or <*> to get file names in current dir.
> But I wanted to know if File::Find has a maxdepth limit like linux "find".
>
> The script I created uses a switch which decides
Telemachus writes:
> On Mon Jul 06 2009 @ 3:31, Harry Putnam wrote:
>> Thanks to all ...
>> Now I'm curious about something else:
>>
>> Is the mode in a stat(file) readout something still different
>> than octal or decimal?
>
> As John answered, there's more there than just the permissions. If
On Mon Jul 06 2009 @ 3:31, Harry Putnam wrote:
> Thanks to all ...
> Now I'm curious about something else:
>
> Is the mode in a stat(file) readout something still different
> than octal or decimal?
As John answered, there's more there than just the permissions. If you
check perldoc -f stat, ther
Harry Putnam wrote:
Thanks to all ...
Now I'm curious about something else:
Is the mode in a stat(file) readout something still different
than octal or decimal?
I see `33261' show up in the `mode' slot on a file with 755 permissions
(from perldoc -f stat:
[...]
($dev,$ino,$mode,$nli
Thanks to all ...
Now I'm curious about something else:
Is the mode in a stat(file) readout something still different
than octal or decimal?
I see `33261' show up in the `mode' slot on a file with 755 permissions
(from perldoc -f stat:
[...]
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$si
On Mon Jul 06 2009 @ 7:00, Harry Putnam wrote:
> Can anyone tell me how printing of $mode = 0755 turns into 493?
Yup: what's in $mode is an octal number. Its decimal equivalent is 493. What
you really want to print out is the string '0755', but the string and the
octal number are not the same thi
On Mon, Jul 6, 2009 at 08:00, Harry Putnam wrote:
snip
> Can anyone tell me how printing of $mode = 0755 turns into 493?
snip
> my $mode = 0755;
snip
> print "hpdb chmod $mode $fname\n";
snip
0755 is 493. More specifically they are two representations of the
same number: the first i
> ""Chas" == "Chas Owens" writes:
"Chas> Huh, never looked at File::Finder before, it looks like it would only
"Chas> make sense if you already knew the UNIX find command. I normally see
"Chas> people use File::Find::Rule when they don't want to write their own
"Chas> wanted function.
Indee
>
> http://search.cpan.org/~tty/kurila-1.19_0/lib/Benchmark.pm
>
> --
> Ron Bergin
Thanks to all for replying.
Greg.
signature.asc
Description: This is a digitally signed message part
On Mon, May 18, 2009 at 21:02, Gunnar Hjalmarsson wrote:
> AndrewMcHorney wrote:
>>
>> I am getting totally confused. All I want is a simple find function call
>> what will return all the files that are in c:\*.*.
>
> File::Find is useful for recursive tasks. If all you want is to list the
> files
Greg Eldridge wrote:
> On Mon, 2009-05-18 at 17:36 -0700, r...@i.frys.com wrote:
>
> What Benchmark .pm are you using ?
> CPAN i/benchmark/ => lists 66 entries, but none of which are simply
> Benchmark
>
> Thanks in advance.
>
> Greg.
>
http://search.cpan.org/~tty/kurila-1.19_0/lib/Benchmark.pm
Greg Eldridge wrote:
What Benchmark .pm are you using ?
CPAN i/benchmark/ => lists 66 entries, but none of which are simply
Benchmark
Thanks in advance.
http://search.cpan.org/~nwclark/perl-5.8.9/lib/Benchmark.pm
--
David Moreno
http://twitter.com/damog
--
To unsubscribe, e-mail: beginne
On Mon, 2009-05-18 at 17:36 -0700, r...@i.frys.com wrote:
> #!/usr/bin/perl
>
> use strict;
> use warnings;
> use File::Find;
> use Benchmark qw/cmpthese/;
>
> cmpthese( 10, {
> 'dir' => sub {my @files = `dir /b /a-d /s c:\test` },
>
> 'filefind' => sub {my @files;
>
AndrewMcHorney wrote:
I am getting totally confused. All I want is a simple find function call
what will return all the files that are in c:\*.*.
File::Find is useful for recursive tasks. If all you want is to list the
files in one directory, there are simpler ways. Personally I would use
ope
On Mon, May 18, 2009 at 20:36, wrote:
> Chas. Owens wrote:
>> On Mon, May 18, 2009 at 19:41, AndrewMcHorney wrote:
>>> Charles
>>>
>>> I am getting totally confused. All I want is a simple find function call
>>> what will return all the files that are in c:\*.*. This is on PC running
>>> windows
Chas. Owens wrote:
> On Mon, May 18, 2009 at 19:41, AndrewMcHorney wrote:
>> Charles
>>
>> I am getting totally confused. All I want is a simple find function call
>> what will return all the files that are in c:\*.*. This is on PC running
>> windows. I thought you mentioned to use file:find() whe
AndrewMcHorney wrote:
Charles
I am getting totally confused. All I want is a simple find function call
what will return all the files that are in c:\*.*. This is on PC running
windows. I thought you mentioned to use file:find() where one of the
parameters would be a function which would be ca
On Mon, May 18, 2009 at 19:41, AndrewMcHorney wrote:
> Charles
>
> I am getting totally confused. All I want is a simple find function call
> what will return all the files that are in c:\*.*. This is on PC running
> windows. I thought you mentioned to use file:find() where one of the
> parameters
Charles
I am getting totally confused. All I want is a simple find function
call what will return all the files that are in c:\*.*. This is on PC
running windows. I thought you mentioned to use file:find() where one
of the parameters would be a function which would be called once for
each fil
Chas. Owens wrote:
On Mon, May 18, 2009 at 19:05, Gunnar Hjalmarsson wrote:
AndrewMcHorney wrote:
I looked at the documentation for this function and I find it confusing.
Try File::Finder for a less confusing interface to *the module* File::Find.
snip
Huh, never looked at File::Finder befor
On Mon, May 18, 2009 at 19:05, Gunnar Hjalmarsson wrote:
> AndrewMcHorney wrote:
>>
>> I looked at the documentation for this function and I find it confusing.
>
> Try File::Finder for a less confusing interface to *the module* File::Find.
snip
Huh, never looked at File::Finder before, it looks l
AndrewMcHorney wrote:
I looked at the documentation for this function and I find it confusing.
Try File::Finder for a less confusing interface to *the module* File::Find.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: beginners-unsubscr...@perl
On Mon, May 18, 2009 at 18:40, AndrewMcHorney wrote:
> Hello
>
> I looked at the documentation for this function and I find it confusing.
> What do you pass in to get all the files on drive letter c?
snip
find \&wanted, "c:/";
will run the wanted function once for every file and directory on the
On Mon, Jan 12, 2009 at 16:05, icarus wrote:
> I'm trying to all count files in a home dir and all subdirs *except* a
> subdir called 'backup'.
When you run into the condition where you don't want to recurse
further, set $File::Find::prune to 1 (e.g. $File::Find::prune = 1 if
$_ = "./backup";).
oryann9 wrote:
Perl'ers,
I was going to reply but I see that this is also posted to PerlMonks.
:(
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.-- Larry Wall
--
To unsubscri
On Jan 4, 2008 12:33 PM, oryann9 <[EMAIL PROTECTED]> wrote:
> if ( $fs =~ m|\x2f{1}?|g ) { ##-- if "/" is matched --#
That's a pretty hard way to write the pattern m#/#. And it's wrong,
too, since you have a /g modifier on it. Or maybe I'm misunderstanding
what you're doing. Did you mean to use
> "reader" == reader <[EMAIL PROTECTED]> writes:
reader> I was using `use Cwd 'abs_path'; at first but someone said it
reader> shouldn't be necessary... turns out it is, unless user gives absolute
reader> names to File::Find. Apparently because File::Find cds to source
reader> directories to
[EMAIL PROTECTED] (Randal L. Schwartz) writes:
>> "reader" == reader <[EMAIL PROTECTED]> writes:
>
> reader> The output I'm getting is a relative name, and that is what I've fed
> reader> the find function. But still the docu seems to indicate it will
> reader> return the absolute (`complete
> "reader" == reader <[EMAIL PROTECTED]> writes:
reader> The output I'm getting is a relative name, and that is what I've fed
reader> the find function. But still the docu seems to indicate it will
reader> return the absolute (`complete' as above) file name.
No, "complete" is not "absolute"
On 12/2/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Near as I can tell, when looking at perldoc File::Find
> when used as a variable $File::Find::name it supposed to be the
> absolute filename
> The output I'm getting is a relative name, and that is what I've fed
> the find function. But
schms schreef:
> opendir DH, $DIR or die "Cannot open '$DIR' $!";
> print map "$DIR/$_\n", readdir DH;
> closedir DH;
Looks very 'global variables' oriented to me.
Compare to:
{ opendir my $dh, $dir
or die "Cannot open '$dir': $!";
while (my $e = readdir $dh) {
$
On 27 Sep., 15:01, [EMAIL PROTECTED] (Paul Lalli) wrote:
> On Sep 27, 6:00 am, [EMAIL PROTECTED] (Schms) wrote:
>
> > I have a UNIX directory $DIR which contains a lot of files and
> > subdirecotires. Now, I would
>
> > like to list all files and subdirectories in $DIR only. That means,
> > $File:
On Sep 27, 6:00 am, [EMAIL PROTECTED] (Schms) wrote:
> I have a UNIX directory $DIR which contains a lot of files and
> subdirecotires. Now, I would
>
> like to list all files and subdirectories in $DIR only. That means,
> $File::Find should not
>
> go into any subdirectories of $DIR and list the
schms wrote:
Hi,
Hello,
I have a UNIX directory $DIR which contains a lot of files and
subdirecotires. Now, I would like to list all files and
subdirectories in $DIR only. That means, $File::Find should not
go into any subdirectories of $DIR and list the files and
subdirectories there as wel
Oh, i am very sorry for my mistakes. Actually i write email from my
mobile, and somehow that backslash vanished. I just checked now from a
PC and its working now. Thanks. And i also commented that line
sub rm();
thanks everybody!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional com
Ron Bergin wrote:
On Aug 28, 10:10 pm, [EMAIL PROTECTED] (Omega -1911) wrote:
Ha! Here is a snippet that I use on a windows machine. It works!!!
use File::Find;
sub rm();
$count = 0;
@directories = ("F://Hindi/RHTDM");
find(\&rm, @directories);
sub rm() {
$count++;
my ($filename) = $_;
if ($f
On Aug 28, 10:10 pm, [EMAIL PROTECTED] (Omega -1911) wrote:
> Ha! Here is a snippet that I use on a windows machine. It works!!!
>
> use File::Find;
>
> sub rm();
> $count = 0;
> @directories = ("F://Hindi/RHTDM");
> find(\&rm, @directories);
>
> sub rm() {
> $count++;
> my ($filename) = $_;
> if (
On Aug 28, 10:10 pm, [EMAIL PROTECTED] (Omega -1911) wrote:
> Ha! Here is a snippet that I use on a windows machine. It works!!!
>
> use File::Find;
>
> sub rm();
> $count = 0;
> @directories = ("F://Hindi/RHTDM");
> find(\&rm, @directories);
>
> sub rm() {
> $count++;
> my ($filename) = $_;
> if (
Somu wrote:
use strict;
use warnings;
use File::Find;
sub rm();
Remove the (). This prototypes the subroutine to force it to have no parameters.
sub rm;
In fact leaving this line out altogether is probably the best option. The
subroutine
doesn't need to be declared early.
my $count=0;
my
On 8/31/07, Somu <[EMAIL PROTECTED]> wrote:
> use strict;
> use warnings;
> use File::Find;
> sub rm();
> my $count=0;
> my @dir = ("F://Hindi/RHTDM");
> find(&rm,@dir);
>
> sub rm(){$count++
> my ($fname)= $_;
> if($fname=~ /mp3/){print "$count $fname"}
> }
PLEASE!!! Before coming to this list an
Those double dollar signs are formatting errors of my mail server. And
with the code i posted, the error has to be at the if statement in the
rm definition
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
use strict;
use warnings;
use File::Find;
sub rm();
my $count=0;
my @dir = ("F://Hindi/RHTDM");
find(&rm,@dir);
sub rm(){$count++
my ($fname)= $_;
if($fname=~ /mp3/){print "$count $fname"}
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://le
Somu wrote:
It gave the error
Use of uninitialized value in pattern match (m//) at test.pl line 13.
Can't use string ("") as a subroutine ref while "strict refs" in use
at C:/Perl/lib/File/Find.pm line 822.
Please show your code.
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For addition
On 8/31/07, Somu <[EMAIL PROTECTED]> wrote:
> It gave the error
>
> Use of uninitialized value in pattern match (m//) at test.pl line 13.
> Can't use string ("") as a subroutine ref while "strict refs" in use
> at C:/Perl/lib/File/Find.pm line 822.
>
>
> ???
>
> On 8/29/07, Omega -1911 <[EMAIL PRO
It gave the error
Use of uninitialized value in pattern match (m//) at test.pl line 13.
Can't use string ("") as a subroutine ref while "strict refs" in use
at C:/Perl/lib/File/Find.pm line 822.
???
On 8/29/07, Omega -1911 <[EMAIL PROTECTED]> wrote:
> On 8/28/07, Randal L. Schwartz <[EMAIL PRO
Randal L. Schwartz wrote:
"Somu" == Somu <[EMAIL PROTECTED]> writes:
Somu> Good sense of humour! Actually i wanted to search for F:/Hindi/RHTDM
Somu> and i entered only /Hindi/RHTDM/
Why did you do that? I think you have to enter the full path on Windows.
However, I don't run Windows (anywh
On 8/28/07, Randal L. Schwartz <[EMAIL PROTECTED]> wrote:
> > "Somu" == Somu <[EMAIL PROTECTED]> writes:
>
> Somu> Good sense of humour! Actually i wanted to search for F:/Hindi/RHTDM
> Somu> and i entered only /Hindi/RHTDM/
>
> Why did you do that? I think you have to enter the full path on
I write all my programs for my personal use in my PC only, just to
learn perl. I will use the code again and tell you, Mr.Randal. Thanks
anyway. Actually, i have written something which will get all file and
folder names in a given folder matching a regex, but then i want the
same subroutine to run
> "Somu" == Somu <[EMAIL PROTECTED]> writes:
Somu> Good sense of humour! Actually i wanted to search for F:/Hindi/RHTDM
Somu> and i entered only /Hindi/RHTDM/
Why did you do that? I think you have to enter the full path on Windows.
However, I don't run Windows (anywhere!) so I can't actual
Hi,
I dont use perl on windows, so if there are any special things about
File::Find your Filesystem I can't help you. Please show us the code
you're using to find the files you're looking for. Maybe we have some
hints for you.
HTH, Martin
On Tue, 28 Aug 2007 00:28:40 +0530
Somu <[EMAIL PROTECTE
Good sense of humour! Actually i wanted to search for F:/Hindi/RHTDM
and i entered only /Hindi/RHTDM/
it didnt find anything. When i tried to print the list in which i
pushed the $File::Find::name it said
use of uninitialised ...
Actually i am unable to understand clearly from the docs for File::
> "Somu" == Somu <[EMAIL PROTECTED]> writes:
Somu> The code didnt work. Error:
Somu> Can't stat /my/dir: No such file or directory
Somu> at test.pl line 12
Then you don't have "/my/dir". :)
I'd actually be surprised if you did. I haven't seen any systems that have
/my as a top-level direc
The code didnt work. Error:
Can't stat /my/dir: No such file or directory
at test.pl line 12
On 8/20/07, Martin Barth <[EMAIL PROTECTED]> wrote:
> On Fri, 17 Aug 2007 07:48:33 -0700
> [EMAIL PROTECTED] (Randal L. Schwartz) wrote:
>
> > Why not just:
> >
> > my @list;
> > find sub { push @list, $$
On Fri, 17 Aug 2007 07:48:33 -0700
[EMAIL PROTECTED] (Randal L. Schwartz) wrote:
> Why not just:
>
> my @list;
> find sub { push @list, $File::Find::name }, "/var/SAMPLES";
HTH
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org
On Aug 17, 11:45 am, [EMAIL PROTECTED] (Paul Lalli) wrote:
> On Aug 16, 7:21 pm, [EMAIL PROTECTED] (Mr. Shawn H. Corey) wrote:
>
> > Paul Lalli wrote:
> > > So define the subroutine in the same scope as the array. Move the
> > > subroutine into the if-statement as well.
>
> > Huh?
>
> What part of
> "Chas" == Chas Owens <[EMAIL PROTECTED]> writes:
>> I get it now, I think. I'm not sure why you put "my $i = 5" in there,
>> since that's unrelated to the $i of the closure.
Chas> The" my $i = 5;" was to show that the two variables named $i were
Chas> indeed in different scopes. The expe
On 8/18/07, Randal L. Schwartz <[EMAIL PROTECTED]> wrote:
> > ""Chas" == "Chas Owens" <[EMAIL PROTECTED]> writes:
>
> "Chas> {
> "Chas> my $i;
> "Chas> sub iter { return $i++ }
> "Chas> }
>
> "Chas> my $i = 5;
> "Chas> print iter(), "\n";
> "Chas> print iter(), "\n";
> "Chas> pr
> ""Chas" == "Chas Owens" <[EMAIL PROTECTED]> writes:
"Chas> {
"Chas> my $i;
"Chas> sub iter { return $i++ }
"Chas> }
"Chas> my $i = 5;
"Chas> print iter(), "\n";
"Chas> print iter(), "\n";
"Chas> print iter(), "\n";
"Chas> print iter(), "\n";
I get it now, I think. I'm not
On 8/17/07, Chas Owens <[EMAIL PROTECTED]> wrote:
snip
> which still works in Perl 5.8.8, but probably shouldn't. I thought
> they were going to fix this after Perl 5.6.1, but apparently it is
> still around (or has reemerged). Maybe Perl 6 will finally kill it (I
> have to test it in Pugs now).
On 8/17/07, Chas Owens <[EMAIL PROTECTED]> wrote:
snip
> Do you mean "broken" as in it doesn't work, it shouldn't work, or it
> is a bad idea? While I think it shouldn't work and it is a bad idea,
> it does, much to my surprise when I tested it before posting*,
> demonstrably** work with Perl 5.8.
On 8/17/07, Chas Owens <[EMAIL PROTECTED]> wrote:
snip
> warnings pragma). I think it is a variant of the classic obscenity
snip
> my $var if 0;
snip
> still around (or has reemerged). Maybe Perl 6 will finally kill it (I
> have to test it in Pugs now).
snip
Pugs prints five zeros, so it
> ""Chas" == "Chas Owens" <[EMAIL PROTECTED]> writes:
"Chas> ** here is the example for reference sake.
"Chas> #!/usr/bin/perl
"Chas> use strict;
"Chas> use warnings;
"Chas> {
"Chas>my $i;
"Chas>sub iter { return $i++ }
"Chas> }
"Chas> my $i = 5;
"Chas> print iter(), "\n";
"
On 8/17/07, Paul Lalli <[EMAIL PROTECTED]> wrote:
snip
> > see attached.
>
> And this file was supposed to demonstrate, what, exactly?
snip
I believe he was trying to demonstrate the "right way" to build an
iterator*, as opposed to the example** I used to show that, in fact, a
subroutine can be gi
On Aug 17, 11:13 am, [EMAIL PROTECTED] (Mr. Shawn H. Corey) wrote:
> Paul Lalli wrote:
> > On Aug 16, 7:21 pm, [EMAIL PROTECTED] (Mr. Shawn H. Corey) wrote:
> >> Paul Lalli wrote:
> >>> So define the subroutine in the same scope as the array. Move the
> >>> subroutine into the if-statement as well
Paul Lalli wrote:
On Aug 16, 7:21 pm, [EMAIL PROTECTED] (Mr. Shawn H. Corey) wrote:
Paul Lalli wrote:
So define the subroutine in the same scope as the array. Move the
subroutine into the if-statement as well.
Huh?
What part of what I said did you not understand?
All of it.
Please spe
> ""Dan" == "Dan Sopher" <[EMAIL PROTECTED]> writes:
"Dan> Thanks for everyone's replies. It helped a lot. It ended up like this.
"Dan> My next question is the use of the array reference, @list. Is it bad
"Dan> form?
Your solution confuses me.
Why not just:
my @list;
find sub { push @list,
On Aug 16, 7:21 pm, [EMAIL PROTECTED] (Mr. Shawn H. Corey) wrote:
> Paul Lalli wrote:
> > So define the subroutine in the same scope as the array. Move the
> > subroutine into the if-statement as well.
>
> Huh?
What part of what I said did you not understand?
> Please speak Perl.
Please learn s
On Aug 16, 7:21 pm, [EMAIL PROTECTED] (Mr. Shawn H. Corey) wrote:
> Paul Lalli wrote:
> > So define the subroutine in the same scope as the array. Move the
> > subroutine into the if-statement as well.
>
> Huh?
What part of what I said did you not understand?
> Please speak Perl.
Please learn s
On 8/16/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote:
> Paul Lalli wrote:
> > So define the subroutine in the same scope as the array. Move the
> > subroutine into the if-statement as well.
>
> Huh?
>
> Please speak Perl.
>
> Subroutines are global. Unless they're anonymous. And even then, t
Thanks for everyone's replies. It helped a lot. It ended up like this.
My next question is the use of the array reference, @list. Is it bad
form?
#!/usr/bin/perl -w
use strict;
use File::Find;
if (1) {
my $dir = "/var/SAMPLES";
my @list;
find ( { wanted=>sub { &found(
Paul Lalli wrote:
So define the subroutine in the same scope as the array. Move the
subroutine into the if-statement as well.
Huh?
Please speak Perl.
Subroutines are global. Unless they're anonymous. And even then, they are.
It's just difficult to get a hold on them.
--
Just my 0.0
Dan Sopher wrote:
Hello. The following code example creates a list of regular files in a
directory. Using File::Find, I'm unable to localize an array to hold the
list of files. Is there a way to create the list with a localized array?
TIA.
#!/usr/bin/perl -w
## Create a list of regular files
1 - 100 of 184 matches
Mail list logo