[9594] in Perl-Users-Digest
Perl-Users Digest, Issue: 3188 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 17 14:19:07 1998
Date: Fri, 17 Jul 98 11:04:59 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 17 Jul 1998 Volume: 8 Number: 3188
Today's topics:
Re: newbie date format (Bob Trieger)
Re: newbie date format (Matt Knecht)
Re: newbie date format (Larry Rosler)
Re: OLE under Win32 (John M. Dlugosz)
Re: open (IN, "foo.txt") works, open (IN, "$foo") does <jdw@alder.dev.tivoli.com>
Re: passing control of forms in script.... <dunna001@bama.ua.edu>
Re: Perl Beautifier Home Page <jdporter@min.net>
Re: Perl Beautifier Home Page <adward@nortel.com>
Re: Perl Beautifier Home Page (Andrew M. Langmead)
Perl5 on Netware Web Server: real or half-broke port? (Kerry Lester)
Re: Please Help Me! (Matt's Script BB Problem) <jdporter@min.net>
Re: Please Help Me! (Matt's Script BB Problem) (Chris Nandor)
Re: Please Help Me! (Matt's Script BB Problem) (Steve Linberg)
Print LoL-tree routine (attached) <swoboda@uvic.ca>
Re: print<<"xxx" vs. print <jdporter@min.net>
Re: real quick and easy - replace.... (Andrew M. Langmead)
Re: regexp help? <agy@macgreg.com>
Re: Reliability of random numbers (Josh Kortbein)
Re: Remote login question (Eric Harley)
Re: Return value of eval() <livshits@netscape.com>
Strangness in for loop ?! <snowbird@pcisys.net>
Re: Strangness in for loop ?! (Larry Rosler)
Thanks for the help onthe if then branch (lloyd)
Re: unwanted warning (Craig Berry)
Win32::Registry QueryValue fails <markstang@ncgroup.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 17 Jul 1998 16:28:09 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: newbie date format
Message-Id: <6onu79$vho$1@strato.ultra.net>
Stephan Lagerholm <stephan@spartacus.unilog.se> wrote:
-> What happens after 2000 ?
2001?
-> I would use:
-> #!/usr/bin/perl -w
->
-> use strict;
-> my($date);
-> open(DATE,"/usr/bin/date +%Y-%m-%d |") || die"can't open:$!";
-> $date=<DATE>;
-> chomp($date);
-> print"Today is: $date\n";
That would work wonders on a non-*nix machine.
Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-400-1972
Ext: 1949 and let the jerk that answers know
that his toll free number was sent as spam. "
------------------------------
Date: Fri, 17 Jul 1998 16:59:28 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: newbie date format
Message-Id: <QpLr1.144482$on1.7780547@news2.voicenet.com>
Larry Rosler <lr@hpl.hp.com> wrote:
>In article <mqqr1.144374$on1.7145255@news2.voicenet.com> on Thu, 16 Jul
> $formatted = (length(++$date[4]) < 2 && '0') . $date[4] . '/' .
>
>but just as misguided, because you get to do it again for the day, hour,
>minute and second. Use [s]printf '%.2d' ;
Using sprintf seems like overkill when all I want is a quick and dirty
manipulation of text.
Ideally I'd bury something like the above in a #define, but I haven't
got the heart to litter my Perl code with pre-processor statements...
yet :)
--
Matt Knecht - <hex@voicenet.com>
"496620796F752063616E207265616420746869732C20796F7520686176652066
617220746F6F206D7563682074696D65206F6E20796F75722068616E6473210F"
------------------------------
Date: Fri, 17 Jul 1998 10:21:17 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: newbie date format
Message-Id: <MPG.101927ea560ba26d98971f@nntp.hpl.hp.com>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <QpLr1.144482$on1.7780547@news2.voicenet.com> on Fri, 17 Jul
1998 16:59:28 GMT, Matt Knecht <hex@voicenet.com> says...
> Larry Rosler <lr@hpl.hp.com> wrote:
> >In article <mqqr1.144374$on1.7145255@news2.voicenet.com> on Thu, 16 Jul
> > $formatted = (length(++$date[4]) < 2 && '0') . $date[4] . '/' .
> >
> >but just as misguided, because you get to do it again for the day, hour,
> >minute and second. Use [s]printf '%.2d' ;
>
> Using sprintf seems like overkill when all I want is a quick and dirty
> manipulation of text.
Odd that you should prefer quick and dirty to quick and clean.
#!/usr/local/bin/perl -w
use Benchmark;
$x = '1';
timethese(1 << (shift || 0), {
Clean => sub { $_ = sprintf '%.2d', $x },
Dirty => sub { $_ = (length($x) < 2 && '0') . $x },
});
__END__
Benchmark: timing 65536 iterations of Clean, Dirty...
Clean: 2 secs ( 1.68 usr 0.01 sys = 1.69 cpu)
Dirty: 6 secs ( 1.71 usr 0.02 sys = 1.73 cpu)
> Ideally I'd bury something like the above in a #define, but I haven't
> got the heart to litter my Perl code with pre-processor statements...
> yet :)
Gag me!
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 17 Jul 1998 16:52:44 GMT
From: john@dlugosz.com (John M. Dlugosz)
Subject: Re: OLE under Win32
Message-Id: <83B07E838ACBD04F.F8237CA684846DCD.99C9CB2D7F17CFE6@library-proxy.airnews.net>
Thanks for your tips. I've switched to "standard" Perl with the
Win32::OLE addin, and I can see that it's improved from ActiveWare's.
On Thu, 16 Jul 1998 09:24:38 +0200, jan.dubois@ibm.net (Jan Dubois)
wrote:
>Standard Perl with libwin32 does support Win32::OLE, which is a superset
>of the ActiveState OLE module. There is a binary distribution of it on
>CPAN in the authors/GSAR directory.
------------------------------
Date: 17 Jul 1998 09:43:10 -0500
From: Jim Woodgate <jdw@alder.dev.tivoli.com>
Subject: Re: open (IN, "foo.txt") works, open (IN, "$foo") does not???
Message-Id: <ob67gw4jy9.fsf@alder.dev.tivoli.com>
Juergen.Puenter@materna.de (J|rgen P|nter) writes:
> - $file2 = "complete_path_to."; #no \n, \t, whitespace... in here
> $file3 = "file.001"; #no \n, \t, whitespace... in here
> $file4 = #choose your method to put together $file2 and $file3#
it might be helpful to see what you used to generate $file4.
you might want to try out some initial testing...
$file2 = "/tmp"; $file3 = "foo.txt"; $file4 = "$file2/$file3";
-d $file2 or die "Directory $file2 does not exist, stopped";
-f $file4 or die "File $file4 does not exist, stopped";
open (FHIN, $file4) || die "Could not open '$file4': $!, stopped";
close FHIN;
also, since we're talking about path names, perl on NT and perl for
Unix could be different, ie $file4 = "$file2\$file3"; probably won't
work so great, even on NT
> open (FHIN, "$file4") || die "...";
> $foo = <FHIN>;
>
> This fails _each and every time_, no matter how I try to construct
> $file4. It always dies at the 'open' with 'Can't open '$file4'
> for read. No such file or directory'
--
Jim Woodgate
Tivoli Systems
E-Mail: jdw@tivoli.com
------------------------------
Date: Fri, 17 Jul 1998 11:38:35 -0500
From: MrNobody <dunna001@bama.ua.edu>
Subject: Re: passing control of forms in script....
Message-Id: <Pine.GSO.3.96.980717112111.18930A-100000@bama.ua.edu>
On Sun, 12 Jul 1998, Sue & Mike wrote:
> I am writing a script to control a few (about 5) order forms. I
> would like to be able to place buttons on each form to allow the user
> to jump to anyone of the pages they want, rathe rthan following a set
> order.
> My question is how do I control this in the script? I have tried
> putting multiple submit buttons in the html and giving each a
> different value. When I test this, I do not gete any value for the
> field $FORM{'submit'} so I am not able to trap the button that was
> clicked......
> any help is greatly appreciated.
> Thanks
> Mike K.
As near as I can tell, this is not a perl problem, this is an html form
problem. Perhaps you should read a nice book on html, or check out them
mans, or post this question to a newsgroup that handles such nonsense.
In an effort to *save* my flameing post from being totaly useless, I will
ask a question, that I "believe" is on topic. If not, I guess I'll burn...
I am very, very interested in connectionist theory, and more specificaly,
nural networking and genetic algorithms used in conjunction. I am
currently working with feedforward nets of arbitrary firing functions (I
want to replace said functions reguarly) and backpropagation learning
algoriths. What I am looking for is a good FAQ or MAN or HowTo or
someone who has tried it for doing *large* genetic algoriths and/or nural
networks in perl. I will be working on this project for some time, and
unless consensus believes this is off topic, will probably post
optimization questions and the sort. Now, I know that perl is not the
fastest for some of the memory operations that I will need performing, but
It develops fast, and with embeded C and code translators, It should work
nicely.
again, thats: need nural networking in perl "manual"
need genetic algorithms in perl "manual"
Co-conspirators welcome.
-MrNobody
I dont exist, so
stop looking at me.
perl -e 'print pack("C*",10,rs(231266),&v,32,rs(17528),rs(235297),&v,32,
rs(195292),&v,32,rs(19496),rs(27979),10);sub v{rand(26)+97};
sub rs{srand($_[0]);(&v,&v,&v);}'
------------------------------
Date: Fri, 17 Jul 1998 15:55:19 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Perl Beautifier Home Page
Message-Id: <35AF757A.1B85@min.net>
Russ Allbery wrote:
>
> (Studly caps. Ick.)
Oh, man, don't get into that. Claiming that
BuildImpersonateExplicitAccessWithName // Thank you, M$
ought to be
build_impersonate_explicit_access_with_name
just gives 'em more ammo.
--
John Porter
sub Another::Just {
shift;local$\=",\n";local$,=' ';
print reverse @_,(caller(0))[3]=~/(.*)::(.*)/;
}
sub Hacker::Perl{(caller(0))[3]=~/(.*)::(.*)/}
Just Another Perl Hacker;
------------------------------
Date: Fri, 17 Jul 1998 09:59:15 -0500
From: "Andrew Ward" <adward@nortel.com>
Subject: Re: Perl Beautifier Home Page
Message-Id: <6onoub$s7p@nrtphc11.bnr.ca>
Maybe I'm evil for doing this, but it turned
split(/;/);
into
($_, $null) = split(/;
/);
which is noticeably wrong. I also tried
split(/\;/);
which didn't help.
Otherwise, though, it doesn't look like it did any other strange things.
Looks good!
----------------------------
Andrew Ward
Northern Telecom
adward@nortel.com
------------------------------
Date: Fri, 17 Jul 1998 17:13:10 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Perl Beautifier Home Page
Message-Id: <Ew915y.BDx@world.std.com>
Tim Maher <tim.maher@halcyon.com> writes:
>1) it's got a slight bias against the "backwards" constructs in the
first place
Its a shame that the beautifier has a bias against the backwards
constructs, because efficient perl code has a bias against entering
and exiting unnecessary blocks.
--
Andrew Langmead
------------------------------
Date: Fri, 17 Jul 1998 16:01:00 GMT
From: klester@whitlow-law.com (Kerry Lester)
Subject: Perl5 on Netware Web Server: real or half-broke port? Does anyone know/is Novell telling?
Message-Id: <35af7423.7187099@news.vci.net>
I have Novell WEB Server 3.1, installed it for the sole reason
that it includes a Perl5.NLM. Naturally, running a Perl script thru
CGI works OK, but what I really want is to cron job some perl scripts,
and so far haven't been able to find a means of executing a Perl
script other than thru a web page link - it's the damndest thing...
would someone really do that? It doesn't make sense. Is anyone in
the know about this port of Perl?
Likewise, there are a couple of obscure references among Novell
Knowledge Base docs to "ability to specify additional library paths",
i.e. other than YourServer/volume:inw_web/shared/Lcgi/Perl5 (home of
Perl5.NLM). So far that's all I've found that even hint that maybe
this "Perl5.NLM" can use modules, hence: (1) Novell calls it Perl5, so
can it use modules? (2) The same Carp.pm, net.pm, Socket.pm, etc
module files that works on Wn95, Linux, etc.? (3) So where do you have
to put these or how do you specify add'l lib paths? Huh?
------------------------------
Date: Fri, 17 Jul 1998 16:01:52 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Please Help Me! (Matt's Script BB Problem)
Message-Id: <35AF7707.4EB2@min.net>
I R A Aggie wrote:
>
> In article <35AE2B09.1C72@min.net>, jdporter@min.net wrote:
>
> + 1. Contact Matt directly. He wrote the crap; the onus is on him.
>
> He's stated, in the documentation, and in several other forums that
> he may or may not correct bugs in his script archive. Reading between
> the lines: its free software, and if it works for you, great, if not,
> then dump into the trash.
Sure. I'm just saying, if someone has a problem with MSA crap, he
should complain to Matt, and to no one else.
--
John Porter
sub Another::Just {
shift;local$\=",\n";local$,=' ';
print reverse @_,(caller(0))[3]=~/(.*)::(.*)/;
}
sub Hacker::Perl{(caller(0))[3]=~/(.*)::(.*)/}
Just Another Perl Hacker;
------------------------------
Date: Fri, 17 Jul 1998 16:36:30 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Please Help Me! (Matt's Script BB Problem)
Message-Id: <pudge-1707981236000001@dynamic434.ply.adelphia.net>
In article <35AF7707.4EB2@min.net>, jdporter@min.net wrote:
# I R A Aggie wrote:
# >
# > In article <35AE2B09.1C72@min.net>, jdporter@min.net wrote:
# >
# > + 1. Contact Matt directly. He wrote the crap; the onus is on him.
# >
# > He's stated, in the documentation, and in several other forums that
# > he may or may not correct bugs in his script archive. Reading between
# > the lines: its free software, and if it works for you, great, if not,
# > then dump into the trash.
#
# Sure. I'm just saying, if someone has a problem with MSA crap, he
# should complain to Matt, and to no one else.
But I think more accurately, one should say if it works for you, then you
have not used it for very long, so just save yourself the trouble and dump
it into the trash.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Fri, 17 Jul 1998 13:21:51 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Please Help Me! (Matt's Script BB Problem)
Message-Id: <linberg-1707981321510001@projdirc.literacy.upenn.edu>
In article <pudge-1707981236000001@dynamic434.ply.adelphia.net>,
pudge@pobox.com (Chris Nandor) wrote:
> But I think more accurately, one should say if it works for you, then you
> have not used it for very long, so just save yourself the trouble and dump
> it into the trash.
:)
I thought I read somewhere that he was going to update wwwboard to version
3. Who know, maybe he'll fix things? Someone will have to eventually.
Who will get fed up first?
_____________________________________________________________________
Steve Linberg National Center on Adult Literacy
Systems Programmer &c. University of Pennsylvania
linberg@literacy.upenn.edu http://www.literacyonline.org
------------------------------
Date: Fri, 17 Jul 1998 09:39:17 -0700
From: Paul <swoboda@uvic.ca>
Subject: Print LoL-tree routine (attached)
Message-Id: <35AF7E35.2D6A3079@uvic.ca>
This is a multi-part message in MIME format.
--------------E63EC5F334085C5BE9523E02
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi there, I recently had to code up a routine (which
has probably already been written a thousand times
and everyone already has) to print trees made from
lists of lists, *with scalar leaves*. Attached is a
routine that does the printing, with branches drawn
out and the space between branches filled with
periods, so it is easy to count the indentation-level
of a deep node... (I needed it for parse trees, and the
output had to be exactly as coded in this routine.)
The tree has to be passed in as a reference to an LoL.
PS
.
--------------E63EC5F334085C5BE9523E02
Content-Type: text/plain; charset=us-ascii; name="print_lol.ph"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="print_lol.ph"
sub print_lol_tree
# Prints a tree (built from lists of lists), indenting each new level by two
# and printing branches. Space between branches is filled in with periods, so
# that indentation levels can be seen clearly.
#
# Argument: The LoL-tree: must be passed in as a reference to a list!
{
my($tree_ref) = @_;
if (ref($tree_ref) ne 'ARRAY') {
print "ERROR: non array-ref argument passed to print_lol_tree()\n";
return;
}
if ($#{$tree_ref} > 0) {
print_lol_tree_helper('+-', $tree_ref, 0);
} else {
print_lol_tree_helper('+-', $tree_ref, 1);
}
}
sub print_lol_tree_helper
{
my($indent, $tree, $last_element_flag_list) = @_;
my($this_node, $first_element_drawn, $temp_indent, $node_count,
$temp_flag_list, $this_flag);
if (length($indent) == 0) {
$indent = '+-';
}
$first_element_drawn = 0;
$node_count = -1;
foreach $this_node (@{$tree}) {
$node_count++;
if ($first_element_drawn) {
$temp_flag_list = $last_element_flag_list;
$indent = '';
while(length($temp_flag_list) > 0) {
$this_flag = chop($temp_flag_list);
if ($this_flag eq '1') {
$indent = '. ' . $indent;
} else {
$indent = '| ' . $indent;
}
}
}
if (ref($this_node) eq 'ARRAY') {
if ($#{$this_node} >= 0) {
# This node is a non-empty subtree:
if ($node_count == $#{$tree}) {
print_lol_tree_helper($indent . '+-', $this_node,
$last_element_flag_list . 1);
} else {
print_lol_tree_helper($indent . '+-', $this_node,
$last_element_flag_list . 0);
}
} else {
# This node is a reference to an empty list:
print $indent . '+-' . "\n";
}
} else {
# A leaf! Print the contents in quotes:
print "$indent\"$this_node\"\n";
}
$first_element_drawn = 1;
}
}
1;
--------------E63EC5F334085C5BE9523E02--
------------------------------
Date: Fri, 17 Jul 1998 16:17:59 GMT
From: John Porter <jdporter@min.net>
Subject: Re: print<<"xxx" vs. print
Message-Id: <35AF7ACE.548D@min.net>
fred@no.spam.leeds.ac.uk wrote:
>
> Yes. I have never really understood why the last newline (which must be
> there, mustn't it, because the need for the end delimiter to start on
> a newline) is considered to be part of the document.
>
> Is there any possibility of a Perl changing its interpretation of here
> documents to ignore the last newline? Or can I do an explicit chomp
> somewhere?
Why not?
chomp( $s = <<EOF );
slap yer mammy down
slap yer mammy down again
EOF
--
John Porter
sub Another::Just {
shift;local$\=",\n";local$,=' ';
print reverse @_,(caller(0))[3]=~/(.*)::(.*)/;
}
sub Hacker::Perl{(caller(0))[3]=~/(.*)::(.*)/}
Just Another Perl Hacker;
------------------------------
Date: Fri, 17 Jul 1998 17:18:20 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: real quick and easy - replace....
Message-Id: <Ew91EK.F6y@world.std.com>
cberry@cinenet.net (Craig Berry) writes:
>merzky@physik.hu-berlin.de wrote:
>: $string =~ tr/[a-z]/[A-Z]/g; # replace set of chars by diff. set (man tr)
>Replacing [ by [ and ] by ] seems a bit like a make-work program for the
>interpreter.
Its probably not all that much work, since tr/// sets up a 256 element
table for every character. Since it is replacing every character with
the one in the table anyway, it doesn't matter whether its the one you
specified or its the one it defaulted to.
The square brackets are unnecessary, but not terribly inefficient.
--
Andrew Langmead
------------------------------
Date: Fri, 17 Jul 1998 12:02:50 -0400
From: "Adam Graham-Yooll" <agy@macgreg.com>
Subject: Re: regexp help?
Message-Id: <6onsif$4df$1@client3.news.psi.net>
There is a pretty good explanation here.
ftp://ftp.plig.org/pub/CPAN/doc/FAQs/FAQ/PerlFAQ.html#How_can_I_split_a_char
acter_de
Adam.
------------------------------
Date: 17 Jul 1998 17:25:41 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: Reliability of random numbers
Message-Id: <6oo1el$qbj$3@news.iastate.edu>
David Hamilton (hamilton@melbpc.org.au) wrote:
: Can someone who has been working with Perl for a while tell me whether
: the following code is "trustworthy" for giving out a random number, or
: is it prone to one number or another:
: srand(time ^ $$);
: $a=int(rand(15))+1;
http://www.perl.com/CPAN-local/doc/FMTEYEWTK/random
--
__________________________________________
She had heard all about excluded middles;
they were bad shit, to be avoided.
- Thomas Pynchon
------------------------------
Date: Fri, 17 Jul 1998 10:35:48 -0700
From: eharley@pacbell.net (Eric Harley)
Subject: Re: Remote login question
Message-Id: <eharley-1707981035480001@ppp-207-214-149-213.snrf01.pacbell.net>
> Is there a way to login on a remote machine thru perl
> apart from telnet and rsh?
Is there a way to login on a remote machine thru the shell apart from
telnet and rsh?
--
Eric Harley
Freelance Programmer
You need it done, I'm your man.
eharley@pacbell.net
http://burn.victim.com/~eharley
------------------------------
Date: Fri, 17 Jul 1998 10:45:45 -0700
From: Vladimir Livshits <livshits@netscape.com>
To: Steve Linberg <linberg@literacy.upenn.edu>
Subject: Re: Return value of eval()
Message-Id: <35AF8DC9.5E31254E@netscape.com>
Hi Steve. So this is what I am trying to do:
I am trying to create a method that would allow calling arbitrary pieces of code
(even rm *)
from JavaScript and I want to grab the return value of that. The return value can
be anything -
a scalar, array, whatever. So if I assign it to a scalar, Perl will do the
conversion, which is not
what I need. So far I've been passing sprintf("*js = \\eval(%s); return *js",
their_string) to eval
and dealing with the tipeglob this returns, but this is pretty ugly and probably
unsafe. Maybe
there's a better way to do this with references?..
Thanks,
- Vladimir
Steve Linberg wrote:
> In article <6olamh$vqj$1@nnrp1.dejanews.com>, livshits@netscape.com wrote:
>
> > I have an eval statement that can have anything in it (or, for that matter,
> > an anonymous procedure). I don't know what code will be in it
>
> Yikes. This sounds dangerous. Are you getting the code from a trusted
> source before you go ahead and execute it? What if it contains "`rm
> -rf`"?
>
> If security isn't a problem, then ignore that.
>
> > and I'd like
> > some way to check the return value or the value of the last statement
> > evaluated. So I try to create a reference to the result of the execution like
> > this:
> >
> > $_ = \eval('return %ENV'); print
> > and this outputs SCALAR... However,
> > $_ = \%ENV; print
> > works fine and outputs HASH as expected.
>
> Maybe I don't understand, but is there a reason you don't just take the
> value returned by eval? Why the reference? Why not just
>
> $foo = eval($trusted_code);
> _____________________________________________________________________
> Steve Linberg National Center on Adult Literacy
> Systems Programmer &c. University of Pennsylvania
> linberg@literacy.upenn.edu http://www.literacyonline.org
------------------------------
Date: Fri, 17 Jul 1998 11:00:06 -0600
From: snowbird <snowbird@pcisys.net>
Subject: Strangness in for loop ?!
Message-Id: <35AF8316.7111831E@pcisys.net>
Running the script:
#!/usr/bin/perl
@array = qw(a b c d e f g);
for $i ( 0 .. $#array ) {
last if $array[$i] eq 'c';
}
print " i = $i\n";
for ( $i=0; $i <= $#array; $i++ ) {
last if $array[$i] eq 'c';
}
print " i = $i\n";
__END__
results in:
i =
i = 2
This has me confused as to why my index variable ( $i ) is undefined
after coming out of the first for loop.
I reasoned that the range operator is making it's own copy that is
scoped only within the for loop. So I tried to force it to use my index
value by replacing the first for loop with:
for $main::i ( 0 .. $#array ) {
print "i = $main::i $array[$main::i]\n";
last if $array[$main::i] eq 'c';
}
The results were the same:
i = 0 a
i = 1 b
i = 2 c
i =
If anyone can provide a little more insight or suggested readings I
would appreciate it.
Im running Perl 5.004_04 on hp-ux 10.20
Curious in Colorado
Andrew
------------------------------
Date: Fri, 17 Jul 1998 10:55:50 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Strangness in for loop ?!
Message-Id: <MPG.10192ffd47062913989720@nntp.hpl.hp.com>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <35AF8316.7111831E@pcisys.net> on Fri, 17 Jul 1998 11:00:06 -
0600, snowbird <snowbird@pcisys.net> says...
...
> If anyone can provide a little more insight or suggested readings I
> would appreciate it.
Read the first paragraph under 'Foreach Loops' in `perldoc perlsyn`.
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 17 Jul 1998 17:23:20 GMT
From: lloyd007@best.com (lloyd)
Subject: Thanks for the help onthe if then branch
Message-Id: <lloyd007-1707981037540001@lloyd007.vip.best.com>
Thanks for the help on theif then branch my questions have been answered....
lloyd francis
lloyd007@best.com
------------------------------
Date: 17 Jul 1998 16:23:39 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: unwanted warning
Message-Id: <6ontqb$7tr$1@marina.cinenet.net>
Stephan Lagerholm (stephan@spartacus.unilog.se) wrote:
: I'm making some CGI's in perl and use the -w flag. My program uses a lot
: of dbm's but I don't want
: perl to open a new database if there doesn't exists any.:
:
: dbmopen(%AAA,"aaa",undef);
:
: Now i get alot of warnings that fills up my Apache error_log:
:
: Use of initialized value at line 111.
:
: Is there any way to avoid this ?
{ local $^W; dbmopen(%AAA,"aaa",undef); }
: I don't want to: tail -f error_log | grep -v uninitialized
I don't blame you. :)
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Fri, 17 Jul 1998 13:10:39 -0400
From: "Mark Stang" <markstang@ncgroup.com>
Subject: Win32::Registry QueryValue fails
Message-Id: <6oo0ip$kob$1@usenet1.interramp.com>
I admit from the start I am a newbie at perl.
I am using Activestate Perl for Win32 build 316
which is Perl 5.003_07
I am simply trying to read a value in the registry.
The code:
===================================
#!/perl/bin/perl -w
use Win32::Registry;
$HKEY_CURRENT_USER->Open('Console', $NewObj) || die $!;
$NewObj->QueryValue('CursorSize', $testval) || die $!;
print $testval;
======================================
The QueryValue Method fails
Would someone please tell me what I'm doing wrong?
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 3188
**************************************