I asked this just b/c I want to do matrix calculation in perl.
I found under some conditions a recursion is more effective.
Thanks everybody.
On 2017/3/29 23:31, Chas. Owens wrote:
On Tue, Mar 28, 2017 at 9:27 PM PYH mailto:p...@vodafonemail.de>> wrote:
Hi,
what's the be
Forwarding to the list.
Begin forwarded message:
Date: Wed, 29 Mar 2017 11:32:08 -0400
From: Shawn H Corey
To: Shlomi Fish
Subject: Re: how to recursion
On Wed, 29 Mar 2017 17:22:36 +0300
Shlomi Fish wrote:
> my_recursion accepts $self as its first argument, so you should pass
> it
On Tue, Mar 28, 2017 at 9:27 PM PYH wrote:
> Hi,
>
> what's the better way to write a recursion in perl's class?
>
> sub my_recursion {
> my $self = shift;
>
> if (...) {
> $self->my_recursion;
> }
> }
>
> this
Hi Shawn!
On Wed, 29 Mar 2017 08:09:12 -0400
Shawn H Corey wrote:
> On Wed, 29 Mar 2017 09:25:06 +0800
> PYH wrote:
>
> > sub my_recursion {
> > my $self = shift;
> >
> > if (...) {
> > $self->my_recursion;
>
> # you don't need $self. subroutine lookup starts
>
nough.
my_recursion();
> }
> }
More thoughts on recursion:
https://lookatperl.blogspot.ca/2012/11/a-look-at-recursion.html
--
Don't stop where the ink does.
Shawn H Corey
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
On 03/28/2017 09:25 PM, PYH wrote:
Hi,
what's the better way to write a recursion in perl's class?
sub my_recursion {
my $self = shift;
if (...) {
$self->my_recursion;
}
}
this one?
i am not sure what you mean by better. your code would work if you
Hi,
what's the better way to write a recursion in perl's class?
sub my_recursion {
my $self = shift;
if (...) {
$self->my_recursion;
}
}
this one?
thanks.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail
On Wed, Jul 8, 2015 at 10:51 AM, Nagy Tamas (TVI-GmbH) <
tamas.n...@tvi-gmbh.de> wrote:
> How can it be? I call the subroutine in the middle of a tag. How can be
> the document closed?
>
Well, I don't get that (could it be that call to
Travers($dir,$writer);
before the sub def?) but to get your
Hi,
Thanks for the solutions of the recent problems.
I would like to traverse a dir on the HDD at a part of the XML generation.
So I generated about 75% of an xml file with xml::writer, and it comes a
Projectstructure tag. Between these tag I simply list a dir into empty tags
.
If recursion is
On 2012-02-27 03:52, Shawn H Corey wrote:
There is no simplify way of doing this.
perl -wle '
my $s = "{red,green,blue},{small,large},{light,dark}";
print for glob $s;
'
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl
On Sun, Feb 26, 2012 at 09:30:44PM -0500, Steve Bertrand wrote:
> I came across a question early this morning on a forum that
> intrigued me. I literally spent about five hours trying everything
> to solve it, but I couldn't.
Sometimes Perl is just a means to get at the corect tool:
my $attribute
On 2012-02-26 23:55, Rob Dixon wrote:
On 27/02/2012 02:30, Steve Bertrand wrote:
I know this isn't a beginner's question, but I know there are geniuses
here. Is there a way to simplify this within Perl?
Hi Steve
Much of the complexity comes from working with the nested data
structure. Writi
On 27/02/2012 02:30, Steve Bertrand wrote:
I came across a question early this morning on a forum that intrigued
me. I literally spent about five hours trying everything to solve it,
but I couldn't.
Every attempt at recursion, counting, numbering, hashing etc failed. Is
there a way t
and cross-product it with a recursive call to the rest. Like this:
fyi: http://forums.devshed.com/perl-programming-6/recursion-help-882763.html
Steve
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
On 2012-02-26 21:52, Shawn H Corey wrote:
On 12-02-26 09:30 PM, Steve Bertrand wrote:
I know this isn't a beginner's question, but I know there are geniuses
here. Is there a way to simplify this within Perl?
There is no simplify way of doing this. Separate off the first attribute
and cross-pro
On 12-02-26 09:30 PM, Steve Bertrand wrote:
I know this isn't a beginner's question, but I know there are geniuses
here. Is there a way to simplify this within Perl?
There is no simplify way of doing this. Separate off the first attribute
and cross-product it with a recursive call to the rest.
I came across a question early this morning on a forum that intrigued
me. I literally spent about five hours trying everything to solve it,
but I couldn't.
Every attempt at recursion, counting, numbering, hashing etc failed. Is
there a way to use recursion to eliminate the repeated and
On Sat, Aug 7, 2010 at 09:36, Amit Saxena wrote:
snip
> The purpose of this activity is to model a hierarchical representation of
> dependent components, each of one will be represented as a service.
>
> I had a look at the Graph module (
> http://search.cpan.org/~jhi/Graph-0.94/lib/Graph.pod) but
On Fri, Aug 6, 2010 at 8:09 PM, Randal L. Schwartz wrote:
> > "Amit" == Amit Saxena writes:
>
> Amit> I am working on a tree implementation (with any number of parent
> Amit> and child nodes) in perl. Every node is defined as a object of a
> Amit> "Node" class which I have created as a ".pm"
> "Amit" == Amit Saxena writes:
Amit> I am working on a tree implementation (with any number of parent
Amit> and child nodes) in perl. Every node is defined as a object of a
Amit> "Node" class which I have created as a ".pm" module.
Unless this is for a student exercise, you probably just wa
Hi all,
I am working on a tree implementation (with any number of parent and child
nodes) in perl. Every node is defined as a object of a "Node" class which I
have created as a ".pm" module.
I have defined a method "getParentNodes" which returns reference to an array
having all the (immediate) pa
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
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
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 &q
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 scri
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 if recursion i
Dermot wrote:
>Hi,
>
>I was reading Higher Order Perl[1] last night and, dishearteningly,
>got stuck on chapter one.
>
>Mark Dominus offers the following as a binary string conversion
>example of how recursion can work.
>
>
>use strict;
>use warnings;
>
>
2009/7/10 Telemachus :
> On Fri Jul 10 2009 @ 9:26, Dermot wrote:
>> The algorithm works perfectly but my understanding of it's workings is amiss.
>>
>> When I look at this I see $E initialised and then concatenate with the
>> the modulus of
>
> It helps for me to walk through it visually, indenti
On Fri Jul 10 2009 @ 9:26, Dermot wrote:
> The algorithm works perfectly but my understanding of it's workings is amiss.
>
> When I look at this I see $E initialised and then concatenate with the
> the modulus of
> 37 % 2 =1
> 18 % 2 = 0
> 9 % 2 = 1
> 4 % 2 = 0
> 2 % 2 = 0
>
> That by my reckoni
On Fri, 2009-07-10 at 13:42 +0100, Dermot wrote:
> Why is $E getting assigned the value from $k?
my $E = binary($k);
I said $E will be assigned the string that represents $k, not it's
value.
> $E is initialised and
> then assigned the return value of the binary(18) during the first
> invocation
2009/7/10 Shawn H. Corey :
> On Fri, 2009-07-10 at 09:26 +0100, Dermot wrote:
>> The algorithm works perfectly but my understanding of it's workings is amiss.
>>
>> When I look at this I see $E initialised and then concatenate with the
>> the modulus of
>> 37 % 2 =1
>> 18 % 2 = 0
>> 9 % 2 = 1
>> 4
On Fri, 2009-07-10 at 09:26 +0100, Dermot wrote:
> The algorithm works perfectly but my understanding of it's workings is amiss.
>
> When I look at this I see $E initialised and then concatenate with the
> the modulus of
> 37 % 2 =1
> 18 % 2 = 0
> 9 % 2 = 1
> 4 % 2 = 0
> 2 % 2 = 0
>
> That by my
Hi,
I was reading Higher Order Perl[1] last night and, dishearteningly,
got stuck on chapter one.
Mark Dominus offers the following as a binary string conversion
example of how recursion can work.
use strict;
use warnings;
my $bstr = binary(37);
print "$bstr\n";
> "Morbus" == Morbus Iff <[EMAIL PROTECTED]> writes:
Morbus> The script was mindlessly simple, and I felt it would be a good HOWTO
Morbus> for the perl beginners crowd, if not to show some good code practices,
Morbus> but also to counteract the . .. .. . "controversial" HOWTO that had
Morbus>
>> while (@files) {
>
>Are you sure that's not:
>
> for (@files) {
Yup, "for" is right. An error in my memory recall.
--
Morbus Iff ( evil is my sour flavor )
Technical: http://www.oreillynet.com/pub/au/779
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
icq: 2927491 / aim: aka
On 4/1/2004 7:05 PM, Morbus Iff wrote:
# and here is that subroutine. it's nearly exactly
# the same as our previous code, only this time, we
# move into the directory that contains a file to
# be renamed. this is actually a quick hack because
# I knew this wouldn't be production-code: a more
On Thu, Apr 01, 2004 at 07:05:51PM -0500, Morbus Iff wrote:
> Earlier this morning, a friend of mine asked me for a script that would
> "given a list of files, replace underscores with spaces", to take this:
>
> Artist_Name-Track_Name.mp3
>
> and rename it to this:
>
> Artist Name-Track Nam
ersion, and whether that would be "hard
to do". While I wasn't around to help him out, the weak solution
was easy: just move the script into each new directory and run
it again. But, there are two other solutions to this new request:
the bad one, and the good one.
The bad one is t
While you're at it, write a parallel version of du.pl... Modern hard
drives do scatter gather, and reading lots (say 10 or so) of dirs'
contents' block sizes at a time would be interesting...
It would be cool if a parent kept 20 children pre-forked, and only told
10 children at a time to do their
Jesper Noehr wrote:
>
> On Mon, 29 Dec 2003 13:19:29 -0800, John W. Krahn <[EMAIL PROTECTED]> wrote:
> >
> > $ ls -l test.txt
> > -rw-r--r--1 john users 187 Jul 9 11:54 test.txt
> > $ perl -le'print +(lstat shift)[11]' test.txt
> > 4096
> > $ du -b test.txt
> > 4096test.txt
>
On Mon, 29 Dec 2003 13:19:29 -0800, John W. Krahn <[EMAIL PROTECTED]> wrote:
Jesper Noehr wrote:
Hey list.
Hello,
I'm having a problem reading the size of a directory with recursive
directories.
The problem is that du -s shows a different bytecount than my program
does.
$ man du
NAME
du
Jesper Noehr wrote:
>
> Hey list.
Hello,
> I'm having a problem reading the size of a directory with recursive
> directories.
> The problem is that du -s shows a different bytecount than my program does.
$ man du
NAME
du - estimate file space usage
SYNOPSIS
du [OPTION]... [FILE]
Hey list.
I'm having a problem reading the size of a directory with recursive
directories.
The problem is that du -s shows a different bytecount than my program does.
Here's my code:
#!/usr/gnu/bin/perl -w
use File::Find;
@ARGV = ('.') unless @ARGV;
my $sum = 0;
find sub { $sum += -s }, @ARGV;
On Tue, Nov 04, 2003 at 12:45:58AM +0100, Paul Johnson wrote:
> On Mon, Nov 03, 2003 at 11:16:02PM -, Rob Dixon wrote:
>> Steve Grazzini wrote:
>>> The problem is that "-d $path" will return true if $path is a symlink
>>> to a directory.
>>
>> Thanks Steve, but are you certain? I can't test it
On Mon, Nov 03, 2003 at 11:16:02PM -, Rob Dixon wrote:
> Steve Grazzini wrote:
> >
> > On Mon, Nov 03, 2003 at 09:48:55AM -, Rob Dixon wrote:
> > > Steve Grazzini wrote:
> > > > That's fine if you *want* to skip the dotfiles. But you *always*
> > > > skip "." and "..". More robust code wi
Steve Grazzini wrote:
>
> On Mon, Nov 03, 2003 at 09:48:55AM -, Rob Dixon wrote:
> > Steve Grazzini wrote:
> > > That's fine if you *want* to skip the dotfiles. But you *always*
> > > skip "." and "..". More robust code will also check for cycles, but
> > > since File::Find does all this alre
On Mon, Nov 03, 2003 at 09:48:55AM -, Rob Dixon wrote:
> Steve Grazzini wrote:
> > That's fine if you *want* to skip the dotfiles. But you *always*
> > skip "." and "..". More robust code will also check for cycles, but
> > since File::Find does all this already, it's usually better just to
>
On Monday, November 3, 2003, at 03:43 AM, Rob Dixon wrote:
Recursion can always be eliminated by hard-coding the stacking of
context variables that the compiler provides and using a loop
instead of a recursive call. In fact this is exactly what File::Find
itself does. But recursive code will
R. Joseph Newton wrote:
>
> Rob Dixon wrote:
>
> > Jeff Westman wrotenews:[EMAIL PROTECTED]
> > >
> > > I've never liked "recursion" but of course there are times where it is
> > > needed.
> > >
> > > I have a simpl
Steve Grazzini wrote:
>
> On Sun, Nov 02, 2003 at 05:32:35PM -0600, James Edward Gray II wrote:
> > On Sunday, November 2, 2003, at 06:19 AM, Rob Dixon wrote:
> > > sub printdir {
> > >
> > >my $dir = shift;
> > >
> > >opendir DIR, $dir or die $!;
> > >my @dirs = grep /[^.]/, readdir D
James Edward Gray II wrote:
>
> On Sunday, November 2, 2003, at 06:19 AM, Rob Dixon wrote:
>
> > Jeff Westman
> > wrotenews:[EMAIL PROTECTED]
> >> Hi,
> >>
> >> I've never liked "recursion" but of course there are times where it is
On Sun, Nov 02, 2003 at 05:32:35PM -0600, James Edward Gray II wrote:
> On Sunday, November 2, 2003, at 06:19 AM, Rob Dixon wrote:
> > sub printdir {
> >
> >my $dir = shift;
> >
> >opendir DIR, $dir or die $!;
> >my @dirs = grep /[^.]/, readdir DIR;
>
> I'm not sure this grep() is wha
On Sunday, November 2, 2003, at 06:19 AM, Rob Dixon wrote:
Jeff Westman
wrotenews:[EMAIL PROTECTED]
Hi,
I've never liked "recursion" but of course there are times where it is
needed.
I'm not sure I would say recursion is "needed", but it sure makes some
thi
On Sunday, November 2, 2003, at 06:19 AM, Rob Dixon wrote:
File::Find would do it for you, but the revursion is very
simple really:
use strict;
use warnings;
printdir('/usr');
sub printdir {
my $dir = shift;
opendir DIR, $dir or die $!;
my @dirs = grep /[^.]/, readdir DIR;
I
Rob Dixon wrote:
> Jeff Westman wrotenews:[EMAIL PROTECTED]
> > Hi,
> >
> > I've never liked "recursion" but of course there are times where it is
> > needed.
> >
> > I have a simple task that I am trying to do. Basically, I just want to
Jeff Westman wrotenews:[EMAIL PROTECTED]
> Hi,
>
> I've never liked "recursion" but of course there are times where it is
> needed.
>
> I have a simple task that I am trying to do. Basically, I just want to list
> out my directories on disk, and then chdir to
On Sat, 2003-11-01 at 20:20, Jeff Westman wrote:
> Hi,
>
> I've never liked "recursion" but of course there are times where it is
> needed.
>
> I have a simple task that I am trying to do. Basically, I just want to list
> out my directories on disk, and then
On Sat, Nov 01, 2003 at 05:20:39PM -0800, Jeff Westman wrote:
> I have a simple task that I am trying to do. Basically, I just want
> to list out my directories on disk, and then chdir to each one, print
> it out, and so on.
use File::Find;
find sub { print "$File::Find::name\n" if -d },
Hi,
I've never liked "recursion" but of course there are times where it is
needed.
I have a simple task that I am trying to do. Basically, I just want to list
out my directories on disk, and then chdir to each one, print it out, and so
on. Pretty basic, but I have a total men
I have this program that recurses through a directory structure building
Default.htm files. The idea here was to quickly generate a bunch of these
things to replace the default index listing you normally see. The part
that's giving me trouble is the navbar that should have a nested structure
lik
62 matches
Mail list logo