[24836] in Perl-Users-Digest
Perl-Users Digest, Issue: 6987 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 10 11:06:51 2004
Date: Fri, 10 Sep 2004 08:05:09 -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 Fri, 10 Sep 2004 Volume: 10 Number: 6987
Today's topics:
Re: *.pl(in server) get http header information(from cl <end@dream.life>
Array of file names <dobedidoo@yahoo.se>
Re: Array of file names <tony_curtis32@yahoo.com>
Re: Array of file names <noreply@gunnar.cc>
Re: Array of file names <HelgiBriem_1@hotmail.com>
Re: Array of file names <dobedidoo@yahoo.se>
Re: Array of file names <miknrene@drizzle.com>
Name of variable is value of other variable (Bart Van der Donck)
Re: Name of variable is value of other variable <noreply@gunnar.cc>
Re: Name of variable is value of other variable <bernard.el-haginDODGE_THIS@lido-tech.net>
Re: Name of variable is value of other variable <jurgenex@hotmail.com>
Re: Name of variable is value of other variable <tadmc@augustmail.com>
Perl 6 and OOP (J. Romano)
Re: Perl 6 and OOP <uri@stemsystems.com>
Re: Perl 6 and OOP <noreply@gunnar.cc>
Re: Perl and Inheritance strangeness. <tadmc@augustmail.com>
Re: perl open function for size bigger than 2 Gig (Peng Yue)
Re: Problem with Compress::Zlib (SOLVED) <no_given_address@landofthelost.net>
Set-Cookie with discard in a perl CGI? (Norman Ackroyd)
Re: Set-Cookie with discard in a perl CGI? <noreply@gunnar.cc>
Re: web services... <hernan.sanchez@iname.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 10 Sep 2004 20:51:06 +0800
From: Alont <end@dream.life>
Subject: Re: *.pl(in server) get http header information(from client) failed
Message-Id: <4143a2fb.19695468@130.133.1.4>
Christian Winter <thepoet_nospam@arcor.de>Wrote at Fri, 10 Sep 2004
11:29:18 +0200:
>If you are running your perl code as a cgi script, you
>should have a look at the CGI module, which gives you
>access to POST and GET parameters and header values of
>the current request.
>
>Your server-side code would then look like:
thank you so much for your detail reply :-)
--
Your fault as a Government is My failure as a citizen
------------------------------
Date: Fri, 10 Sep 2004 15:44:27 +0200
From: "MM" <dobedidoo@yahoo.se>
Subject: Array of file names
Message-Id: <_ci0d.4141$LV3.6585@nntpserver.swip.net>
Hello,
Does anyone know a nice way to create an array with names of the files in a
path? That is, each element in the array is a name (just the name!) of one
of the files in the path.
A short example.
The path have these files:
-rw-r--r-- 1 john john 111 Sep 10 12:52 e_out2.log
-rw-r--r-- 1 john john 125 Sep 10 12:52 e_out.log
-rw-r--r-- 1 john john 182 Sep 10 12:52 p_out2.log
-rw-r--r-- 1 john john 210 Sep 10 12:52 p_out.log
-rw-r--r-- 1 john john 1050679 Sep 10 12:52 test2.prn
-rw-r--r-- 1 john john 1050679 Sep 10 12:52 test2.ps
-rw-r--r-- 1 john john 1050795 Sep 10 12:52 test.prn
-rw-r--r-- 1 john john 5426813 Sep 10 12:52 test.ps
Then I want the array, say $Files, to be like this:
$Files[0] = e_out2.log
$Files[1] = e_out.log
$Files[2] = p_out2.log
$Files[3] = p_out.log
$Files[4] = test2.prn
$Files[5] = test2.ps
$Files[6] = test.prn
$Files[7] = test.ps
Many thanks in advance,
MM
------------------------------
Date: Fri, 10 Sep 2004 08:49:22 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Array of file names
Message-Id: <87isam2pzx.fsf@limey.hpcc.uh.edu>
>> On Fri, 10 Sep 2004 15:44:27 +0200,
>> "MM" <dobedidoo@yahoo.se> said:
> Hello, Does anyone know a nice way to create an array with
> names of the files in a path? That is, each element in the
> array is a name (just the name!) of one of the files in the
> path.
perldoc -f opendir
perldoc -f readdir
perldoc -f grep
hth
t
------------------------------
Date: Fri, 10 Sep 2004 15:48:33 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Array of file names
Message-Id: <2qdps6Fuf9hkU1@uni-berlin.de>
MM wrote:
> Does anyone know a nice way to create an array with names of the
> files in a path? That is, each element in the array is a name (just
> the name!) of one of the files in the path.
perldoc -f readdir
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 10 Sep 2004 14:00:06 +0000
From: Helgi Briem <HelgiBriem_1@hotmail.com>
Subject: Re: Array of file names
Message-Id: <llc3k0l77oougqnob884khdcnjsstc1g7i@4ax.com>
On Fri, 10 Sep 2004 15:44:27 +0200, "MM" <dobedidoo@yahoo.se> wrote:
>Does anyone know a nice way to create an array with names of the files in a
>path? That is, each element in the array is a name (just the name!) of one
>of the files in the path.
my $dir = '/full/path/to/directory';
opendir DIR, $dir or die "Cannot open directory $dir:$!\n";
# leave out . and ..
my @filenames = grep !/\.{1,2}$/,readdir DIR;
closedir DIR;
print join "\n", @filenames;
--
Helgi Briem hbriem AT simnet DOT is
Never worry about anything that you see on the news.
To get on the news it must be sufficiently rare
that your chances of being involved are negligible!
------------------------------
Date: Fri, 10 Sep 2004 16:50:03 +0200
From: "MM" <dobedidoo@yahoo.se>
Subject: Re: Array of file names
Message-Id: <xaj0d.4155$LV3.6476@nntpserver.swip.net>
"Helgi Briem" <HelgiBriem_1@hotmail.com> wrote in message
news:llc3k0l77oougqnob884khdcnjsstc1g7i@4ax.com...
> On Fri, 10 Sep 2004 15:44:27 +0200, "MM" <dobedidoo@yahoo.se> wrote:
>
> >Does anyone know a nice way to create an array with names of the files in
a
> >path? That is, each element in the array is a name (just the name!) of
one
> >of the files in the path.
>
> my $dir = '/full/path/to/directory';
>
> opendir DIR, $dir or die "Cannot open directory $dir:$!\n";
>
> # leave out . and ..
> my @filenames = grep !/\.{1,2}$/,readdir DIR;
> closedir DIR;
>
> print join "\n", @filenames;
>
Ah, very nice! Just perfect. Many thanks!
MM
------------------------------
Date: Fri, 10 Sep 2004 07:52:27 -0700
From: Michael Slass <miknrene@drizzle.com>
Subject: Re: Array of file names
Message-Id: <m3u0u6gor8.fsf@eric.rossnet.com>
"MM" <dobedidoo@yahoo.se> writes:
>Hello,
>
>Does anyone know a nice way to create an array with names of the files in a
>path? That is, each element in the array is a name (just the name!) of one
>of the files in the path.
If the point of making the array is to then do something with each
file, I'd take a look at the File::Find module.
perldoc File::Find
--
Mike Slass
------------------------------
Date: 10 Sep 2004 04:33:53 -0700
From: bart@nijlen.com (Bart Van der Donck)
Subject: Name of variable is value of other variable
Message-Id: <b5884818.0409100333.6fc460e6@posting.google.com>
How can I rewrite this code so that it works for whatever value $pp
may hold ?
if ($pp eq 'xx') { $myvar = $xx }
if ($pp eq 'yy') { $myvar = $yy }
if ($pp eq 'zz') { $myvar = $zz }
Basically, I am looking for something like:
$myvar = $"$pp";
Hashes seem the best choice, but I didn't find a way to put a
variable's name in it.
Background: this goes back to a complex database construction that I
have to work with.
Thanks,
Bart
------------------------------
Date: Fri, 10 Sep 2004 13:31:58 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Name of variable is value of other variable
Message-Id: <2qdj1gFt44o8U1@uni-berlin.de>
Bart Van der Donck wrote:
> How can I rewrite this code so that it works for whatever value $pp
> may hold ?
>
> if ($pp eq 'xx') { $myvar = $xx }
> if ($pp eq 'yy') { $myvar = $yy }
> if ($pp eq 'zz') { $myvar = $zz }
>
> Basically, I am looking for something like:
> $myvar = $"$pp";
>
> Hashes seem the best choice, but I didn't find a way to put a
> variable's name in it.
%hash = ( xx => 1, yy => 2, zz => 3 );
$myvar = $hash{$pp};
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 10 Sep 2004 13:51:16 +0200
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: Name of variable is value of other variable
Message-Id: <Xns95608CEEEDF56elhber1lidotechnet@62.89.127.66>
bart@nijlen.com (Bart Van der Donck) wrote:
> How can I rewrite this code so that it works for whatever value $pp
> may hold ?
>
> if ($pp eq 'xx') { $myvar = $xx }
> if ($pp eq 'yy') { $myvar = $yy }
> if ($pp eq 'zz') { $myvar = $zz }
>
> Basically, I am looking for something like:
> $myvar = $"$pp";
http://perl.plover.com/varvarname.html
http://perl.plover.com/varvarname2.html
http://perl.plover.com/varvarname3.html
--
Cheers,
Bernard
------------------------------
Date: Fri, 10 Sep 2004 12:55:00 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Name of variable is value of other variable
Message-Id: <Euh0d.3776$Sb.205@trnddc06>
Bart Van der Donck wrote:
> How can I rewrite this code so that it works for whatever value $pp
> may hold ?
>
> if ($pp eq 'xx') { $myvar = $xx }
> if ($pp eq 'yy') { $myvar = $yy }
> if ($pp eq 'zz') { $myvar = $zz }
>
> Basically, I am looking for something like:
> $myvar = $"$pp";
NOT AGAIN!
This question has been asked before. Actually it has been Asked Frequently
(hint, hint).
Did you check
perldoc -q "variable name"
Did you check recent postings to the same topic?
Did you ask aunt google (search for symbolic reference or symref)?
> Hashes seem the best choice,
Yes, they are.
> but I didn't find a way to put a
> variable's name in it.
You don't.
Use your own hash to store your data, not the the systems symbol table hash.
jue
------------------------------
Date: Fri, 10 Sep 2004 08:14:27 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Name of variable is value of other variable
Message-Id: <slrnck3a5j.965.tadmc@magna.augustmail.com>
Bart Van der Donck <bart@nijlen.com> wrote:
> Subject: Name of variable is value of other variable
^^^^ ^^^^^^^^
Those are known as "symbolic references", and they are Bad, they
can lead to hard-to-troubleshoot bugs so they should be avoided.
You are expected to check the Perl FAQ *before* posting to the
Perl newsgroup you know.
perldoc -q name
perldoc -q variable
How can I use a variable as a variable name?
> How can I rewrite this code so that it works for whatever value $pp
^^^^^^^^^^^^^^
> may hold ?
That is impossible.
$pp may hold the name of a variable that does not exist...
$pp may hold the name of a lexical variable (symrefs don't work
on lexicals).
> if ($pp eq 'xx') { $myvar = $xx }
> if ($pp eq 'yy') { $myvar = $yy }
> if ($pp eq 'zz') { $myvar = $zz }
>
> Basically, I am looking for something like:
> $myvar = $"$pp";
If you _did_ want to use a symbolic reference (but you don't!),
then it would be:
$myvar = $$pp;
> Hashes seem the best choice, but I didn't find a way to put a
> variable's name in it.
The variable's "name" becomes the hash's "key":
if ($pp eq 'xx') { $myvar = $hash{xx} }
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 10 Sep 2004 07:04:12 -0700
From: jl_post@hotmail.com (J. Romano)
Subject: Perl 6 and OOP
Message-Id: <b893f5d4.0409100604.12dda80f@posting.google.com>
Greetings!
After doing some work with Object-Oriented Perl (and helping a
friend learn it, as well), we both agree that the Data::Dumper module
is a valuable tool for debugging OO Perl programs, as it lets us
easily see the structure and contents of complex objects (which is
something I wish more OO languages had readily available).
Now, OO Perl has had its critics, most of which are quick to say
that OO Perl is messy and doesn't enforce private data very well.
However, some do admit that this makes OO Perl quite flexible -- for
instance, a Perl object can be easily examined with the Data::Dumper
module as a result of its laid-back policy on information hiding.
Now to my question: Knowing that Perl 6 will have better OO
handling, does that mean that Data::Dumper will lose its usefulness on
Perl 6 objects? Or will it still be able to let a programmer peer
into them and let him/her tinker with their data using the debugger?
I'm hoping for the latter case, even though that case is sure not
to eliminate all of Perl's OO criticisms that gripe about the lack of
information hiding.
-- Jean-Luc
------------------------------
Date: Fri, 10 Sep 2004 14:11:07 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Perl 6 and OOP
Message-Id: <x7zn3ydxkt.fsf@mail.sysarch.com>
>>>>> "JR" == J Romano <jl_post@hotmail.com> writes:
JR> Now to my question: Knowing that Perl 6 will have better OO
JR> handling, does that mean that Data::Dumper will lose its usefulness on
JR> Perl 6 objects? Or will it still be able to let a programmer peer
JR> into them and let him/her tinker with their data using the debugger?
you seem to be conflating data::dumper and OO. dumper is not an OO tool
but a debugging and data tool. i have (as have many others) used it in
many non-oo programs. it is just a way to dump perl data structures (oo
or not) in a way that can be evaled and also read by hyoomans.
JR> I'm hoping for the latter case, even though that case is sure not
JR> to eliminate all of Perl's OO criticisms that gripe about the lack of
JR> information hiding.
i am not sure what you are talking about. dumper as it is won't do that
in perl6. but there are ways to introspect anything in perl6 (normal
code won't be able to accidentally do that) so dumper can be modified to
do that. i am sure the p6/parrot teams will make sure of that since
dumper is such a useful tool regardless of the OO nature of the data.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Fri, 10 Sep 2004 16:25:11 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Perl 6 and OOP
Message-Id: <2qds5vFug10nU1@uni-berlin.de>
Uri Guttman wrote:
>
> you seem to be conflating data::dumper and OO. dumper is not an OO tool
^^^^^^^^^^^^
Time soon to ask somebody to fix that broken shift key? After all,
module names are case sensitive. ;-)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 10 Sep 2004 08:02:22 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Perl and Inheritance strangeness.
Message-Id: <slrnck39eu.965.tadmc@magna.augustmail.com>
Anthony Roy <news@ant-roy.co.uk> wrote:
> Tad McClellan wrote:
>> antroy <news@ant-roy.co.uk> wrote:
>>>Tad McClellan wrote:
>>>
>>>>Usenet is not email!
>>>
>>>Thanks for the constructive advice.
>>
>>
>>
>> You're welcome.
>>
>> Can you identify how it is constructive to know the difference?
>
> It's called irony.
It is clear that you cannot identify why the difference between
email and usenet might be important, your loss.
But let's discuss it for the benefit of the lurkers.
> I think it is a rare thing in Texas.
If you cannot think of anything to support your position, start
looking around for something _else_ you can attack ad hominem.
Where I live is not related to whether the difference is relevant
or not.
Do you have any arguments supporting why the distinction is
not worth making? Or or you just going to continue with
name calling?
> I won't be continuing with this fork of the thread - it's exactly this
> sort of irrelevant banter that annoys me about usenet.
Your question had already been answered, so I saw no point in
answering it again.
I did, however, notice something else worth correcting, so I corrected it.
> Someone asks a
> technical question in line with the charter, and someone else responds
> with "this is usenet not email", or "use google" or other arbitrary or
> useless remark.
The ultimate goal of a question-asker is to get an answer to the question.
If "use google" leads to the answer, then such advice is NOT useless!
> Why not use the forums for the purpose they are intended,
They are intended to help people learn things, whether it was the
thing they were asking about, or some other thing that they didn't
even know they didn't know.
> rather than a
> place to simply bitch for the sake of it?
It was not just for the sake of it. It was because it makes a difference.
The social dynamic is very different between individual communication (email)
and mass communication (usenet).
You write differently for an audience of thousands than for an individual.
You might expect the recipient to remember what you were talking
about in an email dialog, but that is a poor assumption in a
usenet context. So including the relevant context is important
if writing for usenet and less important if writing for email.
Many people participate in a usenet thread, so trimming the irrelevant
material is important in usenet, less so in email.
If you write to usenet as if it was email, you will look silly,
I though perhaps you would not want to appear that way. My mistake.
> I'm just glad that there *are* people who are keen to help
I have answered tens of thousands of Perl questions on this newsgroup
in the past, and I will answer more in the future, just not any
of yours. Good luck!
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 10 Sep 2004 06:45:36 -0700
From: peng.yue@gmail.com (Peng Yue)
Subject: Re: perl open function for size bigger than 2 Gig
Message-Id: <3436affa.0409100545.4b893dc2@posting.google.com>
"cat" is working. I have no idea why it did not work when I tried
yesterday. I must did something stupid. Thanks.
------------------------------
Date: Fri, 10 Sep 2004 07:54:58 -0600
From: "Mr. No Address" <no_given_address@landofthelost.net>
Subject: Re: Problem with Compress::Zlib (SOLVED)
Message-Id: <chsd70$dbn$1@news.nems.noaa.gov>
I had a very vanilla install and thus didn't have make installed on the
machine(s).
Mr. No Address wrote:
> I have two machines with fresh Debian Sarge installs. On both I've
> tried to "install Bundle::CPAN" and they both fail in the same way. It
> looks like it might be a problem with Compress::Zlib. If I try to
> install Compress::Zlib by itself I get the following:
>
> ~>perl -v
> This is perl, v5.8.4 built for i386-linux-thread-multi
>
> ~>perl -MCPAN -e shell
> cpan> install Compress::Zlib
> CPAN: Storable loaded ok
> Going to read /root/.cpan/Metadata
> Database was generated on Thu, 09 Sep 2004 07:08:49 GMT
> Running install for module Compress::Zlib
> Running make for P/PM/PMQS/Compress-Zlib-1.33.tar.gz
> CPAN: Digest::MD5 loaded ok
> Checksum for
> /root/.cpan/sources/authors/id/P/PM/PMQS/Compress-Zlib-1.33.tar.gz ok
> Scanning cache /root/.cpan/build for sizes
> Compress-Zlib-1.33/
> ### Similar lines deleted ###
>
> CPAN.pm: Going to build P/PM/PMQS/Compress-Zlib-1.33.tar.gz
>
> Parsing config.in...
> Building Zlib enabled
> Looks Good.
> Up/Downgrade complete.
> Checking if your kit is complete...
> Looks good
> Writing Makefile for Compress::Zlib
> -- NOT OK
> Running make test
> Can't test without successful make
> Running make install
> make had returned bad status, install seems impossible
>
------------------------------
Date: 10 Sep 2004 06:28:57 -0700
From: deflatermouse@hotmail.com (Norman Ackroyd)
Subject: Set-Cookie with discard in a perl CGI?
Message-Id: <13ce2235.0409100528.773103f1@posting.google.com>
I've got a CGI script that is going to set a cookie and I would like
to be able to use some of the attributes specified in RFC2965
(ftp://ftp.isi.edu/in-notes/rfc2965.txt) such as "discard" . CGI.pm
appears to only support cookie attributes specified in the original
"HTTP State Management Mechanism" - RFC2109 document. Besides building
my response from scratch and a Socket connect, are there any cgi
modules out there that will do this?
Thanks,
Norm Ackroyd
------------------------------
Date: Fri, 10 Sep 2004 16:06:03 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Set-Cookie with discard in a perl CGI?
Message-Id: <2qdqvaFubt11U1@uni-berlin.de>
Norman Ackroyd wrote:
> I've got a CGI script that is going to set a cookie and I would
> like to be able to use some of the attributes specified in RFC2965
> (ftp://ftp.isi.edu/in-notes/rfc2965.txt) such as "discard" . CGI.pm
> appears to only support cookie attributes specified in the
> original "HTTP State Management Mechanism" - RFC2109 document.
If that's the case, it's not very difficult to print the cookie
'manually':
print "Set-cookie: name=value; path=/; otherattr\n";
Then you can include whichever attributes you believe the browsers
will understand. :)
Of course, depending on what the cookie may contain, you may need to
URI escape it.
> Besides building my response from scratch and a Socket connect,
?
> are there any cgi modules out there that will do this?
A search at CPAN should give you the answer to that question.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 10 Sep 2004 07:48:05 -0500
From: "Hernán Sánchez" <hernan.sanchez@iname.com>
Subject: Re: web services...
Message-Id: <2qdm42Ft1lurU1@uni-berlin.de>
http://www.soaplite.com/
Hernán Sánchez
"Prasad Gadgil" <prasad.gadgil@gmail.com> escribió en el mensaje
news:chosrr$ieb@odbk17.prod.google.com...
> hi,
>
> Web services is very interesting. How does one code this using perl?
> Any famous examples ?
>
> regards,
> prasad
>
------------------------------
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:
#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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V10 Issue 6987
***************************************