[31910] in Perl-Users-Digest
Perl-Users Digest, Issue: 3173 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 14 03:09:32 2010
Date: Thu, 14 Oct 2010 00:09:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 14 Oct 2010 Volume: 11 Number: 3173
Today's topics:
a test posting <ng@spim.woeishyang.com>
get value of variable number of arguments <massion@gmx.de>
Re: get value of variable number of arguments <ben@morrow.me.uk>
Re: get value of variable number of arguments <uri@StemSystems.com>
Re: get value of variable number of arguments <sherm.pendley@gmail.com>
Re: get value of variable number of arguments <massion@gmx.de>
Re: get value of variable number of arguments <uri@StemSystems.com>
Re: get value of variable number of arguments <mvdwege@mail.com>
hashing for absent but not present cases <ela@yantai.org>
Re: hashing for absent but not present cases <tadmc@seesig.invalid>
Re: hashing for absent but not present cases <ela@yantai.org>
Help with Hash <pradeep.bg@gmail.com>
Re: How to make XSUBs thread-safe? xsubpp switches? <nospam-abuse@ilyaz.org>
Re: How to make XSUBs thread-safe? xsubpp switches? <ben@morrow.me.uk>
Re: How to make XSUBs thread-safe? xsubpp switches? <nospam-abuse@ilyaz.org>
Re: Looping on "if" statement? <uri@StemSystems.com>
Re: Looping on "if" statement? <sherm.pendley@gmail.com>
Re: why does this happen? <miller@yoyo.ORG>
Re: why does this happen? <miller@yoyo.ORG>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 13 Oct 2010 23:09:59 GMT
From: Ng Spim <ng@spim.woeishyang.com>
Subject: a test posting
Message-Id: <i95e87$vk5$1@mawar.singnet.com.sg>
Pellentesque mollis imperdiet nibh, eu blandit nisi consequat et. Nulla
ullamcorper ullamcorper ante vel vehicula. Curabitur sit amet porta
est. Aliquam placerat lectus in mauris sagittis tempus. Cras vel ligula
eros. In vehicula auctor lacinia. Ut pretium ornare mauris at luctus.
Etiam sit amet scelerisque nunc. Phasellus ac urna vel sapien pretium
pharetra eu et dolor. Pellentesque blandit adipiscing diam egestas
cursus. Pellentesque in orci justo.
------------------------------
Date: Wed, 13 Oct 2010 22:15:12 -0700 (PDT)
From: Francois Massion <massion@gmx.de>
Subject: get value of variable number of arguments
Message-Id: <75b028c5-296e-49c2-8763-4babcc255ce3@28g2000yqm.googlegroups.com>
I have a script with the following syntax:
extract.pl [file-to-extract] [results file] [stopword-file(s)
= 1..n]
I would like to get the value of the stopword-file(s). There may be
one or more of such file.
The following code doesn't deliver the right values:
my $source_file = shift @ARGV;
my $target_file = $ARGV[0]; # Value is OK
# one or more than one stopword file --> result NOK
my @stopwords_files = ();
foreach my $stopword_file (@ARGV) {
push @stopwords_files, $stopword_file;
}
Any suggestions?
------------------------------
Date: Thu, 14 Oct 2010 06:25:49 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: get value of variable number of arguments
Message-Id: <trgio7-rh61.ln1@osiris.mauzo.dyndns.org>
Quoth Francois Massion <massion@gmx.de>:
> I have a script with the following syntax:
> extract.pl [file-to-extract] [results file] [stopword-file(s)
> = 1..n]
>
> I would like to get the value of the stopword-file(s). There may be
> one or more of such file.
>
> The following code doesn't deliver the right values:
>
> my $source_file = shift @ARGV;
^^^^^^^^^^^
> my $target_file = $ARGV[0]; # Value is OK
^^^^^^^^
These two lines are not the same. Why not?
> # one or more than one stopword file --> result NOK
> my @stopwords_files = ();
^^^^
This does exactly nothing, so don't put it in.
> foreach my $stopword_file (@ARGV) {
> push @stopwords_files, $stopword_file;
> }
>
> Any suggestions?
There are three basic approaches here:
# using shift
my $source_file = shift @ARGV;
my $target_file = shift @ARGV;
my @stopwords_files;
while (@ARGV) {
push @stopword_files, shift @ARGV;
}
# using individual assignments
my $source_file = $ARGV[0];
my $target_file = $ARGV[1];
my @stopword_files = @ARGV[2..$#ARGV];
# using one assignment
my ($source_file, $target_file, @stopword_files) = @ARGV;
I greatly prefer the last.
Ben
------------------------------
Date: Thu, 14 Oct 2010 01:33:45 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: get value of variable number of arguments
Message-Id: <87iq15mj7q.fsf@quad.sysarch.com>
>>>>> "FM" == Francois Massion <massion@gmx.de> writes:
FM> I have a script with the following syntax:
FM> extract.pl [file-to-extract] [results file] [stopword-file(s)
FM> = 1..n]
FM> I would like to get the value of the stopword-file(s). There may be
FM> one or more of such file.
FM> The following code doesn't deliver the right values:
FM> my $source_file = shift @ARGV;
that removed the arg
FM> my $target_file = $ARGV[0]; # Value is OK
that doesn't remove the arg.
FM> # one or more than one stopword file --> result NOK
FM> my @stopwords_files = ();
FM> foreach my $stopword_file (@ARGV) {
the first value will still be the target file
also use the same names in your code as you do to describe the command
line args. why call one results file and the other target file?
FM> push @stopwords_files, $stopword_file;
FM> }
you are coding way too much!
my( $source_file, $target_file, @stopwords_files ) = @ARGV ;
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Thu, 14 Oct 2010 01:34:56 -0400
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: get value of variable number of arguments
Message-Id: <m239s9nxq7.fsf@sherm.shermpendley.com>
Francois Massion <massion@gmx.de> writes:
> I have a script with the following syntax:
> extract.pl [file-to-extract] [results file] [stopword-file(s)
> = 1..n]
>
> I would like to get the value of the stopword-file(s). There may be
> one or more of such file.
>
> The following code doesn't deliver the right values:
>
> my $source_file = shift @ARGV;
> my $target_file = $ARGV[0]; # Value is OK
You're doing different things here. shift() removes the first value
from the array and returns it. Accessing the first value by using a
subscript [0] doesn't remove it from the array.
If you want @ARGV to have *only* your stopword files past this point,
you need to use shift() both times above:
my $source_file = shift @ARGV;
my $target_file = shift @ARGV;
But there's an easier way to write the whole thing. Keep reading. :-)
> # one or more than one stopword file --> result NOK
> my @stopwords_files = ();
> foreach my $stopword_file (@ARGV) {
> push @stopwords_files, $stopword_file;
> }
Seems like a lot of unnecessary work just to copy an array. Why not
just:
#!/usr/bin/perl
use strict;
use warnings;
my ($source_file, $target_file, @stopwords_files) = @ARGV;
print $source_file, "\n", $target_file, "\n",
join(",", @stopwords_files), "\n";
Output from the above:
Macintosh:~ sherm$ perl ./extract.pl in out foo bar baz
in
out
foo,bar,baz
sherm--
--
Sherm Pendley
<http://camelbones.sourceforge.net>
Cocoa Developer
------------------------------
Date: Wed, 13 Oct 2010 22:48:33 -0700 (PDT)
From: Francois Massion <massion@gmx.de>
Subject: Re: get value of variable number of arguments
Message-Id: <4317bf29-77a9-469d-b7c0-5852b7fe9114@n26g2000yqh.googlegroups.com>
On 14 Okt., 07:25, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth Francois Massion <mass...@gmx.de>:> I have a script with the follow=
ing syntax:
> > extract.pl =A0 =A0[file-to-extract] =A0 =A0[results file] =A0 =A0[stopw=
ord-file(s)
> > =3D 1..n]
>
> > I would like to get the value of the stopword-file(s). There may be
> > one or more of such file.
>
> > The following code doesn't deliver the right values:
>
> > my $source_file =3D shift @ARGV;
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ^^^^^^^^^^^> my $target_file =3D =
$ARGV[0]; # Value is OK
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ^^^^^^^^
> These two lines are not the same. Why not?
>
> > # one or more than one stopword file --> result NOK
> > my @stopwords_files =3D ();
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ^^^^
> This does exactly nothing, so don't put it in.
>
> > foreach my $stopword_file (@ARGV) {
> > =A0 =A0push @stopwords_files, $stopword_file;
> > }
>
> > Any suggestions?
>
> There are three basic approaches here:
>
> =A0 =A0 # using shift
>
> =A0 =A0 my $source_file =3D shift @ARGV;
> =A0 =A0 my $target_file =3D shift @ARGV;
> =A0 =A0 my @stopwords_files;
> =A0 =A0 while (@ARGV) {
> =A0 =A0 =A0 =A0 push @stopword_files, shift @ARGV;
> =A0 =A0 }
>
> =A0 =A0 # using individual assignments
>
> =A0 =A0 my $source_file =3D $ARGV[0];
> =A0 =A0 my $target_file =3D $ARGV[1];
> =A0 =A0 my @stopword_files =3D @ARGV[2..$#ARGV];
>
> =A0 =A0 # using one assignment
>
> =A0 =A0 my ($source_file, $target_file, @stopword_files) =3D @ARGV;
>
> I greatly prefer the last.
>
> Ben
Hi Ben,
apparently only the SHIFT approach works here. The other two
approaches create an array @stopword_files with all the file names,
not the names of the stop files only.
Thanks for your help.
------------------------------
Date: Thu, 14 Oct 2010 02:31:51 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: get value of variable number of arguments
Message-Id: <8739s9mgiw.fsf@quad.sysarch.com>
>>>>> "FM" == Francois Massion <massion@gmx.de> writes:
FM> On 14 Okt., 07:25, Ben Morrow <b...@morrow.me.uk> wrote:
>>
>> # using shift
>>
>> my $source_file = shift @ARGV;
>> my $target_file = shift @ARGV;
>> my @stopwords_files;
>> while (@ARGV) {
>> push @stopword_files, shift @ARGV;
>> }
>>
>> # using individual assignments
>>
>> my $source_file = $ARGV[0];
>> my $target_file = $ARGV[1];
>> my @stopword_files = @ARGV[2..$#ARGV];
>>
>> # using one assignment
>>
>> my ($source_file, $target_file, @stopword_files) = @ARGV;
>>
>> I greatly prefer the last.
FM> apparently only the SHIFT approach works here. The other two
FM> approaches create an array @stopword_files with all the file names,
FM> not the names of the stop files only.
your word isn't good enough. you need to show code and data and output
and prove ben's code didn't work. all three will work if you try them
correctly. saying it didn't work is a useless statement without
information on what you did and what results you see.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Thu, 14 Oct 2010 09:07:16 +0200
From: Mart van de Wege <mvdwege@mail.com>
Subject: Re: get value of variable number of arguments
Message-Id: <86d3rdw8uz.fsf@gareth.avalon.lan>
Francois Massion <massion@gmx.de> writes:
> I have a script with the following syntax:
> extract.pl [file-to-extract] [results file] [stopword-file(s)
> = 1..n]
>
> I would like to get the value of the stopword-file(s). There may be
> one or more of such file.
>
> The following code doesn't deliver the right values:
>
> my $source_file = shift @ARGV;
> my $target_file = $ARGV[0]; # Value is OK
> # one or more than one stopword file --> result NOK
> my @stopwords_files = ();
> foreach my $stopword_file (@ARGV) {
> push @stopwords_files, $stopword_file;
> }
>
> Any suggestions?
Use Getopt::Long
Warning, following code is untested:
----- START CODE -----
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
my $source_file;
my $target_file;
my @stopword_files;
my $result = GetOptions("source-file=s" => \$source_file,
"target-file=s" => \$target_file,
"stopword-files=s{,}" => \@stopword_files,
);
----- END CODE -----
After running your script with 'extract.pl --source-file <filename>
--target-file <filename> --stopword-files <one or more filenames>' your
stopword file names will be stored in the @stopword_files array.
for a working example, I have a script here that merges multiple PDFs
into one:
#!/usr/bin/perl
use Getopt::Long;
use PDF::API2;
my $target = "merged.pdf";
my @sources;
my $debug;
my $result = GetOptions("target=s" => \$target,
"source=s{,}" => \@sources,
"debug" => \$debug );
my $pdf = PDF::API2->new;
my $current_page = $pdf->openpage(-1);
for my $source (@sources) {
print "Merging file $source\n" if $debug;
my $src_pdf = PDF::API2->open($source);
my $src_pages = $src_pdf->pages;
for my $src_page (1..$src_pages) {
$pdf->importpage($src_pdf,$src_page,$current_page);
$current_page = $pdf->page(0);
}
}
$pdf->saveas($target);
Mart
--
"We will need a longer wall when the revolution comes."
--- AJS, quoting an uncertain source.
------------------------------
Date: Thu, 14 Oct 2010 10:44:13 -0700
From: "ela" <ela@yantai.org>
Subject: hashing for absent but not present cases
Message-Id: <i95qp9$cp1$1@ijustice.itsc.cuhk.edu.hk>
if i have a table like:
ID
2
19
117
67
8
and information file like:
1
USA
2
China
3
Japan
4
England
...
100000
Australia
then I can first put the information file into hash and then retrieve the
country information later by the hashed ID. This is the "present" case that
can be solved easily. How can the other way, that is, those IDs that are
absent, to retrieve the coresponding "absent" country information?
------------------------------
Date: Wed, 13 Oct 2010 22:21:45 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: hashing for absent but not present cases
Message-Id: <slrnibcu0g.7tf.tadmc@tadbox.sbcglobal.net>
ela <ela@yantai.org> wrote:
> if i have a table like:
>
> ID
> 2
> 19
> 117
> 67
> 8
>
> and information file like:
>
> 1
> USA
> 2
> China
> 3
> Japan
> 4
> England
> ...
> 100000
> Australia
>
> then I can first put the information file into hash and then retrieve the
> country information later by the hashed ID. This is the "present" case that
> can be solved easily. How can the other way, that is, those IDs that are
> absent, to retrieve the coresponding "absent" country information?
------------------------
#!/usr/bin/perl
use warnings;
use strict;
my @ids = qw/2 1 4/;
my %countries = qw(
1 USA
2 China
3 Japan
4 England
5 Australia
);
my %absent = map {$_ => 1} 1..keys %countries;
delete $absent{$_} for @ids;
print "missing countries:\n";
print "$_\n" for @countries{keys %absent};
------------------------
But %countries should probably be @countries...
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
Date: Thu, 14 Oct 2010 12:46:10 -0700
From: "ela" <ela@yantai.org>
Subject: Re: hashing for absent but not present cases
Message-Id: <i961tu$ff7$1@ijustice.itsc.cuhk.edu.hk>
While your example has the key and value pair on the same row, mine is
different and may span several rows, e.g.
>1
USA, MA, Boston
>2
China,
Beijing,
Chaoyang
>3
...
so I have to parse the information file first. However, I don't know how
my %absent = map {$_ => 1} 1..keys %countries;
works.
I'd appreciate if you would explain a little for the abc below because
perldoc map examples do not cover the combined concepts below:
a) map
b) {$_ => 1}
c) 1..keys
After knowing what they do, then I can produce my own scripts for different
file formats. Thanks again.
------------------------------
Date: Wed, 13 Oct 2010 23:41:55 -0700 (PDT)
From: Deepu <pradeep.bg@gmail.com>
Subject: Help with Hash
Message-Id: <c9b5abfd-180a-4125-9e3e-5a593c1aa1bc@30g2000yqm.googlegroups.com>
Hi All,
If i have a files located in different directories with contents like:
File_A:
ABCD : 1
DECF : 0
DREF : 1
DSER : 0
QWSA : 0
File_B:
ABCD : 1
DECF : 1
DREF : 0
DSER : 0
QWSA : 0
File_C:
ABCD : 1
DECF : 0
DREF : 1
DSER : 0
QWSA : 1
How can i generate a output file:
File_Output:
ABCD : 1
DECF : 1
DREF : 1
DSER : 0
QWSA : 1
In addition to this FileOutput should contain:
Num of Files: 3
Num of Elements: 5
Num of Hits : 4 (Elements with 1 after comparing all 3 files)
I have the code like below but would like to know how i get the Num of
Hits after comparing all 3 files.
use strict;
use Getopt::Long;
use IO::Handle;
use vars qw($opt_help $opt_dir $opt_debug);
&GetOptions("help|h" => \$opt_help,
"dir|d=s" => \$opt_dir,
"debug" => \$opt_debug
);
my $Dir = "$opt_dir";
my $num_of_files = 0;
my $num_of_elements = 0;
my $num_of_hits = 0;
my %num_of_elements = ();
opendir (DIR, $Dir) || die "Can't open $Dir - $!\n";
foreach my $tempdir (readdir DIR)
{
if (-d "$Dir/$tempdir")
{
$num_of_files = $num_of_files + 1;
opendir (SUB, "$Dir"."/$tempdir" ) || die "Can't open
$tempdir - $!\n";
my $Name = $tempdir;
my $elementFile = "$Dir/$tempdir/"."File_$Name";
open (FH, "$elementFile") || die "Can't open $elementFile -$!
\n";
while (<FH>)
{
if (/(\S+)\s+\:\s+(\d+)/)
{
$num_of_elements{$1}++;
}
}
close (FH);
closedir (SUB);
}
}
closedir (DIR);
foreach my $element (keys %num_of_elements)
{
$num_of_elements = $num_of_elements + 1;
}
print ("\n________________________________________\n");
print ("Num of Files: $num_of_files \n");
print ("Num of Elements: $num_of_elements \n");
print ("Num of Hits: $num_of_hits \n");
print ("________________________________________\n");
------------------------------
Date: Wed, 13 Oct 2010 21:46:58 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: How to make XSUBs thread-safe? xsubpp switches?
Message-Id: <slrnibca6i.no3.nospam-abuse@powdermilk.math.berkeley.edu>
On 2010-10-13, Ben Morrow <ben@morrow.me.uk> wrote:
>> > SCOPE: ENABLE
>> > PREINIT:
>> > dMY_CXT;
>> > INIT:
>> > SvLOCK(MY_CXT.locksv);
> See "Safely Storing Static Data in XS" in perlxs. The unlocking is
> handled by the save stack: SvLOCK sets a lock which is only valid until
> the end of the current scope. That's why SCOPE:ENABLE is needed.
Thanks. I never needed that part of xsubpp-ing before.
[ AFAICS, one needs six new declarations:
GLOBAL_PREINIT_ADD:
dMY_CXT;
GLOBAL_INIT_ADD:
SvLOCK(MY_CXT.locksv);
and corresponding _REMOVE and _REMOVE_ALL flavors. Too many...
Nowadays, I would prefer keeping existing names, and adding
modifiers; something like
PREINIT: GLOBAL ADD
dMY_CXT;
What do you people think about the syntax looks like? I do not
know whether PREINIT++ and PREINIT-- would look too bold... ;-]
Yours,
Ilya
------------------------------
Date: Wed, 13 Oct 2010 23:41:21 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: How to make XSUBs thread-safe? xsubpp switches?
Message-Id: <h5pho7-2501.ln1@osiris.mauzo.dyndns.org>
Quoth Ilya Zakharevich <nospam-abuse@ilyaz.org>:
>
> [ AFAICS, one needs six new declarations:
>
> GLOBAL_PREINIT_ADD:
> dMY_CXT;
>
> GLOBAL_INIT_ADD:
> SvLOCK(MY_CXT.locksv);
Mmm, I like this idea.
> and corresponding _REMOVE and _REMOVE_ALL flavors. Too many...
What does REMOVE_ALL do for you? Change the default for XSUBS declared
after this? I'm not sure how easy it would be to use this, in general;
how would you reliably identify which bits to remove? Re-specify them in
full? What if you start with
GLOBAL_INIT_ADD:
FOO();
BAR();
BAZ();
and you later want to remove just the BAR?
> Nowadays, I would prefer keeping existing names, and adding
> modifiers; something like
>
> PREINIT: GLOBAL ADD
> dMY_CXT;
>
> What do you people think about the syntax looks like? I do not
> know whether PREINIT++ and PREINIT-- would look too bold... ;-]
How about
GLOBAL:
SCOPE: ENABLE
PREINIT:
dMY_CXT;
INIT:
SvLOCK(MY_CXT.locksv);
void
needs_lock ()
/* this gets scoping, dMY_CXT and SvLOCK */
GLOBAL:
SCOPE: DISABLE
INIT:
/* nothing */
void
no_lock ()
/* this gets just dMY_CXT, since the new global INIT section is
* empty but the global PREINIT section wasn't replaced */
Possibly better would be PREPEND: and APPEND: instead of simply GLOBAL:,
in case it matters whether the section is added before or after the
XSUB's own section.
Ben
------------------------------
Date: Thu, 14 Oct 2010 02:43:23 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: How to make XSUBs thread-safe? xsubpp switches?
Message-Id: <slrnibcria.oeo.nospam-abuse@powdermilk.math.berkeley.edu>
On 2010-10-13, Ben Morrow <ben@morrow.me.uk> wrote:
>> GLOBAL_INIT_ADD:
>> SvLOCK(MY_CXT.locksv);
>
> Mmm, I like this idea.
>
>> and corresponding _REMOVE and _REMOVE_ALL flavors. Too many...
>
> What does REMOVE_ALL do for you? Change the default for XSUBS declared
> after this? I'm not sure how easy it would be to use this, in general;
> how would you reliably identify which bits to remove? Re-specify them in
> full? What if you start with
>
> GLOBAL_INIT_ADD:
> FOO();
> BAR();
> BAZ();
>
> and you later want to remove just the BAR?
I see that we think similarly. ;-) For a few hours now I think in
terms of "keys". A key is a Perl symbol. To a key one associates a
sequence of "actions" to perform. This may look almost exactly as a
defintion of an XSUB:
KEY=lock1
PREINIT: dMY_CTX;
INIT: SvLOCK(MY_CXT.locksv);
Such a definition does not change how following XSUBs is processed.
However, at any moment one can change the list of "active keys":
KEYS: lock1 croak_on_false
KEYS: -lock1
KEYS: +lock1
(either in global scope, or inside an XSUB.
> Possibly better would be PREPEND: and APPEND: instead of simply GLOBAL:,
> in case it matters whether the section is added before or after the
> XSUB's own section.
Hmm, this may be solved by insertion of
KEY=XSUB
in the (ordered) list of keys. (This must have no "actions"
specified, but would separate "prepend" actions from "append" ones.)
Thanks,
Ilya
------------------------------
Date: Wed, 13 Oct 2010 16:10:55 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Looping on "if" statement?
Message-Id: <878w21voog.fsf@quad.sysarch.com>
>>>>> "c" == ccc31807 <cartercc@gmail.com> writes:
c> On Oct 13, 2:45 pm, "Uri Guttman" <u...@StemSystems.com> wrote:
>> recursing is a sub concept and has nothing to do with if's. and you can
>> traverse a tree without recursion (either with looping or dispatching to
>> dedicated subs for each level).
c> Recursion deals with the concept of calling the same function with a
c> subset of the data, and has everything to do with conditionals. If you
c> can't test for the base case, how could you stop the recursive call?
please don't lecture me on recursion. the OP's problem had nothing to do
with recursion. and recursion can always be done without sub calls and
in a plain loop. sometimes it is cleaner to properly recurse (depending
on the problem and language). other times it is much better to loop or
fake recursion with a loop (which can ALWAYS be done - recursion is a
neat idea but never required)..
c> My point was that iterative controls, such as while, until, for, and
c> so on, involve looping. Conditional controls, such as if, unless,
c> case, and so on, involve recursion.
that is total bull. what does a single if statement with nothing else
have to do with recursion? boolean tests are used everywhere and are not
related to the thing they control. while is just an if with a goto at
the end/beginning. is that recursing? recursion only involves calling a
sub by itself (or deeper in the call tree). how it resolves to exit is
not an issue. and you could stop recursion with a while as well if you
wanted. it is just a boolean test.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Wed, 13 Oct 2010 17:20:09 -0400
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: Looping on "if" statement?
Message-Id: <m2fww97pti.fsf@sherm.shermpendley.com>
ccc31807 <cartercc@gmail.com> writes:
> On Oct 13, 2:45Â pm, "Uri Guttman" <u...@StemSystems.com> wrote:
>> recursing is a sub concept and has nothing to do with if's. and you can
>> traverse a tree without recursion (either with looping or dispatching to
>> dedicated subs for each level).
>
> Recursion deals with the concept of calling the same function with a
> subset of the data
Correct so far, but you should have stopped there. :-)
>, and has everything to do with conditionals. If you
> can't test for the base case, how could you stop the recursive call?
That's an implementation detail that has nothing to do with the concept
of recursion.
> Conditional controls, such as if, unless,
> case, and so on, involve recursion.
Nonsense. Why do you keep insisting on making up new meanings for
terms that have been in use since before you were born?
sherm--
--
Sherm Pendley
<http://camelbones.sourceforge.net>
Cocoa Developer
------------------------------
Date: Wed, 13 Oct 2010 22:16:40 +0000 (UTC)
From: J G Miller <miller@yoyo.ORG>
Subject: Re: why does this happen?
Message-Id: <i95b48$n5i$3@news.eternal-september.org>
On Sat, 02 Oct 2010 10:13:50 +0200, Peter J. Holzer wrote:
>
> Actually, if you use an editor to open file "A", possibly edit it, and
> then save it as "B", I don't think it is entirely unreasonable to assume
> that B will have the same permissions as A.
A big assumption there.
What if A is owned by somebody else?
The editor should respect umask -- and that should
be the end of the matter.
------------------------------
Date: Wed, 13 Oct 2010 22:17:48 +0000 (UTC)
From: J G Miller <miller@yoyo.ORG>
Subject: Re: why does this happen?
Message-Id: <i95b6c$n5i$4@news.eternal-september.org>
On Fri, 01 Oct 2010 08:06:42 +0200, Mike Rechtman wrote:
> (Personally -- I use TPU on VMS)
TPU mode in Emacs works just great.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 3173
***************************************