[11164] in Perl-Users-Digest
Perl-Users Digest, Issue: 4764 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 27 20:07:30 1999
Date: Wed, 27 Jan 99 17:00:18 -0800
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, 27 Jan 1999 Volume: 8 Number: 4764
Today's topics:
Re: ? Sessions in CGI, Perl, Apache, Unix ? <gellyfish@btinternet.com>
Re: Camand line params into a perl script. halxd2@my-dejanews.com
Re: CDDA Access? Or CDDB even! <paul@miraclefish.com>
Cookie and redirect <info@gottsoftware.dk>
Re: Dereferencing and element of an array <shawn@iweb.dhis.org>
Re: Dereferencing and element of an array (Sam Holden)
Re: Email notification <Jann.E.VanOver@Boeing.com>
Re: Globbing. <om@republica.freeserve.co.uk>
Re: Globbing. scraig@my-dejanews.com
Re: Gosh, s// faster than m// (was Re: Counting charact (Ilya Zakharevich)
Re: Help with RE for separate Perl codes and comments <brucem@library.ucdavis.edu>
Re: HELP with string parsing and scoring <ludlow@us.ibm.com>
Re: HELP with string parsing and scoring <jeromeo@atrieva.com>
is crypt() function compatible? (THE Groovy)
just for kicks: forking chat server with full log <david@kasey.umkc.edu>
LWP and Cookies neal@make-a-store.com
Re: Perl Criticism [summary] (I R A Aggie)
Re: Perl Criticism [summary] ptimmins@netserv.unmc.edu
Re: Perl Criticism topmind@technologist.com
Perl/Tk graphing module <peromaric@yahoo.com>
Re: perlcc problem (some compilled programs doesn't run vishalb@my-dejanews.com
Re: Request for negative value list indexes <uri@ibnets.com>
Re: Safely editing /etc/passwd. <estabroo@ispn.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 27 Jan 1999 23:18:59 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: ? Sessions in CGI, Perl, Apache, Unix ?
Message-Id: <78o6t3$2mj$1@gellyfish.btinternet.com>
On Wed, 27 Jan 1999 12:58:13 -0500 Peter Perchansky, Microsoft FrontPage MVP wrote:
> Greetings:
>
> In NT you have sessions (time outs, et all) where you can keep track of each
> user's session in RAM (or via a cookie).
>
> Is there a way on Apache/Unix where you can create a session for a visitor
> (aka shopping cart session), and keep track of the session time?
>
Of course this isnt really a Perl question at all but appropriate to#
comp.infosystems.www.authoring.cgi
or its FAQ.
You will probably need to use cookies in general.
Alternatively you can use mod_perl and Apache::Session or even Apache::ASP
if you so desire which is more Perlish as I'm sure you'll see.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Wed, 27 Jan 1999 20:19:28 GMT
From: halxd2@my-dejanews.com
Subject: Re: Camand line params into a perl script.
Message-Id: <78nsc6$ivs$1@nnrp1.dejanews.com>
In article <m3btjmgjpn.fsf@joshua.panix.com>,
Jonathan Feinberg <jdf@pobox.com> wrote:
> Billy Bagshaw <bill@highwater.co.uk> writes:
>
> > I'm running perl scripts under Win NT4 using bat files.
> > Can I pass command line params to the script from the bat file ?
>
> What happened when you tried it?
>
> --
> Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
> http://pobox.com/~jdf
>
Absolutely!
@ECHO OFF
perl file.pl %1 %2 %3 %4 REM each %[0-9] is the args from the batch
hal
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 27 Jan 1999 23:50:07 +0000
From: Paul Sharpe <paul@miraclefish.com>
Subject: Re: CDDA Access? Or CDDB even!
Message-Id: <36AFA62F.6281DEA1@miraclefish.com>
Angus McLeod wrote:
>
> Naturally, I ment CDDB. :-/
>
> On Mon, 25 Jan 1999 16:49:42 -0400 (AST), Angus McLeod wrote:
>
> >Is there any code around to assist in accessing the internet CDDA servers?
> >
CDDB.pm on CPAN
------------------------------
Date: Thu, 28 Jan 1999 00:56:20 +0100
From: "Gott-Software Internet" <info@gottsoftware.dk>
Subject: Cookie and redirect
Message-Id: <78o93i$3fr8$1@news-inn.inet.tele.dk>
Is it posible to send 2 cookies and then a redirection from a perl script.
I've tried this:
my $the_cookie = new CGI::Cookie(-name=>"cok1",
-value=>$count,
-expires=>'+1y');
my $the_cookie2 = new CGI::Cookie(-name=>"cok2",
-value=>$prof,
-expires=>'+1y');
print "Set-Cookie: $the_cookie\n";
print "Set-Cookie: $the_cookie2\n";
print "Location: $sp\n\n";
but it dosn't send the cookies, just redirect.
------------------------------
Date: Wed, 27 Jan 1999 20:44:26 -0400
From: "Shawn Crosby" <shawn@iweb.dhis.org>
Subject: Re: Dereferencing and element of an array
Message-Id: <78obtc$2rh$1@garnet.nbnet.nb.ca>
Unfortunately, I need the whole array. I know my example was a little
vague. What I am doing is querying a database and passing two columns to a
subroutine in a graphing module (GIFgraph).
The first array is my X axis values which are Mon, Tue, Wed, etc. Only
there are 288 Y values for each day of the week...I only want one Mon, one
Tue, etc to be printed, however the module croaks if I don't pass it the
same number of x and y values. The module, as far as I can tell, won't let
me group the x values together.
What I want to do is change the module, similar to my example, to let it
loop through and compare the current x value ($d->[0][$i]) to the previous x
value ($d->[0][$i-1])...if it is the same, don't print the label just loop
to the next x value.
I added another couple of lines just to see what the heck was going on:
....
open(FIGOUT,">/home/public/figure.txt");
for $i (0..$s->{numpoints}){ #already part of the module
print FIGOUT "\n$i";
if($d->[0][$i]==$d->[0][$i-1]){print FIGOUT " - $d->[0][$i] -
$d->[0][$i-1]";
...
}
close FIGOUT;
The result was that the 2 $d elements printed every time even though I could
see in the output file that the two values periodically did not equal..(i.e.
289 - Wed - Thu). If I change the compare operator to != then nothing
printed....basically telling me that 'Wed' and 'Thu' were equal.
What am I missing?!?
Sam Holden wrote in message ...
>
>If the unique values thing is what you really want the why not try :
>perlfaq4 : How can I extract just the unique elements of an array?
>
>>
>>#!/usr/bin/perl
>>
>>my @col1=(1, 1, 1, 2, 2, 2, 3, 3, 3, 4); #print only the first of each
>>repeated value in funct
>>my @col2=(6, 5, 3, 7, 5, 3, 4, 3, 6, 2);
>>my @data=([@col1], [@col2]);
>>
>>&funct(\@data);
>>
>>sub funct($) # \@data
>> {
>> my $d=shift;
>> for $i (0..9){
>> next if ($d->[0][$i]==$d->[0][$i-1]);
>
>That line is going to do probably what you don't expect if the first and
last
>elements of the array are the same. Remember $array[-1] gives the last
element
I hadn't thought of this yet..(thank you)..., but I haven't even gotten it
to work poorly yet.
>>---desired output---
>>1
>>2
>>3
>>4
>
>And how does that differ from what you get ???????
>
As I said...nothing prints. Is this just some concept that I am missing
completely, or what?
Shawn Crosby
scrosby@jacqueswhitford.com
------------------------------
Date: 28 Jan 1999 00:56:04 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Dereferencing and element of an array
Message-Id: <slrn7avdd4.p39.sholden@pgrad.cs.usyd.edu.au>
On Wed, 27 Jan 1999 20:44:26 -0400, Shawn Crosby <shawn@iweb.dhis.org> wrote:
>
>The result was that the 2 $d elements printed every time even though I could
>see in the output file that the two values periodically did not equal..(i.e.
>289 - Wed - Thu). If I change the compare operator to != then nothing
>printed....basically telling me that 'Wed' and 'Thu' were equal.
>
>What am I missing?!?
'Wed' and 'Thu' are equal since they are both 0 when treated as a number.
If you include the -w that should always be there - especially when you
are having problems perl would tell you this - in fact perl would
yell at you about it...
To test equality of strings use 'eq' to test equality of numbers use '=='.
--
Sam
Just don't create a file called -rf. :-)
--Larry Wall
------------------------------
Date: Thu, 28 Jan 1999 00:33:51 GMT
From: Jann E VanOver <Jann.E.VanOver@Boeing.com>
Subject: Re: Email notification
Message-Id: <36AFB06F.2A97A26C@Boeing.com>
Christoph Janser wrote:
>
> Stephan Slagter schrieb in Nachricht <369C63EA.1B56C495@eega.nl>...
> >I'm looking for a way to send visitors a email notifications when a html
> >page is changed on our server. I've seens this before but can't find it
> >again.
> >If you know of any service, perl- or javascript that can do this, please
> >let me know.
>
> Hi Stephan
> http://www.mindit.com is a very good service in the internet for your
> problem.
>
That one didn't work for me, but http://url.netmind.com/ did
------------------------------
Date: Wed, 27 Jan 1999 23:19:23 -0000
From: "OM" <om@republica.freeserve.co.uk>
Subject: Re: Globbing.
Message-Id: <78o7et$ekd$1@news7.svr.pol.co.uk>
Sam Holden wrote in message ...
>
>It does exactly what I would expect it to...
>
>So what do you expect it to do?
>What does it actually do when you try it?
>
It doesn't like it and gives me an error, it complains about using
uninitialised data, or something to that effect.
------------------------------
Date: Wed, 27 Jan 1999 23:31:54 GMT
From: scraig@my-dejanews.com
Subject: Re: Globbing.
Message-Id: <78o7la$t6l$1@nnrp1.dejanews.com>
In article <78nlo8$cq0$1@nnrp1.dejanews.com>,
jambutter@my-dejanews.com wrote:
> Can someone tell me what's wrong with the following...
>
> sub CheckForFiles
> {
> my $c = $_[0];
>
> while (defined($nextfile = <${c}>))
> {
> print $nextfile."\n";
> }
> }
>
> What gets passed to the sub routine is a path, like "/dir/*".
Check out opendir and readdir.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 28 Jan 1999 00:24:14 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Gosh, s// faster than m// (was Re: Counting characters with tr/// (in perl))
Message-Id: <78oane$i4o$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Jonathan Feinberg
<jdf@pobox.com>],
who wrote in article <m3ognkproe.fsf_-_@joshua.panix.com>:
> sub substitute { $bucket =~ s/$foo/$foo/g }
> sub match_1 { scalar (() = $bucket =~ m/$foo/g) }
> sub match_2 { $c=0; ++$c while $bucket =~ m/$foo/g; $c }
> Benchmark: timing 200000 iterations of match_1, match_2, substitute...
> match_1: 13 wallclock secs (13.39 usr + 0.01 sys = 13.40 CPU)
> match_2: 10 wallclock secs ( 9.89 usr + 0.00 sys = 9.89 CPU)
> substitute: 6 wallclock secs ( 7.10 usr + 0.00 sys = 7.10 CPU)
>
> Any comments on what I consider to be starkly weird?
It is clear that Perl match_2 may be slower than C substitute. One of
the differences with match_1 is that it creates/destroys a list of
data. This *might* slow things down. Are you using system's malloc?
Ilya
------------------------------
Date: Wed, 27 Jan 1999 16:43:19 -0800
From: Bruce McEachern <brucem@library.ucdavis.edu>
To: Tad McClellan <tadmc@metronet.com>
Subject: Re: Help with RE for separate Perl codes and comments
Message-Id: <36AFB2A7.579A@library.ucdavis.edu>
>Tad McClellan wrote:...
> :
> :
> : Jerry Chen <016781c@acadiau.ca> writes:
> : >
> : > I have some difficulties to parse Perl code to identify
> : > the source part and comment part using regular expression...
> :
> :
> There are other uses for # though...
>
> s#</a>##; # so long anchor end tags...
>
> That leaves the single character 's' for the example line above.
>
> Jerry heard right. It is difficult....
Tad,
Sorry to reply to you, but you provided the most astute example of
the difficulties here. And, sorry to resurrect this ancient thread
(1 week!) but this is exactly why I came up to Usenet this time
around. Hasn't anybody done this in a comprehensive fashion and
posted it in CPAN? (I haven't found anything, does anybody know of
such?)
It seems to me the crux of the problem is that we have to except
all quotish type situations and, perhaps, some functionals (eg,
eval() ). I know little about it, but I believe a finite state
table-driven parse should do it--and I think it may be fairly
easy to construct in Perl. It's just that I'd just as soon not
re-invent the wheel. (Not to mention that I didn't major in CS,
so I never got any formal training in doing such things as
table-driven parsers.)
If you, or anyone, can point me in a direction to find out about
anything already done in this regard, I'd appreciate it. Maybe
some help from Larry on how Perl parses Perl. Thanks for anything,
Bruce
--------------------------------------------------------------------
Bruce McEachern >> brucem@library.ucdavis.edu <<
Library Systems Department The older I get, the better I...was.
Univ. of California, Davis Youth is fleeting
Phone: (530) 752-7685 --immaturity can last a lifetime.
--------------------------------------------------------------------
------------------------------
Date: Wed, 27 Jan 1999 17:06:43 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: HELP with string parsing and scoring
Message-Id: <36AF9C03.E4083A0F@us.ibm.com>
Danny Paxton wrote:
> Hello...
Hi again.
> I am looking for some help. I am taking a 31 character string from an
> HTML FORM and attempting to treat each character as an individual answer
> to a question of a test. I am then trying to assign a certain number
> depending on the individual character (it changes depending on the
> answer and question number). I am then trying to keep a running total
> so that I can get an overall score. I have tried to use substr() to
> isolate the idnividual characters of the string but am not enough of an
> accomplished perl programmer to see where my mistakes may lie. If
> someone could give me the first couple of lines of code I would greatly
> appreciate it.
Seems like I've seen this post before. In response to the first time
you asked this question, a couple of us told you to go read about the
"split" function. If you're having trouble keeping track of responses
to your messages, dejanews.com is a great tool for this.
Read all about split. If you're still having trouble, post some of your
code. Show what your program output is. Also explain what you expect
your output to be. You'll get much more exact answers this way.
You may benefit from a trip to www.perl.com. There are links there to
the documentation and the FAQ (both of which are installed with perl
also).
If you've got some cash to burn (invest in this case), "Learning Perl"
published by O'Reilly is an excellent place to start. There is a
version for Unix and for Win32. Go through each and every example
program in this book, and you'll see your current problem as exceedingly
trivial.
Good luck.
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: Wed, 27 Jan 1999 15:28:47 -0800
From: Jerome O'Neil <jeromeo@atrieva.com>
To: Danny Paxton <paxtond@ix.netcom.com>
Subject: Re: HELP with string parsing and scoring
Message-Id: <36AFA12F.C3290D9@atrieva.com>
No one here is expert enough to tell you what you are doing wrong unless
you show us what doesn't work.
Here is one way to do what you want. There are probably more efficient
ways, but this works.
This, of course, will annoy Topmind (sic).
#!/usr/local/bin/perl -w
use strict;
my($string) = 'AAPBBBJJFFDDOOFVVDDECFGBBA';
my(@array,$char) = ();
my($i) = 0;
while($char = substr($string,$i++,1)){
push @array, $char;
}
Danny Paxton wrote:
>I am taking a 31 character string from an
> HTML FORM and attempting to treat each character as an individual answer
> to a question of a test. I am then trying to assign a certain number
> depending on the individual character (it changes depending on the
> answer and question number). I am then trying to keep a running total
> so that I can get an overall score. I have tried to use substr() to
> isolate the idnividual characters of the string but am not enough of an
> accomplished perl programmer to see where my mistakes may lie.
--
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947
The Atrieva Service: Safe and Easy Online Backup http://www.atrieva.com
------------------------------
Date: 28 Jan 1999 00:12:33 GMT
From: thegroovy@aol.comNOSPAM (THE Groovy)
Subject: is crypt() function compatible?
Message-Id: <19990127191233.17233.00000082@ng155.aol.com>
Greetings,
I am making a mailing list manager for resale and am trying to determine
how compatible it is with Win NT. However, I was stumped on the crypt()
function, and am not sure if it is one of those Unix-only commands, or does Win
NT work the same?
Regards,
Gil Hildebrand, Jr.
UIN: 28517138
THEGroovy\@aol.com
remove the \ to email me (I hate spam!)
------------------------------
Date: Wed, 27 Jan 1999 18:35:09 -0600
From: David L Nicol <david@kasey.umkc.edu>
To: "Paul M. Lambert" <plambert@nas.nasa.gov>
Subject: just for kicks: forking chat server with full log
Message-Id: <36AFB0BD.3C1ED45@kasey.umkc.edu>
This is a multi-part message in MIME format.
--------------AABC52E37AB04D20C26C6991
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Paul M. Lambert wrote:
>
> David L Nicol said:
> >
> > Paul M. Lambert wrote:
> >
> > > It's a chat-like server, which makes the use of fork equally complicated,
> >
> > there's threads --- each thread is responsible for its own client, and
> > they share a queue that they insert messages in to, the destination end
> > of the queue appends messages onto an array, to keep from logging the
> > whole chat the array index variable wraps to zero whenever it hits a
> > thousand lines, each client checks the array pointer against its local
> > array index and distributes to catch up.
> >
> > And the article I'm responding to here is two weeks old, anyway.
> >
>
> I don't know that I'm competent enough to implement that complicated
> of a server.
>
> This problem has to have been solved before the implementation of
> perl threads, right? I would expect that someone had done this before
> perl5...
>
> It doesn't really matter. The thing mostly works, and I'm too lazy to fix
> it. ;-)
>
> --Paul L.
plenty of disk space?
each client gets forked into their own process
socket binding and listending code largely copied from perldoc perlipc
---- started out in thi se-mail message but got into its own file
so I could debug it, you need to use ioctl to see if there is data
available on a socket, that was tricky because I had to locate where
the ioctls.ph file had gotten hidden; anyway the forking chat server
attached to this posting works
all processes lock and append to a file called chatlog when they get
data in
all processes have an open read handle on chatlog and send its tail to
their connections
i'd rather use "seek" than "select".
But the same kind of rotate-the-pointer kind of thing could be done
with opening a new data file whenever the old one is up to the largest
size; then again why not keep a log of the whole chat server and kick
everyone
off and restart every week or so? disk space is cheap.
using threads instead of processes (there is a working example threaded
server at http://www.tipjar.com/idiots/server )
means all the threads share the dynamic variable space, as well
as sharing the file system; I have always done IPC with the file system,
it works across platforms, I never quite got the hang of "shared memory
segments."
________________________________________________________________________
David Nicol 816.235.1187 UMKC Network Operations david@news.umkc.edu
"ManyFaces[13k] has resigned the game."
--------------AABC52E37AB04D20C26C6991
Content-Type: text/plain; charset=us-ascii; name="perlchat"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="perlchat"
#!/usr/bin/perl -Tw
use Socket;
use Carp;
my $port = shift || 5555;
my $proto = getprotobyname('tcp');
$port = $1 if $port =~ /(\d+)/; # untaint port number
socket(Server, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
setsockopt(Server, SOL_SOCKET, SO_REUSEADDR,
pack("l", 1)) || die "setsockopt: $!";
bind(Server, sockaddr_in($port, INADDR_ANY)) || die "bind: $!";
listen(Server,SOMAXCONN) || die "listen: $!";
print "server started on port $port\n";
my $waitedpid = 0;
my $paddr;
sub REAPER {
$waitedpid = wait;
$SIG{CHLD} = \&REAPER; # loathe sysV
print "reaped $waitedpid" . ($? ? " with exit $?" : '');
}
$SIG{CHLD} = \&REAPER;
for ( $waitedpid = 0;
($paddr = accept(SOCKET,Server)) || $waitedpid;
$waitedpid = 0, close SOCKET)
{
next if $waitedpid and not $paddr;
my($port,$iaddr) = sockaddr_in($paddr);
my $name = gethostbyaddr($iaddr,AF_INET);
print "$$ received connection from $name [",
inet_ntoa($iaddr), "]
at port $port\n";
# fork a new process to handle the client
last unless fork();
};
print "$$ handling connection\n";
# from perldoc -q flush
select((select(SOCKET), $| = 1)[0]);
use Fcntl ':flock'; # import LOCK_* constants
until(defined($myname)){
print SOCKET "What's your name\n";
$myname = <SOCKET>;
if($myname =~ m/(\w+)/){
$myname = $1;
}else{
print SOCKET "Your name must be made of A-Za-z0-9_, please.\n";
undef $myname;
};
};
print SOCKET "type \"BYE\" to leave the chat.\n";
open WCHAT,">>chatlog";
open RCHAT,"chatlog";
seek(RCHAT,0,2);
$Rpos = tell RCHAT;
# you'll have to locate this on your machine; I found
# it with find /usr/lib -type f | xargs -n4 grep FION
# messy, huh?
require '/usr/lib/perl5/i386-linux/5.00404/asm/ioctls.ph';
# although it might work right if I didn't have pieces of
# several versions of perl5 in here
for (;;){
$size = pack("L", 0);
ioctl(SOCKET, FIONREAD(), $size) or die "Couldn't call ioctl: $!\n";
$size = unpack("L", $size);
if ($size){
sysread(SOCKET,$data,$size);
$data =~ s/\s+$//;
# expand this by keeping lines that aren't \nterminated in
# a buffer instead of just blatting out the fragments?
last if ($data eq 'BYE');
print "received <$data> from $myname\n";
flock(WCHAT,LOCK_EX);
seek(WCHAT,0,2);#see `perldoc -f seek`
print WCHAT "$myname > $data\n";
flock(WCHAT,LOCK_UN);#nice perl flushes for us here
};
seek(WCHAT,0,2);
$Wpos = tell(WCHAT); # we're not writing to it, we just want
# to know how much it has grown
# this could be replaced with
# the same "Is there data there?"
# ioctl used on the socket
# then follow with a tail -f analogue
if($Rpos < $Wpos){ print SOCKET <RCHAT>};
$Rpos = tell RCHAT;
sleep 1; # not the world's most responsive chat server.
}
print SOCKET "Goodbye\n";
print "Closing connection from $myname\n";
--------------AABC52E37AB04D20C26C6991--
------------------------------
Date: Wed, 27 Jan 1999 22:50:56 GMT
From: neal@make-a-store.com
Subject: LWP and Cookies
Message-Id: <78o58e$r5f$1@nnrp1.dejanews.com>
I have a script which gets a whole bunch of different URLs which use cookies.
I want LWP to maintain cookies (get/set) just like a browser would.
What am I doing wrong in my pseudo-code below;
use HTTP::Cookies;
$cookie_jar = HTTP::Cookies->new;
while (have more URLS to get) {
$ua = new LWP::UserAgent;
$ua->cookie_jar($cookie_jar);
$req = new HTTP::Request('GET' => $url);
$res = $ua->request($req);
....
}
Thanks,
Neal
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 27 Jan 1999 17:59:14 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Perl Criticism [summary]
Message-Id: <fl_aggie-2701991759140001@aggie.coaps.fsu.edu>
In article <39iudsv0ho.fsf@ibnets.com>, Uri Guttman <uri@ibnets.com> wrote:
+ interesting how bottommind read these threads and keeps flaming but has
+ nothing to say in any other thread. maybe he could actually post some
+ code or comments in a reply to a real perl question. then we can see the
+ true genius of his unobsfucated code.
Now, now, he's already admitted to being more of an 'idea rat'. I
believe this is the point where Dogbert steps in and tells topmind
"IT CAN'T BE DONE THAT WAY, YOU BLITHERING IDIOT. Lean over here so I can
slap you."
James
------------------------------
Date: Thu, 28 Jan 1999 00:08:52 GMT
From: ptimmins@netserv.unmc.edu
Subject: Re: Perl Criticism [summary]
Message-Id: <78o9qe$v62$1@nnrp1.dejanews.com>
In article <78nvuj$ma4$1@nnrp1.dejanews.com>,
topmind@technologist.com wrote:
> Well, at least the insults aren't ALL directed my way.
> That was refreshing to see. You at least hinted at the
> anti-establishment cowboy-like center-of-the-prairie
> attitude of some of those here.
So now this pointy-haired pretty-boy is slamming ranching and the
"prarie" in addition to Perl?
... when does topmind-a-huntin season start? <- (a joke ... don't freak :)
from the plains of Nebraska, where cattle and corn are king
... and we use Perl whenever and wherever we damn-well please
... and tough cobs if your manager doesn't like it
Patrick Timmins
$monger{Omaha}[0]
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 27 Jan 1999 21:30:09 GMT
From: topmind@technologist.com
Subject: Re: Perl Criticism
Message-Id: <78o0gl$moq$1@nnrp1.dejanews.com>
In article <78n78a$v37$1@nnrp1.dejanews.com>,
aqumsieh@my-dejanews.com wrote:
> In article <78gpsb$qfq$1@nnrp1.dejanews.com>,
> topmind@technologist.com wrote:
>
> > How about somebody take that cryptical signiture that
> > somebody here keeps posting at the bottom and turn it
> > into Pascal or Java. Let's see if they can make it
> > equally confusing to reverse engineer.
>
> As far as I'm concerned, that's a feature in Perl that is lacking in Pascal
> and Java. It is true that it is *easier* to write obfuscated code in Perl,
> but at the risk of sounding redundant, that is a feature.
Being Obfuscatable is a "feature"?
This almost reminds of MS calling their bugs "features". (Almost)
>> It is true that it is *easier* to write obfuscated code in Perl <<
2/3 of the fools who enjoy insulting me wont even admit this.
If you disappear in the middle of the night, I will know why.
> If you worry about
> maintainability and readability, then Perl offers alternatives which can be
> used to construct nicely-written, well-documented code.
>
> On the other hand, if you are merely writing a quick script to hack some
> specific data, and reformat it into something human-readable (which is why
> Perl was invented in the first place), then maintainability is not an issue
> as you are (most likely) never ever going to use that same piece of code
> again. What is important in this case is the speed at which you code your
> script and the results it produces. From this point of view, I see no
> competitor to Perl. Did I mention that I see this as a feature in Perl??
I agree, but Perl is being used for non ad-hoc projects all the time.
>
> PS. Try writing a C/Java/Pascal program that simply substitutes all
> occurences of THIS to THAT in a file, only if the word 'Perl' occurs
> somewhere in the line. Compare that to the perl one-liner and you might just
> understand my point.
Reg.ex libraries can be attached to many languages, not just Perl.
Besides, there is more to life than parsing text.
>
> Ala
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>
-tmind-
http://www.geocities.com/SiliconValley/Lab/6888/langopts.htm
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 27 Jan 1999 17:29:06 -0800
From: Pero Maric <peromaric@yahoo.com>
Subject: Perl/Tk graphing module
Message-Id: <36AFBD61.AEF5B57C@yahoo.com>
I am trying to find out if a graphing module exists for Perl/Tk.
If so, I would be very grateful to be be pointed in the right
direction.
Many Thanks in advance.
------------------------------
Date: Thu, 28 Jan 1999 00:08:28 GMT
From: vishalb@my-dejanews.com
To: fooly@sztaki.hu
Subject: Re: perlcc problem (some compilled programs doesn't running)
Message-Id: <78o9pl$v5s$1@nnrp1.dejanews.com>
In article <36AE4A0C.F6E9D0E1@sztaki.hu>,
fooly@sztaki.hu wrote:
> Hi,
>
> I tried perlcc with a very simple script:
> ----------------------------
> #!/usr/bin/perl
> while(<>)
> {
> print $_;
> }
> ----------------------------
> The compillation (perlcc test.pl) was succesfull (without any warning or
> erorr), but when I started this compilled program with a parameter
> (example: test /etc/sendmail.cf) the program give me the following
> message:
> "Modification of a read-only value attempted at test.pl line 2."
> , but when I running the original perl script (without compilation) the
> progam runs ok.
>
> Does anybody knows this problem?
Yes, this could be caused by certain stack underflows in code generated by
CC.pm Fixes are in 5.005_54, but I advise you to wait till 5.005_55 (which
should be coming soon) because it would contain lots of more bug fixes.
Alternatively try the C backend.
> With the simplest script:
>
> #!/usr/bin/perl
> print "Hello World!\n";
>
> I didn't detected any problem.
>
> Additional information:
> Machine: HP vectra iP166MMX/64MB main memory
> OS version: RedHat linux 5.1
> perl version: perl-5.005_02-2
>
> Regards,
>
> Pal
>
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 27 Jan 1999 17:36:23 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: Request for negative value list indexes
Message-Id: <39hftcuyvs.fsf@ibnets.com>
>>>>> "MS" == Mike Stok <mike@stok.co.uk> writes:
BL> @ary = qw(A B C D E) $first = $ary[0]; @rest = @ary[2 .. -1]; #
BL> does NOT work, because -1 < 2
>>
>> .. is defined as an incrementing operation. so how could it handle 2 .. -1?
>>
>> to get what you want just use reverse as in:
>>
>> @ary[reverse -1 .. 2]
>> or
>> reverse @ary[-1 .. 2]
>>
>> so there is no need for a decrementing ..
MS> But Bart may have been lamenting that @array[2 .. -1] doesn't go
MS> from element 2 to the last element of the array, if you consider
MS> -1 as the rightmost element of the array then reverse @ary[-1
MS> .. 2] probably doesn't do what you want:
true for that answer. the first one should work fine.
MS> in python you can do something like array[2:] to go from array[2] to
MS> the last element of the array and array[2:-1] to go from array[2] to the
MS> element before the last.
so in perl you do:
@ary[2 .. $#ary]
@ary[2 .. $#ary - 1]
one place where python has syntactic sugar that perl doesn't. perl's
array slices just take a list, and not some special syntax. ask for this
on the p6p list.
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: Wed, 27 Jan 1999 17:19:02 -0600
From: Eric Estabrooks <estabroo@ispn.com>
Subject: Re: Safely editing /etc/passwd.
Message-Id: <36AF9EE6.B91F9B88@ispn.com>
Steve Vertigan wrote:
>
> jbritain@home.com wrote thus:
>
> >1. Copy the file, and work on the copy, not the original, make a
> >second copy, and save it to a date/time serialized file for backup.
>
> Is there any particular advantage to working on a backup? I like the idea
> of a serialized backup but the way I'd do it at the moment involves only two
> operations on /etc/passwd.
> 1) Read.
> 2) mv /etc/passwd2 /etc/passwd
> 2 will need to be performed in anycase but I can't see what can go wrong
> with 1.
>
> >2. Since it's only changing a password, the file character count
> >(size) should be exactly the same, and you can in fact "edit in place"
> >if the whole file will fit in memory at once.
>
> I must confess I don't understand what "edit in place" means. Could I be
> enlightened? :) Also I'm hoping to expand this to adding and removing users
> so there may be more substantial changes.
>
> >3. either with a cron job, do a weekly wipeout of old backups, (of
> >course this will depend upon number of changes/week, etc.) but it
> >leave you a fallback position. Save the backups root-owned, mod 0400.
>
> A good idea.
>
I have been working on a perl module that extends current operations on
the password file
getpwnam, ..., to include setpwinfo, modpwinfo, rmpwnam, mgetpwnam.
setpwinfo creates/modifies entries in the password file (and shadow if
it is used)
modpwinfo only modifies entries, gives an error if the entry doesn't
exist
rmpwnam removes entries from the password file
mgetpwam returns the output of getpwnam but doesn't include the
normally unused age and comment fields
Currently I have stuff working for Solaris and HPUX. Soon I'll have
access to a linux box. The modules right now are named
Password::Solaris and Password::HPUX, though that can be easily changed
if a more appropriate name space is proposed. I am also working on
Password::DB which uses a BerkeleyDB Hash file and provides the above
mentioned routines plus getpwnam, getpwuid, and usedb.
Any way, while working on this I found that the most important thing to
do when working on the password files is to use the systems password
locking system, usually the 'C' calls lckpwdf/ulckpwdf. This insures
that all of the systems programs that modify the password file will not
work with the file while you are modifying it.
Eric
estabroo@ispn.com
------------------------------
Date: 12 Dec 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 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 4764
**************************************