[9954] in Perl-Users-Digest
Perl-Users Digest, Issue: 3547 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 26 06:03:00 1998
Date: Wed, 26 Aug 98 03:00:19 -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 Wed, 26 Aug 1998 Volume: 8 Number: 3547
Today's topics:
another error in "Programming Perl"? <b.d.low@unsw.edu.au>
Authentication Process <bellears@deakin.edu.au>
Re: Authentication Process <thornton@yoyoweb.com>
Re: CGI Question, <peng7072@cs.nyu.edu>
Re: Data::Dumper question (Honza Pazdziora)
delete a line in an open file <rolf.rettinger@desy.de>
Help with reading a file (Rick)
Re: Help with reading a file (Larry Rosler)
Re: how can I print 10 digit nos. using 0s as place hol (Patrick Timmins)
Max value in an array <mferg@hal.ddntl.didata.co.za>
Re: Oh ladies and lords of Perl, do not roast or toast huntersean@hotmail.com
Re: Perl compiler (Honza Pazdziora)
Re: Perl compiler <lavelle@netgazer.net>
Re: Perl documentation (Norman UNsoliciteds)
Re: Perl documentation (Norman UNsoliciteds)
Re: Perl documentation <rra@stanford.edu>
Re: Perl FAR version 1.1.1 MAKE SURE YOU READ THIS BEFO (Norman UNsoliciteds)
Re: Question: How do I test Perl? <lavelle@netgazer.net>
Re: qw// vs. (), re. interpolation - error in "Prog Per huntersean@hotmail.com
Re: text editing in perl greene@gucc.org
webcounter in Perl? <mbusch@iskp.uni-bonn.de>
Re: Where to find Net::Domain? <versace@gianni.com>
Re: Where to find Net::Domain? (Honza Pazdziora)
Re: Y2K Date Support dave@mag-sol.com
Re: Y2K Date Support <leon@netcraft.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 26 Aug 1998 19:00:20 +1000
From: Benjamin Low <b.d.low@unsw.edu.au>
Subject: another error in "Programming Perl"?
Message-Id: <35E3CEA4.70555C7C@unsw.edu.au>
This isn't so much a question than a request for confirmation before I
send an error report to O'reilly. Comments welcome :-)
p. 117 of "Programming Perl", 2nd ed., has an example of using typeglobs
to do what it calls "symbol table aliasing". The code extract doesn't
compile under 5.004, this is what happens:
The code:
#!/usr/local/bin/perl5 -w # added by me to test the code
@c = (1..4); @d = (1..5); # added by me to test the code
(*a, *b) = f(\@c, \@d);
print "@a has more than @b\n"; # <- error here
sub f {
local (*e, *f) = @_;
if (@e > @f) { return (\@e, \@f); } else { return (\@f, \@e); }
}
the compilation error is "In string, @a must be written as \@a ...".
Evidently perl is picking up the othwerwise unknown @a within the string
and not doing the "typeglob" thing with it. This is an error, yes?
>From the perlfaq (and later in the book), I noted that you can force
expansion of arbitrary expressions using something along the lines of
@{[@a]}, e.g:
print "@{[@a]} has more than @{[@b]}\n";
which is pretty messy if you ask me. However, it does give the correct
results: "1 2 3 4 5 has more than 1 2 3 4".
--
Benjamin Low
Web Programmer, Communications Unit, University of New South Wales
(02) 9385 1138 b.d.low@unsw.edu.au b.d.low@ieee.org
------------------------------
Date: Wed, 26 Aug 1998 14:34:50 +1000
From: Mick B <bellears@deakin.edu.au>
Subject: Authentication Process
Message-Id: <35E39069.3ADD56B0@deakin.edu.au>
Hi,
I'm presently developing a Web-based course management facility, the
present system is using (On Linux)Apache/mod-perl and postgresql for the
database. For authentication it is currently using basic
PerlAuthzhandler, authentication works well, but there is no way to
log-out, I'm trying to find out more information on the way Communicator
keeps this authentication information in its memory, so there maybe a
method to delete this info so a user has to login again..
Also trying to find out more about AuthCookie, for an alternative
method.
Hope someone can help..Or point me in the direction of some relevant
info.
Thanks,
Mick
------------------------------
Date: Wed, 26 Aug 1998 01:53:17 -0700
From: Thornton Prime <thornton@yoyoweb.com>
Subject: Re: Authentication Process
Message-Id: <35E3CCFD.7DD722B7@yoyoweb.com>
Mick B wrote:
>
> Hi,
> I'm presently developing a Web-based course management facility, the
> present system is using (On Linux)Apache/mod-perl and postgresql for the
> database. For authentication it is currently using basic
> PerlAuthzhandler, authentication works well, but there is no way to
> log-out, I'm trying to find out more information on the way Communicator
> keeps this authentication information in its memory, so there maybe a
> method to delete this info so a user has to login again..
> Also trying to find out more about AuthCookie, for an alternative
> method.
>
> Hope someone can help..Or point me in the direction of some relevant
> info.
You might want to check the comp.infosystems.www.servers.unix
archives at dejanews. This issue was disscussed at great length
by some of the Apache developers.
Basically, HTTP is a "stateless" protocol. The server does not
maintain any information about the client state between requests
(without using some external mechanism like a database of
cookies), so using regular HTTP authentication means the client
sends user name and password for as long as it wants and, as long
as that information is valid, the server doesn't know if that is
one user session or not. The only way to force the HTTP realm
authentication box to pop up again is to send an HTTP 401 code,
which basically means invalidating the user's existing set of
credentials -- changing their username and/or password.
Your best bet is to use something like sessions, possibly using
cookies, and have those expire.
thornton
------------------------------
Date: Tue, 25 Aug 1998 22:49:01 EDT
From: Alex Peng <peng7072@cs.nyu.edu>
Subject: Re: CGI Question,
Message-Id: <6rvt2t$hq7$1@earth.superlink.net>
I figure it out.
Just put html first and write a java script which direct to an exe file when
html page loaded.
Alex
Alex Peng wrote:
> How to send two different outputs, a binary file and html page?
>
> I want my CGI to do the following :
> Ask user save binary file and show up a html page on the browser as
> well.
> Usually, we provide a link to exe file, so the user save the exe file by
> double clicking.
> But, I want the server sends out the exe file.
>
> I saw a copule of download pages worked.
> I had try to send two different content-type and content-length for the
> "first" output, but the second content-type was ignored.
> Can anyone point me out the secret?
>
> Thanks,
>
> Alex
------------------------------
Date: Wed, 26 Aug 1998 07:41:44 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Data::Dumper question
Message-Id: <slrn6u7f1o.hfe.adelton@aisa.fi.muni.cz>
On 26 Aug 1998 01:37:51 GMT, Niels Larsen <niels@vivo.mph.msu.edu> wrote:
>
> Greetings. The following code,
>
> ----
> use Data::Dumper;
>
> $hashRef = { "hello" => "world" };
>
> $struct->{$hashRef} = 1;
>
> print Data::Dumper->Dump ([$struct]), "\n";
> ----
>
> produces
>
> ----
> $VAR1 = {
> 'HASH(0x80b78d0)' => 1
> };
> ----
>
> Maybe a total dummy question, but should the output not show
> the hash reference expanded?
No. From man perlref(1):
WARNING
You may not (usefully) use a reference as the key to a hash.
It will be converted into a string:
$x{ \$a } = $a;
If you try to dereference the key, it won't do a hard
dereference, and you won't accomplish what you're
attempting. You might want to do something more like
Hope this helps,
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: Wed, 26 Aug 1998 11:28:02 +0200
From: "Rolf Rettinger" <rolf.rettinger@desy.de>
Subject: delete a line in an open file
Message-Id: <6s0kfr$85n$1@claire.desy.de>
I have a simple text file and I dont know how to delete a single line in an
open file. Is there someone who knows how to do that?
Thanks
Rolf
----------------------------------------------------------------------------
-------------------------------------
retti@mail.desy.de
------------------------------
Date: Wed, 26 Aug 1998 07:09:50 GMT
From: info@thewebmasters.bc.ca (Rick)
Subject: Help with reading a file
Message-Id: <35e3b276.48575413@news.realnews.net>
Hello All
I hope someone can help me, and I hope I can explain myself correctly.
What I need to do is to open a text file and read it up to a certain character
such as # or & etc. regardless of how many lines into the text file it is. I
will then consider that read to be one line, assign it to a variable, and then
read the next line up to a certain character etc etc.
Sorry if this and the question below are easy ones, but I have not been able to
find the answer.
Also, is there a limit on the maximum number of characters that can be written
on a single line into a text file? 256?
Running perl 5 on solaris 2.6
Thanks very much
Rick Noble
------------------------------
Date: Wed, 26 Aug 1998 00:44:37 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Help with reading a file
Message-Id: <MPG.104d5cc2c7eeb2f89897ef@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <35e3b276.48575413@news.realnews.net> on Wed, 26 Aug 1998
07:09:50 GMT, Rick <info@thewebmasters.bc.ca> says...
...
> What I need to do is to open a text file and read it up to a certain character
> such as # or & etc. regardless of how many lines into the text file it is. I
> will then consider that read to be one line, assign it to a variable, and then
> read the next line up to a certain character etc etc.
This is made to order for the 'input record separator'. Look for $/ in
`perldoc perlvar`.
> Also, is there a limit on the maximum number of characters that can be written
> on a single line into a text file? 256?
Perl imposes no such limit. Whether your particular OS does is a
question that can be answered only by its documentation.
--
(Yet Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 26 Aug 1998 08:48:51 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: how can I print 10 digit nos. using 0s as place holders
Message-Id: <6s0i5i$jbb$1@nnrp1.dejanews.com>
In article <6rvtsg$9kb@newsops.execpc.com>,
Mike Hammernik <mhammer@execpc.com> wrote:
> I'm trying to create file that contain a 10 digit string. The first 6
> digits are given by the user. I then need to count but I need to keep
> the number in the 10 digit format. For example
> If given 111222 I now need to construct a file that contains
>
> 1112220001
> 1112220002
> .
> .
> 1112229999
>
> The best code I can use right now is
>
> #! /usr/bin/perl -w
>
> print "Enter digits: ";
> $digits =<>;
> chomp $digits;
> open (FILE, ">digifile") or die "Can't open digifile";
> for ( $i=1; $i<= 1000; $i++) {
> $n="000"."$i";printf (FILE "%s%s\n", $digits, $n);
> )
[snip]
This should work in a general way:
print "Enter digits: ";
$digits =<>;
chomp $digits;
while ($digits =~ /\d/g) {$length++;}
$pad = 10 - $length;
$holder = 10**$pad;
open (FILE, ">digifile") or die "Can't open digifile";
foreach ($i=$holder+1; $i<2*$holder; $i++) {
$tack_on = $i;
$tack_on =~ s/\d(\d+)/$1/;
print FILE $digits.$tack_on,"\n";
}
__END__
Could do some error checking to make sure user only enters digits, no
negative numbers, and 10 digit length or less, but you get the gist.
Hope that helps.
Patrick Timmins
U. Nebraska Medical Center
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Wed, 26 Aug 1998 11:23:48 -0200
From: Mark Fergusson <mferg@hal.ddntl.didata.co.za>
Subject: Max value in an array
Message-Id: <35E40C64.224E5D65@hal.ddntl.didata.co.za>
Hello,
Please can someone help with the following:
I have an array which contains numbers. What is the easiest way to
determine what the maximum value of the numbers is ?
Thanks in advance.
--
_____________________________________________
Mark Fergusson: mferg@hal.ddntl.didata.co.za
Dimension Data:
PO Box 236, Pavillion, 3611, South Africa
(+27)-31-204-8424 (Work)
(+27)-31-204-8590 (Fax)
082-771-8519 (Cell)
------------------------------
Date: Wed, 26 Aug 1998 08:34:18 GMT
From: huntersean@hotmail.com
Subject: Re: Oh ladies and lords of Perl, do not roast or toast me or fry me in a wok*
Message-Id: <6s0haa$idu$1@nnrp1.dejanews.com>
If you want to read command line args, use the GetOpt module.
<> will not give you the value of ARGV[0], but will rather attempt to open a
filehandle to a file of the name given in ARGV[0], and give you the first
line.
Ergo, if I call my script and the first argument is "foo", and if the file
"foo" exists, and is readable in the current dir etc etc, and if the file
"foo" has the first line "The cuervo gold", then after
$a=<>;
...$a will contain "The cuervo gold".
Regards
Sean Hunter
P.S. You realise that after reading all the lines in "foo", it will perform
something akin to a shift on @ARGV, and evaluate the next argument in the
same way. <> can also read from STDIN, make the grass green and the sky
blue, make the leaves return to the trees in spring etc etc. For the full
scoop, head over to the camel and/or llama nearest you and look for "angle
operator"
In article <35E3435D.41C6@io.com>,
Jose Cuervo <jcrowe@io.com> wrote:
> Apologies to Monty Python,
>
> OK, I'm just getting my perl chops wet and I have a question that I
> do not quite understand from my reading of the old Learning Perl and
> Perl Programming. This involves getting command line parameters. I did
> not exactly see this in the FAQ either. When one reads from the command
> line using the <> filehandle, will one get the actual value of ARGV[0]?
> e.g. will this bit of code
>
> $a=<>
>
> set $a to the contents of ARGV[0].....
>
> TIA. Email OK, roasting fine too, I can stand the heat...
> --
> Joe Crowe
> mailto:jcrowe@io.com
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Wed, 26 Aug 1998 07:35:45 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Perl compiler
Message-Id: <slrn6u7emh.hfe.adelton@aisa.fi.muni.cz>
On 26 Aug 1998 03:12:35 GMT, Sam Holden <sholden@pgrad.cs.usyd.edu.au> wrote:
> Oh dear user2 managed to read the password from the execute only executable...
We do not understand each other (untried, untested):
$ ls -l /path/to/program/with/password.pl
-rwx------ 1 root root size date /path/to/program/with/password.pl
$ cat wrapper.c
int main(void)
{
uid_t effect;
effect=geteuid();
setruid(effect);
execle("/path/to/program/with/password.pl","password.pl","argument",NULL,NULL);
return(0);
}
$ cc -o wrapper wrapper.c
$ su
# chmod 111 wrapper
# chown root.root wrapper
# chmod u+s wrapper
# exit
But as I say, untested, just an idea.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: Tue, 25 Aug 1998 23:44:22 -0500
From: Brent LaVelle <lavelle@netgazer.net>
To: "Lily Y. Fu" <lily@tigr.org>
Subject: Re: Perl compiler
Message-Id: <35E392A6.BAA7F031@netgazer.net>
Lily Y. Fu wrote:
>
> I'd like to thank everyone replied my seeking for help email!
>
> But, I still need furthur help. Here is my situation:
[details deleted]
> $ftp = Net::FTP->new("out.tigr.org");
> $ftp->login("webuser", 'webuser_passwd');
> $ftp->cwd("/somedir/users/A");
> $ftp->type ("binary");
> $ftp->put("$file");
> $ftp->quit;
[more details deleted]
Good start, I have seen way too many people do some foolishness like
open(FTPIN, "|ftp out.tigr.org > /tmp/ftpout$$") or die"yaddy: $!\n";
open(FTPOUT,"tail +0F /tmp/ftpout$$|") or die"yaddy: $!\n";
Or worse (chat scripts, temp files with commands in it,...). Using
modules is good.
Like another user suggested you might look at an NFS or SMB export but
watch out for IP spoofing and other such security issues.
Going with the perl script idea I would suggest that you make sure
webuser
has limited rights on the web server. Like only able to write to that
one
directory and FTP only access. A packet sniffer can still reveal hidden
passwords going over the network.
Now (my attempt at) the answer:
You need to make your program set UID and owned by someone (like you)
that
knows the webuser_passwd and maintains the script. Put the password in
a
file by itself. Make sure is has a mode of 600. When your program needs
the
password do someting like this:
$>=$trusted_UID; #look at book://isbn-1-56592-149-6/page135
open(PASSWORD,'/home/me/.password') or die "Cannot open password file:
$!\n";
($password = <PASSWORD>) or die "Cannot read password file:
$!\n";
close PASSWORD or die "Cannot close password file:
$!\n";
$>=$<; #again look at book://isbn-1-56592-149-6/page135
I would also suggest reading page 403 if you like English and 355-360
about
set UID and taint.
BTW the code above is untested as my OS AIX4.2 doesn't like set UID
'scripts'
so I would need to write a c wrapper and I am too lazy to do that
tonight.
Which is a great segue, you OS may not support this also, I think it has
to
do with the OS not being 100% secure while doing this.
Brent LaVelle
www.perl-site.com
------------------------------
Date: Wed, 26 Aug 1998 18:26:48 +0900
From: No.unsoiliciteds@dead.end (Norman UNsoliciteds)
Subject: Re: Perl documentation
Message-Id: <No.unsoiliciteds-2608981826480001@cs11i06.ppp.infoweb.or.jp>
In article <m33eak46we.fsf@windlord.Stanford.EDU>, Russ Allbery
<rra@stanford.edu> wrote:
>I'm sorry, but despite the fact that you quoted my article to ask this
>question I really don't see what it has to do with what I said.
I was the poster you quoted asking what deluged would mean in terms of
spam. I replied to your question - why ask in the first place if this
wasn't what you wanted to know?
for the record Russ Allbery wrote in a previous message ...
> Could you define "deluged" for me? I'm extremely curious.
[referring to mentioning not having a shell account]
> I realize that many people are in that situation.
> I realize that this is a religious crusade to some people. It isn't to
> me, and I refuse to treat it that way.
I think you misunderstood my intention, I was merely speaking of my
personal experience and not trying to advocate the extermination of anyone
who doesn't have the same hardware probs
--
The Dinosaurs were so stupid, they couldn't
even devise the means of thier own extinction,
they had to wait for Nature to do it for them.
------------------------------
Date: Wed, 26 Aug 1998 18:50:02 +0900
From: No.unsoiliciteds@dead.end (Norman UNsoliciteds)
Subject: Re: Perl documentation
Message-Id: <No.unsoiliciteds-2608981850030001@cs11i06.ppp.infoweb.or.jp>
In article <1decfa1.1t40bd3w42beN@bay1-110.quincy.ziplink.net>,
rjk@coos.dartmouth.edu (Ronald J Kimball) wrote:
> <no.unsoliciteds@dead.end.com> wrote:
>
> > I think laziness is being too lazy to find alternatives to flaming.
>
> Hello, lazy, pleased to meet you.
Yes irony is a good alternative to flaming, I used it a lot in the posting
you quoted from.
--
The Dinosaurs were so stupid, they couldn't
even devise the means of thier own extinction,
they had to wait for Nature to do it for them.
------------------------------
Date: 26 Aug 1998 02:57:15 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Perl documentation
Message-Id: <m3g1ekysjo.fsf@windlord.Stanford.EDU>
Wow, I really screwed up the quoting in my reply to you. Sorry about
that. Teaches me to edit it by hand without paying attention to what I
was doing.
Norman UNsoliciteds <No.unsoiliciteds@dead.end> writes:
> Russ Allbery <rra@stanford.edu> wrote:
>> I'm sorry, but despite the fact that you quoted my article to ask this
>> question I really don't see what it has to do with what I said.
> I was the poster you quoted asking what deluged would mean in terms of
> spam. I replied to your question - why ask in the first place if this
> wasn't what you wanted to know?
I asked you to define "deluged" and your response was "Well how much do
you reckon to make it worth my time to conect up to my mail account and
hand delete the dross?" I'm sorry, maybe I'm really dim, but I don't see
at all how that's a definition of deluged. It seems to be a defensive
counterattack against some perceived slight that you think I'm making,
which I can assure you is not the case.
> I think you misunderstood my intention, I was merely speaking of my
> personal experience and not trying to advocate the extermination of
> anyone who doesn't have the same hardware probs.
I'm rather unclear on why you're so hostile on this subject.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Wed, 26 Aug 1998 18:41:14 +0900
From: No.unsoiliciteds@dead.end (Norman UNsoliciteds)
Subject: Re: Perl FAR version 1.1.1 MAKE SURE YOU READ THIS BEFORE POSTING
Message-Id: <No.unsoiliciteds-2608981841140001@cs11i06.ppp.infoweb.or.jp>
In article <1decfh0.ovhk7213c6dbdN@bay1-110.quincy.ziplink.net>,
rjk@coos.dartmouth.edu (Ronald J Kimball) wrote:
> comp.lang.perl.moderated was not set up to provide justification for the
> FAQs, CGI questions, etc. that get posted to comp.lang.perl.misc.
Nor was it set up to justify willfully abusing other users in _this_ NG.
It seems logical to believe it was set up because OF the proliferation of
the kinds of postings stated above, thereby creating a space that wouldn't
contain just those kinds of trivial, uninformed, off -topic questions.
Point being those who are persistently and willfully abusive Newbie
postings do have an alternative. The fact _they_ are still in _this_ NG
suggests they are either pathological or masochists.
--
The Dinosaurs were so stupid, they couldn't
even devise the means of thier own extinction,
they had to wait for Nature to do it for them.
------------------------------
Date: Tue, 25 Aug 1998 22:27:33 -0500
From: Brent LaVelle <lavelle@netgazer.net>
To: rich@pcav.com
Subject: Re: Question: How do I test Perl?
Message-Id: <35E380A5.B4A843A0@netgazer.net>
richsark@pcav.com wrote:
>
> Hello, I just installed Perl on my Solaris 2.51 box. I would like to know
> what the command is to test it.
make test
> I saw something like "hello World" but I
> cannot remember how to type it out. Please send me a copy of your responce
> to rich@pcav.com
perl -e 'print "Hello world\n"'
I don't want to sound mean but you should read the FAQ or in this case
the
README that came with perl.
- Brent LaVelle
www.perl-site.com
------------------------------
Date: Wed, 26 Aug 1998 08:59:49 GMT
From: huntersean@hotmail.com
Subject: Re: qw// vs. (), re. interpolation - error in "Prog Perl"?
Message-Id: <6s0iq4$jtt$1@nnrp1.dejanews.com>
Do you realise that qw quotes things, and doesn't just separate them with
commas?
Thus
use vars qw($a $b);
...is the same as...
use vars ('$a', '$b');
...and both work.
You may think the qw looks a bit ugly, but the meaning of your call is quite
different, and that is why it fails. () is only the same as qw when only
barewords are in the list. Otherwise (as you guessed) the first interpolates
each before assignment, and the second doesn't.
> @a = (a, b, c, d);
>
> works the same as
>
> @a = qw(a b c d);
...only in this special case where all the elements of the initialisation list
are barewords, and are thus treated as quoted strings.
@a = ($a, $b, $c, $d);
...is quite different from
@a = qw($a $b $c $d);
In this case I think the book is wrong. I hesitate to question the almighty
camel, but looking at page 41 and trying stuff out in the perl debugger, I
can't see how "Interpolates = no" applies to () in this context. Unless what
they actually mean is "Well, () only interpolates if there's something to
interpolate, otherwise no." ;->
Sean Hunter
In article <35E36E00.E30BA8E@unsw.edu.au>,
Benjamin Low <b.d.low@unsw.edu.au> wrote:
> "Programming Perl", 2nd ed., tells me on p. 41 that () is the Customary
> form of the Word List quoting operator, the Generic form being qw//.
>
> The perl 5.004 docs tell me there is no Customary form.
>
> Is the book in error? (This issue isn't mentioned in the errata).
> Certainly something like
>
> @a = (a, b, c, d);
>
> works the same as
>
> @a = qw(a b c d);
>
> But when I try
>
> use vars ($a, $b, $c);
>
> perl bails. (I know < use vars qw($a $b $c) > is the "normal" way of
> doing it, but I think the qw looks a bit ugly :-).
>
> Presumably the () is trying to interpolate the identifiers which happen
> to look like variables, whereas the true qw op doesn't?
> (I just tried @a = ($a, $b, $c) and it is empty)...
>
> --
> Benjamin Low
> Web Programmer, Communications Unit, University of New South Wales
> (02) 9385 1138 b.d.low@unsw.edu.au b.d.low@ieee.org
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Wed, 26 Aug 1998 07:06:33 GMT
From: greene@gucc.org
Subject: Re: text editing in perl
Message-Id: <6s0c5p$chm$1@nnrp1.dejanews.com>
TMTOWTDI - but I've done it my way! (apologies to F. Sinatra).
Hope this is what you're looking for.
Cheers,
J.Greene
# James Greene - Informatics Consulting - D-79539 Loerrach, Germany
# Internet: www.gucc.org/greene/consult - greene@gucc.org
# PGP Fingerprint: 8930 41E7 351B 56D8 801C D4D9 4C76 AF0F E24E F307
perl -we "$_=join'<',qw{d2by' f5e;f4z($iu w0@86yo=&ae b!097)l(&aa8vme
b$*};$_=unpack'u*',uc;print"
In article <6rrqok$non$1@nnrp1.dejanews.com>,
jasjeet14@my-dejanews.com wrote:
> I have simple text file, which is totally jumbled up, with lot of spaces. I
> want to arrange the file in a proper ',' delimited file, with no spaces. The
> point is how to edit this file and remove the extra spaces and arrange it in
> a delimited format ?. Can you tell me how to write a small program in perl
> which can read and thus edit this file into a proper format. The file is
> arranged like this :-
>
> [snip]
> Please help. =
>
#!/usr/bin/perl
# Copyright (C) 26 August 1998 by James Greene Informatics Consulting
# Written by James Greene, D-79539 Loerrach, Germany
# Released to the public domain - No warranties or guarantees or support.
#
# I'm making some assumptions here, since the text sample provided
# was fairly short
# 1) each field is separated by more than one space
# 2) each record is separated by a blank line
# Step 1: Read the file into a list, splitting on 'blank' lines
my $cat = 0;
my @fields;
while (<DATA>) {
chomp;
$cat = 0, next if (/^\s+=$/);
if ($cat) {
$fields[-1] .= $_ ;
} else {
push @fields, $_;
}
$cat++;
}
# Step 2: massage the data in the list to output comma-separated
foreach (@fields) {
# first, remove the equal signs and any spaces that follow them
s/=\s*//g;
# next, turn all multiple spaces (2 or more) into a single comma
s/\s\s+/,/g;
#finally, remove any leading or trailing commas
s/^,//;
s/,$//;
# then display the results
print $_, "\n";
}
__END__
MAJID HUSS=
AIN 125 (PB) 75 D.K. PUBLISHERS DISTRIBUTORS (P) LTD. G=
EOGRAPHY AN AGRICULTURAL VIEW OF HARYANA =
=
M S KAIRON 95D.K. PUBLISH=
ERS DISTRIBUTORS (P) LTD. GEOGRAPHY THE =
ANCIENT GEOGRAPHY OF INDIA
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Wed, 26 Aug 1998 11:03:50 +0200
From: Marc Busch <mbusch@iskp.uni-bonn.de>
Subject: webcounter in Perl?
Message-Id: <Pine.OSF.3.96.980826110108.6618A-100000@mira.iskp.uni-bonn.de>
Hi,
I need some hints on how to program a webcounter in Perl (or can this task
be done in JavaScript?).
Are there any resources/information or do I have to reinvent the wheel?
TIA,
bye,
...Marc...
------------------------------
Date: Wed, 26 Aug 1998 15:24:32 +0800
From: 8\(F&@ <versace@gianni.com>
Subject: Re: Where to find Net::Domain?
Message-Id: <35E3B830.32DE@gianni.com>
But perl was complaining about "Can\'t locate Net/Domain.pm ..." when I
was trying to run some test programs.
Michael Fuhr wrote:
>
> 8\(F&@ <versace@gianni.com> writes:
>
> > Tried CPAN but no luck. Help Please!
>
> Net::Domain is part of libnet.
>
> --
> Michael Fuhr
> http://www.fuhr.net/~mfuhr/
------------------------------
Date: Wed, 26 Aug 1998 07:49:52 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Where to find Net::Domain?
Message-Id: <slrn6u7fh0.hfe.adelton@aisa.fi.muni.cz>
On Wed, 26 Aug 1998 15:24:32 +0800, 8\(F&@ <versace@gianni.com> wrote:
> But perl was complaining about "Can\'t locate Net/Domain.pm ..." when I
> was trying to run some test programs.
You mean while running the make test?
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: Wed, 26 Aug 1998 07:54:49 GMT
From: dave@mag-sol.com
Subject: Re: Y2K Date Support
Message-Id: <6s0f08$g6e$1@nnrp1.dejanews.com>
In article <fl_aggie-2508981053350001@aggie.coaps.fsu.edu>,
fl_aggie@thepentagon.com (I R A Aggie) wrote:
> In article <6rtu9s$cci$1@nnrp1.dejanews.com>, dave@mag-sol.com wrote:
>
> + It only goes to 1999 because there is a bug in your program.
>
> No, not true...
OK, what I really meant was 'the program only runs correctly until 1999
because there is a bug in the program'.
> + > ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
> + > $date = "$days[$wday], $months[$mon] $mday, 19$year at
>
> In the year 2000, this program would have reported the year as:
>
> 19100
Which sure looks like a bug to me.
Dave...
--
dave@mag-sol.com
London Perl M[ou]ngers: <http://www.mag-sol.com/London.pm/>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Wed, 26 Aug 1998 10:31:47 +0100
From: Leon Brocard <leon@netcraft.com>
Subject: Re: Y2K Date Support
Message-Id: <35E3D603.A533E8B8@netcraft.com>
Craig Berry wrote:
> Oh, for pete's sake, doesn't *anybody* read the FAQs anymore? See
> perlfaq17, "Why did a hideous deformed humanoid emerge from the sewers and
> eat my brain while I was trying to sort a hash of lists?"
% perldoc perlfaq17
No documentation found for "perlfaq17". Sorry. Try again after the
cannibalistic humanoid underground dwellers stop chewing the PODs.
;-), Leon
--
Leon Brocard...............................................Perl Hacker
leon@netcraft.com.............................http://www.netcraft.com/
... Happiness is finding special characters
------------------------------
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 3547
**************************************