[16337] in Perl-Users-Digest
Perl-Users Digest, Issue: 3749 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 19 14:10:31 2000
Date: Wed, 19 Jul 2000 11:10:18 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <964030218-v9-i3749@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 19 Jul 2000 Volume: 9 Number: 3749
Today's topics:
Re: Newbie Question - about calendars <noemail@noemail.com>
Re: Newbie Question - about calendars <laf@gameonline.co.uk>
Newbie: if (param()) problem (Tony Balazs)
Re: Newbie: if (param()) problem <tony_curtis32@yahoo.com>
Re: Newcomer question on Multithreading In Active Perl <care227@attglobal.net>
Re: Open Off-Server-File <gellyfish@gellyfish.com>
Pattern matching <samara_biz@hotmail.com>
Re: Pattern matching (Neil Kandalgaonkar)
Re: Pattern matching <samara_biz@hotmail.com>
perl equivalent to "cat /dev/null >filename"? <shon@mad.scientist.com>
Re: perl equivalent to "cat /dev/null >filename"? <gus@black.hole-in-the.net>
Re: perl equivalent to "cat /dev/null >filename"? <care227@attglobal.net>
Re: Perl Expert? I need help! <mauldin@netstorm.net>
Re: Perl Expert? I need help! <cal@iamcal.com>
Re: Perl Expert? I need help! <mauldin@netstorm.net>
Re: Problem with reading values out of an ascii file (Abigail)
Re: Problem with reading values out of an ascii file (Craig Berry)
Re: Set cookie after sending text? <charles_weaver@post.harvard.edu>
Setting environment variables in Perl hdaji@my-deja.com
Re: Suggestion for syntax change (Abigail)
Re: upper case first (Craig Berry)
Re: weird eval problem nobull@mail.com
while (readdir DIR) <jboes@eoexchange.com>
Re: while (readdir DIR) <gellyfish@gellyfish.com>
Re: while (readdir DIR) <care227@attglobal.net>
Re: while (readdir DIR) (Neil Kandalgaonkar)
Re: while (readdir DIR) melet@my-deja.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 19 Jul 2000 11:39:34 -0400
From: Young <noemail@noemail.com>
Subject: Re: Newbie Question - about calendars
Message-Id: <3975CBB6.85FEAF24@noemail.com>
Do you have an example?
Neil Lathwood wrote:
> Hi Folks, I know this is being covered in a different post but I have a bit
> of a different question.
>
> In my cgi script if I run:
>
> #!/usr/bin/perl
>
> print "content-type:text/html\n\n";
>
> @fini = `cal 12 2000`;
>
> print "@fini";
>
> it prints out the date's fine but what I want to do is format the date into
> a table, the problem I have is that the output produced by the calendar
> contains a lot of spaces, how do I go about removing those spaces but still
> keeping the dates in the correct order. Hope I have explained myself
> correctly and many thanks to anyone that responds back.
>
> Neil
------------------------------
Date: Wed, 19 Jul 2000 17:00:37 +0100
From: "Neil Lathwood" <laf@gameonline.co.uk>
Subject: Re: Newbie Question - about calendars
Message-Id: <964022755.18750.0.nnrp-10.c246f12b@news.demon.co.uk>
I have attached the file, and it is available @
www.lathwood.co.uk/cgi-bin-local/date.cgi
i have just added the <PRE> tag into the html page and it prints it out on
the page like it should, but what i want to do is put all the dates into a
table in the right columns...how would i go about this?
"Young" <noemail@noemail.com> wrote in message
news:3975CBB6.85FEAF24@noemail.com...
> Do you have an example?
>
> Neil Lathwood wrote:
>
> > Hi Folks, I know this is being covered in a different post but I have a
bit
> > of a different question.
> >
> > In my cgi script if I run:
> >
> > #!/usr/bin/perl
> >
> > print "content-type:text/html\n\n";
> >
> > @fini = `cal 12 2000`;
> >
> > print "@fini";
> >
> > it prints out the date's fine but what I want to do is format the date
into
> > a table, the problem I have is that the output produced by the calendar
> > contains a lot of spaces, how do I go about removing those spaces but
still
> > keeping the dates in the correct order. Hope I have explained myself
> > correctly and many thanks to anyone that responds back.
> >
> > Neil
>
begin 666 date.cgi
M(R$O=7-R+V)I;B]P97)L#0H-"G!R:6YT(")C;VYT96YT+71Y<&4Z=&5X="]H
M=&UL7&Y<;B([#0H-"G!R:6YT(#P\14](#0H\:'1M;#X-"CQH96%D/@T*/'1I
M=&QE/@T*/"]T:71L93X-"CPO:&5A9#X-"CQB;V1Y/@T*14](#0H[#0H-"D!F
M:6YI(#T@8&-A;" D9F]R;61A=&%[)VUO;G1H)WT@)&9O<FUD871A>R=Y96%R
M)WU@.PT*<')I;G0@(CQ04D4^0&9I;FDB.PT*#0IP<FEN=" \/$5/2 T*/"]B
5;V1Y/@T*/"]H=&UL/@T*14](#0H[
`
end
------------------------------
Date: Wed, 19 Jul 2000 16:07:42 GMT
From: tbalazs-this-must-go@netcomuk.co.uk (Tony Balazs)
Subject: Newbie: if (param()) problem
Message-Id: <3975d220.28538058@1.0.0.119>
In my cgi I have:
if (param()) { #if form filled out
print p("various stuff");
print p(submit("continue"), reset("start again"));
} else
{...opening form...
}
When the submit button on the opening form is pressed, "various stuff"
etc loads just fine. But what I can't get to work at all is for the
submit button on the form above to load a third form (and so on).
I have tried putting an
if (param()) {}
else {} within the one above but this doesn't work.
Can anyone suggest what I might do?
Thanks,
Tony.
PS I have been reading the docs but haven't seen an answer to this
one.
------------------------------
Date: 19 Jul 2000 11:46:03 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Newbie: if (param()) problem
Message-Id: <87vgy2vzjo.fsf@limey.hpcc.uh.edu>
>> On Wed, 19 Jul 2000 16:07:42 GMT,
>> tbalazs-this-must-go@netcomuk.co.uk (Tony Balazs) said:
> In my cgi I have: if (param()) { #if form filled out
> print p("various stuff"); print p(submit("continue"),
> reset("start again")); } else {...opening form... }
> When the submit button on the opening form is pressed,
> "various stuff" etc loads just fine. But what I can't
> get to work at all is for the submit button on the form
> above to load a third form (and so on). I have tried
> putting an if (param()) {} else {} within the one above
> but this doesn't work.
You haven't shown the code that defines the FORM's
action. That's the location that the browser(agent)
contacts when "submit" is activated, and is what would
return the appropriate HTML with the new FORM in it.
hth
t
--
"With $10,000, we'd be millionaires!"
Homer Simpson
------------------------------
Date: Wed, 19 Jul 2000 11:18:37 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Newcomer question on Multithreading In Active Perl MSWin32
Message-Id: <3975C6CD.28CE3035@attglobal.net>
nso@manbw.dk wrote:
>
> Drew Simonis <care227@attglobal.net> writes:
>
> > IIRC, threading is not included in the perl build by default. That
> > feature is a build time option. Since you probably got a binary,
> > you probably got the defaults only.
>
> Are there any prebuilt binaries out there with 5.005 threading enabled?
>
> ActivePerl seems to have interpreter threads enabled. How is this feature
> accessed?
>
$ perldoc perlthrtut
Never used them myself, so i can't comment with anything but
foggily remembered second hand material.
------------------------------
Date: Wed, 19 Jul 2000 15:22:03 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Open Off-Server-File
Message-Id: <vIjd5.458$Px6.44598@news.dircon.co.uk>
On Tue, 18 Jul 2000 19:35:17 GMT, Phoebus Wrote:
> wow thanx for getting back to me so soon, you would think perl/cgi
> would have an easier way to do this...it seems i have to install the
> whole lwp module (and its related stuff) just to get one silly
> function, but thank you so much for the quick and direct answers.
Huh ? What 'one silly function' ? 'open' is for files not resources available
via HTTP - HTTP Is Not A File System (HINAFS) (Although I did have a rather
peculiar conversation with some colleagues regarding using all those thousands
of instances of wwwboard.pl to implement one :)
/J\
------------------------------
Date: Wed, 19 Jul 2000 11:13:59 -0400
From: "Alex T." <samara_biz@hotmail.com>
Subject: Pattern matching
Message-Id: <3975C5B7.8DDBBEBC@hotmail.com>
Hi,
I'm using this regular expression in my script. I built it based on
someone else's regular expression, which does slightly different thing.
m/.*form-data; name="(.*?)";
filename="(.*?)"[\xd\xa]*[^\xd\xa]*\xd\xa\xd\xa(.*)\xd\xa/s
I was wondering if someone could explain what \xd\xa means? I looked in
my book on regular expressions, but it says that \xnn matches any
hexidecimal, but I have \xd and \xa here, which looks like it's
something else.
Thanks!!!
Alex
------------------------------
Date: Wed, 19 Jul 2000 16:29:12 GMT
From: neil@brevity.org (Neil Kandalgaonkar)
Subject: Re: Pattern matching
Message-Id: <8l4kjr$2r0$1@localhost.localdomain>
In article <3975C5B7.8DDBBEBC@hotmail.com>,
Alex T. <samara_biz@hotmail.com> wrote:
>Hi,
>
>I'm using this regular expression in my script. I built it based on
>someone else's regular expression, which does slightly different thing.
>
>m/.*form-data; name="(.*?)";
>filename="(.*?)"[\xd\xa]*[^\xd\xa]*\xd\xa\xd\xa(.*)\xd\xa/s
>
>I was wondering if someone could explain what \xd\xa means? I looked in
>my book on regular expressions, but it says that \xnn matches any
>hexidecimal, but I have \xd and \xa here, which looks like it's
>something else.
Hexadecimal is 0-9A-F.
$ perl -e 'print 0xd , "," , 0xa , "\n"'
13,10
Starting to make sense now? It's CRLF.
--
Neil Kandalgaonkar <neil@brevity.org>
------------------------------
Date: Wed, 19 Jul 2000 12:38:35 -0400
From: "Alex T." <samara_biz@hotmail.com>
Subject: Re: Pattern matching
Message-Id: <3975D98B.4F09FE0F@hotmail.com>
Yeah, thanks!
I can't believe I didn't realize it myself... probably been debugging for
too long...
Alex
Neil Kandalgaonkar wrote:
> In article <3975C5B7.8DDBBEBC@hotmail.com>,
> Alex T. <samara_biz@hotmail.com> wrote:
> >Hi,
> >
> >I'm using this regular expression in my script. I built it based on
> >someone else's regular expression, which does slightly different thing.
> >
> >m/.*form-data; name="(.*?)";
> >filename="(.*?)"[\xd\xa]*[^\xd\xa]*\xd\xa\xd\xa(.*)\xd\xa/s
> >
> >I was wondering if someone could explain what \xd\xa means? I looked in
> >my book on regular expressions, but it says that \xnn matches any
> >hexidecimal, but I have \xd and \xa here, which looks like it's
> >something else.
>
> Hexadecimal is 0-9A-F.
>
> $ perl -e 'print 0xd , "," , 0xa , "\n"'
> 13,10
>
> Starting to make sense now? It's CRLF.
>
> --
> Neil Kandalgaonkar <neil@brevity.org>
------------------------------
Date: Wed, 19 Jul 2000 16:19:25 GMT
From: Shon Stephens <shon@mad.scientist.com>
Subject: perl equivalent to "cat /dev/null >filename"?
Message-Id: <8l4kdn$sf8$1@nnrp1.deja.com>
I am trying to figure this one out. I normally use this to flush log
file contents. I would like to create a subroutine in perl to do this
in various scripts. I tried something like this:
sub DESTROY {
open(IN,$abyss);
open(OUT,">>$file");
while (<IN>) {
print OUT $_;
}
close(IN);
close(OUT);
}
and I get this error:
Prototype mismatch: sub main::DESTROY () vs none at ./rotate.pl line 28
Has anyone done this? Please show me how!
--
Shon Stephens
UNIX Systems Administrator
shon@mad.scientist.com
"You want a piece of me?"
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 19 Jul 2000 17:31:56 GMT
From: Gus <gus@black.hole-in-the.net>
Subject: Re: perl equivalent to "cat /dev/null >filename"?
Message-Id: <964027916.6837.1.nnrp-08.c29f015a@news.demon.co.uk>
Shon Stephens <shon@mad.scientist.com> wrote:
> I am trying to figure this one out. I normally use this to flush log
> file contents. I would like to create a subroutine in perl to do this
> in various scripts. I tried something like this:
> sub DESTROY {
"DESTROY" is a reserved name, try renaming the subroutine.
> open(IN,$abyss);
> open(OUT,">>$file");
|| die ("Can't open .....
Regards,
_Gus
--
gus@black.hole-in-the.net
0x58E18C6D
82 AA 4D 7F D8 45 58 05 6D 1B 1A 72 1E DB 31 B5
http://black.hole-in-the.net/gus/
------------------------------
Date: Wed, 19 Jul 2000 13:58:22 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: perl equivalent to "cat /dev/null >filename"?
Message-Id: <3975EC3E.837CBB58@attglobal.net>
Shon Stephens wrote:
>
> I am trying to figure this one out. I normally use this to flush log
> file contents. I would like to create a subroutine in perl to do this
> in various scripts. I tried something like this:
>
Useless use of cat.
$results = `more /dev/null > $filename`;
Or, if you don't care about results (why would you here?) and you
don't want to spawn a shell, use system() with multiple arguments.
Or... take advantage of an annoying habit of Perl that clobbers
files.
open LOG, ">$file" or die $!;
That will do the same thing.
------------------------------
Date: Wed, 19 Jul 2000 15:30:57 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: Perl Expert? I need help!
Message-Id: <3975C8F6.AB645005@netstorm.net>
Bernard El-Hagin wrote:
> >$a =~ s/^(.{8})/$1/;
> ^^^
> Dammit, that should be:
>
> $a =~ s/^(.{8}).*$/$1/;
I'm stumped - why doesn't ^(.{8}) do the job? It seems like an unambiguous
assertion: 'first 8 don't care'.
-- Jim
------------------------------
Date: Wed, 19 Jul 2000 16:58:57 +0100
From: "Cal Henderson" <cal@iamcal.com>
Subject: Re: Perl Expert? I need help!
Message-Id: <Kekd5.516$KR1.8196@news6-win.server.ntlworld.com>
"Jim Mauldin" <mauldin@netstorm.net> wrote ...
: > >$a =~ s/^(.{8})/$1/;
: > ^^^
: > Dammit, that should be:
: >
: > $a =~ s/^(.{8}).*$/$1/;
:
: I'm stumped - why doesn't ^(.{8}) do the job? It seems like an unambiguous
: assertion: 'first 8 don't care'.
That doesn't replace the whole string, just the first 8 with the first 8 if i
understand correctly.
--
Cal Henderson
sub a{my$a=reverse shift;$a=~y/b-z/a-y/;unshift@a,$a;}sub b{$c.=reverse
shift; while(length($c)>=$b[0]){a(substr($c,0,$b[0]));$c=substr($c,$b[0]);
shift@b;}}@b=(6,3,5,4,10,6,4,4,2,1);$a="l?jouipv"."ezvmxpbuxih";$a.=
",jofoqqibmzamsfsfxfjtuiIg";while($a ne ""){b(substr($a,0,2));$a=
substr($a,2);}print join(" ",@a);
------------------------------
Date: Wed, 19 Jul 2000 16:58:04 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: Perl Expert? I need help!
Message-Id: <3975DD4A.24F3182E@netstorm.net>
Cal Henderson wrote:
> "Jim Mauldin" <mauldin@netstorm.net> wrote ...
> : > >$a =~ s/^(.{8})/$1/;
> : > ^^^
> : > Dammit, that should be:
> : >
> : > $a =~ s/^(.{8}).*$/$1/;
> :
> : I'm stumped - why doesn't ^(.{8}) do the job? It seems like an unambiguous
> : assertion: 'first 8 don't care'.
>
> That doesn't replace the whole string, just the first 8 with the first 8 if i
> understand correctly.
Right - silly me. I've been studying this construct
@a = /foo/g;
and got the two confused. The fog lifts ... (slowly)
-- Jim
------------------------------
Date: 19 Jul 2000 13:16:54 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Problem with reading values out of an ascii file
Message-Id: <slrn8nbplb.3do.abigail@alexandra.delanet.com>
Sven (buggerm@de.ibm.com) wrote on MMDXIV September MCMXCIII in
<URL:news:3975AEE3.412915B0@de.ibm.com>:
@@
@@ Thanks, i'll try to be more precisly
@@ it's a file full of text
@@ and anywhere can stand a formula within %formula%
@@ i can read strings out of the file and parse them find the keyword
@@ then reassemble the words to a formula and use the eval function.
@@ Problem: my perl knowledge is not that big and coding the above
@@ will take many lines for me i just wanted to know if there is a easy way
@@ to take out the formula and evaluate it.
print map {eval} /%([^%]*)%/g;
Abigail
--
echo "==== ======= ==== ======"|perl -pes/=/J/|perl -pes/==/us/|perl -pes/=/t/\
|perl -pes/=/A/|perl -pes/=/n/|perl -pes/=/o/|perl -pes/==/th/|perl -pes/=/e/\
|perl -pes/=/r/|perl -pes/=/P/|perl -pes/=/e/|perl -pes/==/rl/|perl -pes/=/H/\
|perl -pes/=/a/|perl -pes/=/c/|perl -pes/=/k/|perl -pes/==/er/|perl -pes/=/./;
------------------------------
Date: Wed, 19 Jul 2000 18:02:45 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Problem with reading values out of an ascii file
Message-Id: <snbra57m6tt181@corp.supernews.com>
Abigail (abigail@delanet.com) wrote:
: print map {eval} /%([^%]*)%/g;
Or even
print eval for /%(.*?)%/g;
Lots of different ways to approach this; pick your favorite style.
--
| Craig Berry - http://www.cinenet.net/users/cberry/home.html
--*-- "Turning and turning in the widening gyre
| The falcon cannot hear the falconer." - Yeats, "The Second Coming"
------------------------------
Date: Wed, 19 Jul 2000 16:30:05 GMT
From: Charles Weaver <charles_weaver@post.harvard.edu>
Subject: Re: Set cookie after sending text?
Message-Id: <snblsdqr6tt93@corp.supernews.com>
Thanks for the explanation.
The CGI-PERL documentation I read hasn't been clear about this, even
though it follows it implicitly.
Charles
Jim Britain wrote:
>
> [mailed and posted]
> On Wed, 19 Jul 2000 06:30:03 GMT, Charles Weaver
> <charles_weaver@post.harvard.edu> wrote:
>
> >The only time I have been successful in setting a cookie in a .cgi
program
> >is if the first header I print is:
> > print "Set-Cookie..."
> >
> >If I have already printed some html text the Set-Cookie line simply
shows
> >up on the screen as text. Is there a way to set a cookie in a program
that
> >has already sent text to the screen?
>
> #1. This question belongs in a group discussing servers, or web
> programming, not Perl.
>
> #2. In answer to your question, NO, Once the HTML has started, you
> cannot send a cookie -- a cookie part of the httpd transaction, which
> all occurs in the invisible (to the normal user) headers that occur
> before the HTML code.
--
Posted via CNET Help.com
http://www.help.com/
------------------------------
Date: Wed, 19 Jul 2000 15:35:30 GMT
From: hdaji@my-deja.com
Subject: Setting environment variables in Perl
Message-Id: <8l4hs1$qap$1@nnrp1.deja.com>
I am currently invoking a perl script through a command line on Unix
platform. However when I call the same script from a cron scheduler it
fails to find some PATH values. What I would like to do is "exactly
match" all of the environemnt variables when run from the scheduler to
those when run from the command line at the $ prompt as a normal user.
By the way the cron job is submitted as a normal user.
I just can't seem to solve this issue. Any ideas/help will be
appreciated.
What I mean by "exactly match" is I suppose when I type ENV command at
the dollar prompt; I would see a series of lines displayed. I believe I
need to repliacte the same ENV values when I run this script from a
cron scheduler.
Hasmukh Daji
hdaji@my-deja.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 19 Jul 2000 13:38:16 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Suggestion for syntax change
Message-Id: <slrn8nbqte.3do.abigail@alexandra.delanet.com>
Bart Lateur (bart.lateur@skynet.be) wrote on MMDXIV September MCMXCIII in
<URL:news:dq4bnsg43npfulr7m85mmev3l0qvlreuov@4ax.com>:
~~ jason wrote:
~~
~~ >would there be many (any?)
~~ >situations where you'd be interested in going from index (x) to index
~~ >(Z-y) (where Z represents the length of the unknown LIST) ??
~~
~~ Try skipping the first 2 items.
~~
~~ @rest = @somelist[2 .. -1];
Have you tried this?
@somelist = ('a' .. 'z');
@rest = @somelist [2 .. -1];
print "[@rest]\n";
__END__
[]
A range starting at 2 and ending at -1 contains exactly 0 elements....
Abigail
--
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'
------------------------------
Date: Wed, 19 Jul 2000 17:32:13 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: upper case first
Message-Id: <snbpgtld6tt102@corp.supernews.com>
mike solomon (mike.solomon@eps.ltd.uk) wrote:
: I need to convert a name to be lower case but with the first letter as
: uppercase
You probably don't actually want to do this, as discussed on another
thread. Not all names follow such a simple capitalization rule (MacDonald
and Macdonald are both in common use, for example).
: I have written the following script that works but is very clumsy for a
: simple operation
:
: does anyone know of a better way to do it, I am sure there must be one !
Your way is about maximally verbose and difficult. :) Here's another cut:
$name =~ s/(\w+)/\u\L$1/g;
In English, that substitution basically says: "Find every string of
contiguous word characters (letters, digits, and underscores) in $name.
For each of them, replace that string with the result of lowercasing it,
then uppercasing the first character."
--
| Craig Berry - http://www.cinenet.net/users/cberry/home.html
--*-- "Turning and turning in the widening gyre
| The falcon cannot hear the falconer." - Yeats, "The Second Coming"
------------------------------
Date: 19 Jul 2000 17:43:34 +0100
From: nobull@mail.com
Subject: Re: weird eval problem
Message-Id: <u9wviim5op.fsf@wcl-l.bham.ac.uk>
|Odo| <jasonb885@my-deja.com> writes:
> $value = eval '$self->'.${ $func }.'($h,$opts)';
What the...?
$func contains a reference to a scalar that in turn contains the name
of a method?
If this is really the case then you can simply say:
$value = $self->$$func($h,$opts);
> Some of the token handlers (called by way of the eval '' above) also
> call parse() to handle additional tokens. For some reason, when these
> handlers call parse() (after being called from within parse()), the $h
> hash ref is clobbered in the eval ''. Outside the eval, $h refs the
> correct hash. The result is tokens called from within the eval no
> longer have the correct $h passed to them. eval '' seems to be keeping
> the original, first 'copy' of $h and it continues to eval
> '$self->token_handler($h,$opts)' using that $h.
The fact that strings compiled at runtime using eval() can refer by
name to lexical variables (which don't for most purposes _have_ names
at run-time) is fairly deep voodoo. With my limited understanding of
how lexical variables and re-entrancy are handled (see
perlguts/"Scratchpads and recursion") this is exactly the sort of bug
I'd expect.
> I only get this behavior with Perl 5.005_02 on a BSD box. Under Perl
> 5.005_03 on Debian GNU/Linux it works as I expect.
So the most reasonable concusion is that the bug was fixed in
5.005_03.
> I'd just remove the eval, but all of the token handlers called are
> autoloaded by SelfLoader, so I can't create a bunch of sub refs keyed to
> token handler names or anything like that to take eval '' out of the
> equation.
As far as I know there's no problem with symbolic method refs calling
autoloaded methods.
BTW: Method refs in Perl are of necessity symbolic so "use strict"
doesn't bitch about them.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 19 Jul 2000 11:14:13 -0400
From: Jeff Boes <jboes@eoexchange.com>
Subject: while (readdir DIR)
Message-Id: <3975c721$0$48155$44a10c7e@news.net-link.net>
I've been burned on this more than once. Why is that
open(FILE, '<foo') or die;
while(<FILE>) {
...
}
but yet
opendir(DIR, 'foo/') or die;
while(readdir DIR) {
...
}
doesn't work? (You have to explicitly assign the result of readdir DIR
to a scalar; you can't even say
while(scalar(readdir DIR))...
and I just don't get it.) What's different about 'readdir DIR' and
'<FILE>'?
--
Jeff Boes |Computer science is no more |jboes@eoexchange.com
Sr. S/W Engineer |about computers than astronomy|616-381-9889 ext 18
Change Technology|is about telescopes. |616-381-4823 fax
EoExchange, Inc. | --E. W. Dijkstra |www.eoexchange.com
------------------------------
Date: Wed, 19 Jul 2000 15:38:05 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: while (readdir DIR)
Message-Id: <xXjd5.459$Px6.44598@news.dircon.co.uk>
On Wed, 19 Jul 2000 11:14:13 -0400, Jeff Boes Wrote:
> I've been burned on this more than once. Why is that
>
> open(FILE, '<foo') or die;
> while(<FILE>) {
> ...
> }
>
> but yet
>
> opendir(DIR, 'foo/') or die;
> while(readdir DIR) {
> ...
> }
>
> doesn't work? (You have to explicitly assign the result of readdir DIR
> to a scalar; you can't even say
>
> while(scalar(readdir DIR))...
>
> and I just don't get it.) What's different about 'readdir DIR' and
> '<FILE>'?
>
Because it is the diamond operator that is special here not the while().
/J\
------------------------------
Date: Wed, 19 Jul 2000 11:39:34 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: while (readdir DIR)
Message-Id: <3975CBB6.8E5746D8@attglobal.net>
Jeff Boes wrote:
>
> I've been burned on this more than once. Why is that
>
> open(FILE, '<foo') or die;
> while(<FILE>) {
> ...
> }
>
> but yet
>
> opendir(DIR, 'foo/') or die;
> while(readdir DIR) {
> ...
> }
readdir returns the next directory entry for a directory when used
in scalar context. If you use it in list context, I think you'll
get the behaviour you want, like so maybe:
------------------------------
Date: Wed, 19 Jul 2000 16:38:41 GMT
From: neil@brevity.org (Neil Kandalgaonkar)
Subject: Re: while (readdir DIR)
Message-Id: <8l4l5k$2su$1@localhost.localdomain>
In article <3975c721$0$48155$44a10c7e@news.net-link.net>,
Jeff Boes <jboes@eoexchange.com> wrote:
>and I just don't get it.) What's different about 'readdir DIR' and
>'<FILE>'?
while (<FILE>) is special. readdir DIR is normal.
See man perlop under I/O operators for the special while (<FILE>) magic.
To do something similar with readdir DIR:
while (defined (my $f = readdir DIR)) {
print "$f\n";
}
--
Neil Kandalgaonkar <neil@brevity.org>
------------------------------
Date: Wed, 19 Jul 2000 17:04:41 GMT
From: melet@my-deja.com
Subject: Re: while (readdir DIR)
Message-Id: <8l4n2p$urv$1@nnrp1.deja.com>
hello
you must affect the result of readdir(DIR) in a table.
@ls=readdir(DIR);
foreach $f (@ls){
.....
}
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 V9 Issue 3749
**************************************