[16796] in Perl-Users-Digest
Perl-Users Digest, Issue: 4208 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 2 11:05:42 2000
Date: Sat, 2 Sep 2000 08:05:26 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <967907125-v9-i4208@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 2 Sep 2000 Volume: 9 Number: 4208
Today's topics:
Re: $LIST_SEPARATOR bug?? <flavell@mail.cern.ch>
Re: $LIST_SEPARATOR bug?? (Gwyn Judd)
Re: A logfile problem (Colin Keith)
Re: ActivePerl Install Failed (Colin Keith)
Re: Adding HTML to every page in a directory (Colin Keith)
Backslash usage? <reevehotNOSPAM@hotmail.com>
Re: Backslash usage? (Andrew J. Perrin)
Re: Backslash usage? (Colin Keith)
Re: Backslash usage? (Abigail)
Re: Changing Scripts from UNIX to NT <bart.lateur@skynet.be>
Re: coderef to object method? (Jakob Schmidt)
Re: coderef to object method? (Randal L. Schwartz)
Emacs modules for Perl programming (Jari Aalto+mail.perl)
Re: Help! my comma's are comma%27s <mahnke@uni-freiburg.de>
Re: Help! my comma's are comma%27s <flavell@mail.cern.ch>
Re: How long does flock take? <bart.lateur@skynet.be>
Re: how to use HTTP::Cookies <gisle@ActiveState.com>
Re: how to use HTTP::Cookies <dsa@dassda.com>
Re: how to use HTTP::Cookies (Mike Stok)
Re: list assignment to pre-existing hash (Colin Keith)
Re: LWP::Parallel joekind@my-deja.com
Parsing MySQL TEXT field <ales.romaniuk@zag.si>
Re: Parsing MySQL TEXT field (Colin Keith)
Regexp: Get the index of an alternative matched <abuse@localhost.com>
Re: Regexp: Get the index of an alternative matched (Jakob Schmidt)
script problems <nab$@hotmail.com>
Re: script problems <techsupp@helpconsulting.net>
Re: script problems <nab$@hotmail.com>
Re: script problems (Colin Keith)
What the joke, no host!? <tom@webign.co.uk>
Re: What the joke, no host!? <raphaelp@nr1webresource.com>
Re: What the joke, no host!? <techsupp@helpconsulting.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 2 Sep 2000 12:24:39 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: $LIST_SEPARATOR bug??
Message-Id: <Pine.GHP.4.21.0009021214460.19203-100000@hpplus03.cern.ch>
On Sat, 2 Sep 2000, Keith Calvert Ivey wrote:
(in a news posting tagged as iso-8859-1):
> I don't think you can blame Redmond for this one. Using `` for
> double quotes is a Unix thing, in my experience. Microsoft
> quoting would have been something like $^T
dollar caret T??
This seems to be the newsreader trying its best to display an 8-bit
control character (i.e not a displayable graphic) from your iso-8859-1
character coding.
Somehow I don't think you meant that. This is the kind of
misunderstanding that happens when people innocently paste the wrong
character coding into a document. Excuse me if I seem to be nagging,
but IMHO it's safer when trying to _discuss_ this kind of problem, to
take care not to fall into a similar trap oneself.
And on usenet you certainly cannot rely on your audience interpreting
charset=iso-8859-1 as if it meant Windows-1252, even if one's own
newsreader might be misbehaving in that way.
all the best, sorry about the pedantry
------------------------------
Date: Sat, 02 Sep 2000 13:32:44 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: $LIST_SEPARATOR bug??
Message-Id: <slrn8r20bq.mci.tjla@thislove.dyndns.org>
I was shocked! How could Alan J. Flavell <flavell@mail.cern.ch>
say such a terrible thing:
>On Sat, 2 Sep 2000, Keith Calvert Ivey wrote:
>
>(in a news posting tagged as iso-8859-1):
>
>> I don't think you can blame Redmond for this one. Using `` for
>> double quotes is a Unix thing, in my experience. Microsoft
>> quoting would have been something like $^T
>
>dollar caret T??
>
>This seems to be the newsreader trying its best to display an 8-bit
>control character (i.e not a displayable graphic) from your iso-8859-1
>character coding.
He *could* be referring to:
$^T The time at which the program began running, in
seconds since the epoch (beginning of 1970). The
values returned by the -M, -A, and -C filetests
are based on this value.
But I don't have the context to say for sure.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Fantasy is hardly an escape from reality. It's a way of understanding it.
-Lloyd Alexander, "The Prydain Chronicles"
------------------------------
Date: Sat, 02 Sep 2000 13:54:27 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: A logfile problem
Message-Id: <mE7s5.3254$%t6.360751@nnrp3.clara.net>
In article <39B17870@MailAndNews.com>, James <jamesmckay@MailAndNews.com> wrote:
>Hi All,
> Does anyone know of a way of sending all the output of a perl script
>to
>a file, without having to resort to specific open-write-close operations for
UNIX/DOS command interpretters allow the use of redirection of the standard
streams like stdout, so
make_cows_go_moo.pl > results
Would pipe anythign written to stdout into results.
If you don't have that, or don't want to rely on that:
close(STDOUT);
open(STDOUT, ">results");
Change to append, check return codes, use sysopen() as appropriate for the
needs of your script.
And of course STDERR and STDOUT are different variables that point to
different FH's so you'd need to close and redirect that if you wanted it to
catch STDERR stuff too..
Col. - YAY! I have returned from the barren wasteland known as recoding
someone else's crappy C programs to the love and warmth of c.l.p.misc:)
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Sat, 02 Sep 2000 14:02:55 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: ActivePerl Install Failed
Message-Id: <iM7s5.3279$%t6.360901@nnrp3.clara.net>
In article <8nubtq$rsa$1@nnrp1.deja.com>, sumera.shaozab@lmco.com wrote:
>Internal Error 2336. 5, C:\TEMP\MSI766.tmp
This is a windows error, flicking through knowledgebase articles it seems to
be something to do with access permissions to the temp directory. Many
programs seem to be able to generate it, so have a look at some of the
articles on http://search.microsoft.com/
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Sat, 02 Sep 2000 14:07:45 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: Adding HTML to every page in a directory
Message-Id: <QQ7s5.3291$%t6.361331@nnrp3.clara.net>
In article <K6Tr5.19$18.3407@news-west.eli.net>, "Michael Turitzin" <stevet@thevision.net> wrote:
>Is there a way to add a HTML header to every page in a certain directory?
>Like free hosting sites add a banner to the top of every page.
Yes, but its not a Perl related question as such as you can do it in just
about anything, sh, and C happily spring to mind. I would suggest you dig out
the 'perlfunc' man page and look at the opendir/readdir, rename and open
functions. Or you could try the PerlFAQ on "how to insert a line in the
middle of a file"
Better still you could tell your web server to serve each page with a standard
header/use a CGI script :)
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Sat, 2 Sep 2000 22:12:51 +1000
From: "James R" <reevehotNOSPAM@hotmail.com>
Subject: Backslash usage?
Message-Id: <0b5s5.7063$cr3.209944@ozemail.com.au>
I've been given some Perl script which runs on NT with Blat. My server host
says it is the best to use.
However, I notice this script has numerous uses of the backslash character
"\" which I've not seen or used in Perl before. Could anyone explain what it
does?
Example uses are:
$mail_to = "mailto:name\@host.com;
$mail_from = "blat\@" . lc($ENV{"SERVER_NAME"});
and
$\ = "\015\012";
\$cmd = $cmd
Running \`$cmd\`...
------------------------------
Date: 02 Sep 2000 10:13:35 -0400
From: aperrin@demog.berkeley.edu (Andrew J. Perrin)
Subject: Re: Backslash usage?
Message-Id: <ug0ninapc.fsf@demog.berkeley.edu>
You'll find the information in your online perldocs...
"James R" <reevehotNOSPAM@hotmail.com> writes:
> Example uses are:
> $mail_to = "mailto:name\@host.com;
escape the @ so it isn't assumed to be an array identifier. 'Course,
in this case, you could just use single quotes and not worry about it.
> $mail_from = "blat\@" . lc($ENV{"SERVER_NAME"});
ditto.
>
> and
>
> $\ = "\015\012";
Look in perldoc perlvar to see what $\ is. \xxx inserts characters
with the appropriate codes.
> \$cmd = $cmd
Wow. Put a reference to the value contained in the scalar $cmd into $cmd.
> Running \`$cmd\`...
See above about esaping special characters.
--
----------------------------------------------------------------------
Andrew Perrin - Solaris-Linux-NT-Samba-Perl-Access-Postgres Consulting
aperrin@igc.apc.org - http://demog.berkeley.edu/~aperrin
----------------------------------------------------------------------
------------------------------
Date: Sat, 02 Sep 2000 14:31:53 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: Backslash usage?
Message-Id: <sb8s5.3333$%t6.364316@nnrp3.clara.net>
In article <0b5s5.7063$cr3.209944@ozemail.com.au>, "James R" <reevehotNOSPAM@hotmail.com> wrote:
>"\" which I've not seen or used in Perl before. Could anyone explain what it
>does?
Context. Its all about context.
>Example uses are:
>$mail_to = "mailto:name\@host.com;
>$mail_from = "blat\@" . lc($ENV{"SERVER_NAME"});
In that case its to 'escape' the @ symbol so perl uses the ASCII character @
and doesn't try to replace it with the contents of the array @host. The simple
answer to this is to poke the person who wrote this in the tummy and tell them
that they're doing it wrong. By including text in double quotation marks
you're telling perl that it needs to look through for any variables and
replace them. In neither of the above examples do you have that, so the script
wastes resources by making perl check for things that aren't there.
$mail_to = 'mailto:name@host.com';
is perfectly adequate.
>
>and
>
>$\ = "\015\012";
\015 is an octal representation of an ASCII value. In this case its a way of
writing "\r\n" (CRLF). I believe its been used for platform independence, but
I don't remember why some platforms interpret \n and \r with different values
The $\ is the output record separator - the value stuffed at the end of a
print statement (see perldoc perlvar)
>\$cmd = $cmd
\$var is a reference
>Running \`$cmd\`...
escaping the ' to tell perl to print a literal character ', since its followed
by a scalar, I would imagine this is part of a double quoted string in which
case the \ is unnecessary:
maia% perl -w -Mstrict
$_ = 'mooo';
print "Cows go \'$_\'\n";
print "Cows go '$_'\n";
Cows go 'mooo'
Cows go 'mooo'
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: 02 Sep 2000 11:03:37 EDT
From: abigail@foad.org (Abigail)
Subject: Re: Backslash usage?
Message-Id: <slrn8r25kk.8ac.abigail@alexandra.foad.org>
Colin Keith (newsgroups@ckeith.clara.net) wrote on MMDLIX September
MCMXCIII in <URL:news:sb8s5.3333$%t6.364316@nnrp3.clara.net>:
// >
// >$\ = "\015\012";
//
// \015 is an octal representation of an ASCII value. In this case its a way of
// writing "\r\n" (CRLF). I believe its been used for platform independence, but
// I don't remember why some platforms interpret \n and \r with different values
Because different platforms use different byte sequences for line endings.
"\015\012" is CR LF, regardless of the platform. It is, however, *NOT*
"\r\n" everywhere. It's "\r\n" on *some* platforms.
You would use "\015\012" is the newline has to be "\015\012", for instance
many internet protocols use "\015\012" as the newline sequence. You would
use "\n" to get the newline that is used on the platform the program is
running on. That might be "\012", "\015", "\015\012" or even "".
Abigail
--
perl -we'$;=$";$;{Just=>another=>Perl=>Hacker=>}=$/;print%;'
------------------------------
Date: Sat, 02 Sep 2000 12:12:18 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Changing Scripts from UNIX to NT
Message-Id: <7br1rskg6bbfr5lrlnhad3ud4hrck72bog@4ax.com>
kenny9939@my-deja.com wrote:
>Does this mean that the traditional
>first line that points to perl (#!/usr/local/bin/perl) should be
>deleted?
No. But, it depends on the server software. Apache on Win32 *demands*
that the pah to the perl executable be valid. Your description of your
situation suggests to me that your ISP is not useing APache.
> How about paths to features like mail and date?
>($mailCmd= '/usr/sbin/sendmail';$dateCmd = '/bin/date';) Would these
>paths now need to be something like C:\usr\directory?
Oops. You've got problems there. There usually ARE NO eqauivalent
programs on NT, as the standard stuff for Unix. Therefore, your
dependency on external programs should better go. For example, instead
of the external program "sendmail", why not use one of the mailing
modules? Mail::Sendmail is a name that has been suggested already.
And it sure beats me why you insist on using an external program "date",
when you have the built-in primitives like localtime() at your disposal.
--
Bart.
------------------------------
Date: Sat, 2 Sep 2000 14:17:39 +0200
From: sumus@aut.dk (Jakob Schmidt)
Subject: Re: coderef to object method?
Message-Id: <1egc4xc.1tsafdq8p61koN@[192.168.88.117]>
Steve Leibel <stevel@bluetuna.com> wrote:
> So I want the syntax for
>
> $x->add_handler( reference to $self->coderef );
I experimented a bit with that a while ago and I don't think there is a
"syntax" which'll handle that. But you can get the effect thus:
use X;
use Y;
use strict;
my $x = X->new;
my $y1 = Y->new( "The initial one" );
my $y2 = Y->new( "The second one" );
my $y3 = Y->new( "The yet another one" );
$x->add_handler( $y1, \&Y::acknowledge );
$x->invoke;
print '- ' x 10, "\n";
$x->add_handler( $y2, \&Y::acknowledge );
$x->add_handler( $y3, \&Y::acknowledge );
$x->invoke;
print '- ' x 10, "\n";
###########
package X;
use strict;
sub new
{
my ( $this ) = @_;
my $class = ref($this) || $this;
my $self = { handlers => [ ] };
bless $self, $class;
}
sub add_handler
{
my ( $self, $object, $method ) = @_;
push @{ $self->{ handlers } }, [ $object, $method ];
}
sub invoke
{
my ( $self ) = @_;
for ( @{ $self->{ handlers } } ) { &{ $_->[ 1 ] }( $_->[ 0 ] ) }
}
1;
###########
package Y;
use strict;
sub new
{
my ( $this, $message ) = @_;
my $class = ref($this) || $this;
my $self = \$message;
bless $self, $class;
}
sub acknowledge
{
print "${ $_[ 0 ] }\n";
}
1;
Jakob
--
$if=sub{print$&if s].$]]s
}if$_=qq]$/rekcaH$"lreP$"rehtona$"tsuJ];{[eval'&
$if,'x25]}
------------------------------
Date: 02 Sep 2000 06:21:25 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: coderef to object method?
Message-Id: <m1n1hr0w16.fsf@halfdome.holdit.com>
>>>>> "Steve" == Steve Leibel <stevel@bluetuna.com> writes:
Steve> I looked in perldoc perlref and didn't see what I needed.
Steve> I'm using a class, call it X, that lets you register event handlers. My
Steve> event handlers are methods in a class that uses X.
Steve> So the add_handler method of X is looking for something like
Steve> my $x = new X;
Steve> $x->add_handler(\&coderef);
Steve> However in my application, coderef is a method in another
Steve> class, call it Y, that uses X. When the coderef is eventually
Steve> invoked I want it to be able to use the instance data of the Y
Steve> object. So I want the syntax for
Steve> $x->add_handler( reference to $self->coderef );
Steve> where $self is the instance of class Y that has instantiated X.
The most general form would be:
$x->add_handler(sub { $self->coderef() });
In other words, create an anon sub (actually a closure, presuming
you've done the right thing and made $self a lexical variable) to
perform the callback.
Unless you do that, you won't know to call the coderef from the X
object passing the now lost $self as the first parameter. Thankfully,
the closure captures that.
print "Just another Perl hacker,"
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 02 Sep 2000 11:05:05 GMT
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_967892648@rtfm.mit.edu>
Archive-name: perl-faq/emacs-lisp-modules
Posting-Frequency: 2 times a month
URL: http://home.eu.org/~jari/ema-keys.html
Maintainer: Jari Aalto <jari.aalto@poboxes.com>
Announcement: "What Emacs lisp modules can help with programming Perl"
Preface
Emacs is your friend if you have to do anything comcerning software
development: It offers plug-in modules, written in Emacs lisp
(elisp) language, that makes all your programmings wishes come
true. Please introduce yourself to Emacs and your programming era
will get a new light.
Where to find Emacs
XEmacs/Emacs, is available to various platforms:
o Unix:
If you don't have one, bust your sysadm.
http://www.gnu.org/software/emacs/emacs.html
http://www.xemacs.org/
Emacs resources at http://home.eu.org/~jari/emacs-elisp.html
o W9x/NT:
http://www.gnu.org/software/emacs/windows/ntemacs.html
Emacs Perl Modules
Cperl -- Perl programming mode
.ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl
.<olson@mcs.anl.gov> Bob Olson (started 1991)
.<ilya@math.ohio-state.edu> Ilya Zakharevich
Major mode for editing perl files. Forget the default
`perl-mode' that comes with Emacs, this is much better. Comes
starndard in newest Emacs.
TinyPerl -- Perl related utilities
.http://home.eu.org/~jari/tiny-tools-beta.zip
.http://home.eu.org/~jari/emacs-tiny-tools.html
If you ever wonder how to deal with Perl POD pages or how to find
documentation from all perl manpages, this package is for you.
Couple of keystrokes and all the documentaion is in your hands.
o Instant function help: See documentation of `shift', `pop'...
o Show Perl manual pages in *pod* buffer
o Load source code into Emacs, like Devel::DProf.pm
o Grep through all Perl manpages (.pod)
o Follow POD manpage references to next pod page with TinyUrl
o Coloured pod pages with `font-lock'
o Separate `tiperl-pod-view-mode' for jumping topics and pages
forward and backward in *pod* buffer.
o TinyUrl is used to jump to URLs (other pod pages, man pages etc)
mentioned in POD pages. (It's a general URL minor mode)
TinyIgrep -- Perl Code browsing and easy grepping
[TinyIgrep is included in the tgz mentioned above]
To grep from all installed Perl modules, define database to
TinyIgrep. There is example in the tgz (ema-tigr.ini) that shows
how to set up datatbases for Perl5, Perl4 whatever you have
installed
TinyIgrep calls Igrep.el to run the find for you, You can adjust
recursive grep options, ignored case, add user grep options.
You can get `igrep.el' module from <kevinr@ihs.com>. Ask for copy.
Check also ftp://ftp.ihs.com/pub/kevinr/
TinyCompile -- Browsing grep results in Emacs *compile* buffer
TinyCompile is minor mode for *compile* buffer from where
you can collapse unwanted lines, shorten the file URLs
/asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file1:NNN: MATCHED TEXT
/asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file2:NNN: MATCHED TEXT
-->
cd /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/
file1:NNN: MATCHED TEXT
file1:NNN: MATCHED TEXT
End
------------------------------
Date: Sat, 2 Sep 2000 14:28:57 +0100
From: "Christian Mahnke" <mahnke@uni-freiburg.de>
Subject: Re: Help! my comma's are comma%27s
Message-Id: <8oqrg1$rp1$1@news.online.de>
Okay, here is the code (you won't need CGI.pm anymore if you use this):
$yourvar =~ tr/+/ /; # pluses become spaces
$yourvar =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
Hope this helps,
Christian
perspiring goth <perspiring@nuts.com> schrieb in im Newsbeitrag:
39b0702e_2@news.newsfeeds.com...
> Thanks! But where does it go? (I'm very new at this!) I get this as a
> return:
>
> CGI::unescape(comma%27s)
>
>
> "Christian Mahnke" <mahnke@uni-freiburg.de> wrote in message
> news:8opidg$9di$1@news.online.de...
> > You have to decode it. Commas, semicolons and the like are encoded by
the
> > Browser.
> > Do it with "CGI::unescape($yourvar)".
> > If you don't need CGI for the rest of your program, just look up the
> > subroutine "unescape ()" in CGI.pm and use this.
> >
> > Cheers,
> >
> > Christian
> >
> >
> > perspiring goth <perspiring@nuts.com> schrieb in im Newsbeitrag:
> > 39b03f0f_2@news.newsfeeds.com...
> > > Form input won't print commas, semi-colons, etc... just %27s and the
> like.
> > > See for yourself at www.asd-1817.org/test.html.
> > >
> > > Any help would be truly appreciated. I'm just trying to do forms for a
> > > school intranet site.
> > >
> > > Thanks
> > >
> > >
> > >
> > >
> > > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> > > http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> > > -----== Over 80,000 Newsgroups - 16 Different Servers! =-----
> >
> >
>
>
>
>
> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: Sat, 2 Sep 2000 14:37:31 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Help! my comma's are comma%27s
Message-Id: <Pine.GHP.4.21.0009021435590.1247-100000@hpplus03.cern.ch>
On Sat, 2 Sep 2000, Christian Mahnke wrote:
> Okay, here is the code (you won't need CGI.pm anymore if you use this):
And why exactly would that represent a benefit?
Fortunately you posted in upside-down-fullquote style.
--
The new GIGOweb paradigm:
"Be profligate in what you send, uncritical in what you accept,
and bawl out anyone who tries to suggest different."
------------------------------
Date: Sat, 02 Sep 2000 12:28:18 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How long does flock take?
Message-Id: <hhs1rs821ge5ge51nlt1smqd52gfik1o6v@4ax.com>
Chris Stith wrote:
>I would rather think that a hash of the data would be preferable as a unique
>key. A CRC or an MD5 checksum might work better.
It depends on your idea of "unique". There is absolutely no garantee
that different data will yield a different CRC/hash value/MD5 checksum.
--
Bart.
------------------------------
Date: 02 Sep 2000 12:18:59 +0200
From: Gisle Aas <gisle@ActiveState.com>
Subject: Re: how to use HTTP::Cookies
Message-Id: <m37l8vksfg.fsf@eik.g.aas.no>
DT <dsa@dassda.com> writes:
> I tried:
>
> my $ua = new LWP::UserAgent;
> my $cookie_jar = new HTTP::Cookies;
> my $request = new HTTP::Request('GET', $url, $h);
> :
> :
> $response = $ua->request($request);
> $cookie_jar->extract_cookies($response);
>
> extrac_cookies doesn't work
What happens? What headers did the response have?
--
Gisle Aas
------------------------------
Date: Sat, 2 Sep 2000 21:55:34 +0800
From: DT <dsa@dassda.com>
Subject: Re: how to use HTTP::Cookies
Message-Id: <MPG.141b87b22a5a405989685@news.cyberway.com.sg>
when I print "$cookie_jar", I got: HTTP::Cookies=HASH(0xbba9c8)
In article <m37l8vksfg.fsf@eik.g.aas.no>, gisle@ActiveState.com says...
> DT <dsa@dassda.com> writes:
>
> > I tried:
> >
> > my $ua = new LWP::UserAgent;
> > my $cookie_jar = new HTTP::Cookies;
> > my $request = new HTTP::Request('GET', $url, $h);
> > :
> > :
> > $response = $ua->request($request);
> > $cookie_jar->extract_cookies($response);
> >
> > extrac_cookies doesn't work
>
> What happens? What headers did the response have?
>
>
------------------------------
Date: Sat, 02 Sep 2000 14:30:19 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: how to use HTTP::Cookies
Message-Id: <%98s5.24938$C5.493548@typhoon.austin.rr.com>
In article <MPG.141b87b22a5a405989685@news.cyberway.com.sg>,
DT <dsa@dassda.com> wrote:
>when I print "$cookie_jar", I got: HTTP::Cookies=HASH(0xbba9c8)
Have you tried
perldoc HTTP::Cookies
to see what methods you can use on your cookie jar?
Maybe print $cookie_jar->as_string would be more useful, or the scan
method might let you examine the cookies more usefully.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ |
GPG PGP Key 1024D/059913DA | Fingerprint 0570 71CD 6790 7C28 3D60
stok@colltech.com (CT - work) | 75D2 9EC4 C1C0 0599 13DA
------------------------------
Date: Sat, 02 Sep 2000 14:57:13 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: list assignment to pre-existing hash
Message-Id: <cz8s5.3355$%t6.366775@nnrp3.clara.net>
In article <36Zr5.8723$Jq2.17024@dfw-read.news.verio.net>, "lds" <lds@i-55.com> wrote:
>Now my question is this, does assigning a list to a pre-existing hash
>delete, destroy, or otherwise corrupt the key/value pairs already stored in the
>hash?
*exterminate* *exterminate* :)
It discards the old contents and creates it afresh with the new details, same
as any assignation.
$_ = 2;
$_ = 3;
print;
To demonstrate this in you exact case:
maia% perl -w -Mstrict
my(%hash) = (A=>1, B=>2, C=>3);
my(@arr) = (A=>10, B=>10, D=>40);
%hash = @arr;
print "Key: Val:\n";
print " $_ $hash{$_}\n" for(keys(%hash));
Key: Val:
A 10
B 10
D 40
>I am assuming that none of the list values would create key names that
>already exist. If the list values would create a key name already present in
>the hash
nononono, it all goes kabloey, but you can fake all of this using the
following fix:
%hash = (%hash, @arr);
And of course this allows the array of values to overwrite the exist values
for a key or create a new entry, so:
Key: Val:
A 10
B 10
C 3
D 40
The other way around, (@arr, %hash) results in the creation of new key-val
pairs for anything in @arr, but retaining the values in %hash. You could use
in a situation where you wanted to have a set of values that must be present,
predefined in %hash, but allow a user to define additional values. In the
(%hash, @arr) option their values take precidence, but the defaults are used
for anything they don't set. In the (@arr, %hash) form, anything they supply
in addition the default values is added, but the default values are retained.
> ~ just another perl newbie
Yay another one for the light side of the force:)
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Sat, 02 Sep 2000 13:50:19 GMT
From: joekind@my-deja.com
Subject: Re: LWP::Parallel
Message-Id: <8or0io$ftv$1@nnrp1.deja.com>
The main thing I need to know is when to call each sub routine and
where to call them.
In article <8op64h$ht8$1@nnrp1.deja.com>,
joekind@my-deja.com wrote:
> Hi again. I fixed that problem by just taking out the use strict;
> line. The code you have provided me so far is great and I really
> appreciate your help, but I am still having a lot of trouble
> understanding things because I do not know which variables do what and
> which subs to call when. So if you want to help me out more, you
could
> just email me more of your code to kindness@sympatico.ca, it would
help
> out a lot. I have been working off and on with this speed problem for
> over half a year and if this code can help me, then all of my
> fustrations will float away.
>
> Thanks, Joey.
>
> In article <8op248$ct9$1@nnrp1.deja.com>,
> joekind@my-deja.com wrote:
> > Thanks a lot for this code. but I got a few errors for some of the
> > variables because it said require explicite package, so I put "my"
> > infront of those variables. but when I try to put "my" infront of:
> > $handle2eng{$handle} = $eng_ref ;
> > it gives me a error. how can I get around this?
> >
> > In article <x7g0nkouhj.fsf@home.sysarch.com>,
> > Uri Guttman <uri@sysarch.com> wrote:
> > > >>>>> "j" == joekind <joekind@my-deja.com> writes:
> > >
> > > j> I have tried using forking too but I could not get the
program
> > to wait
> > > j> until it had got all of the content from the sites. How did
> you
> > get
> > > j> yours to wait and how fast was did your program get the
> > content? Any
> > > j> code that you may have will help greatly.
> > >
> > > i butchered out the relevent parts to a meta search script i
wrote.
> > this
> > > will not compile/run as is and it has no driving code. but it
should
> > be
> > > very easy to get running. the part where it reads from the search
> > > engines will need hacking to suit your needs. my needs were very
> > simple
> > > as this was mostly a proof of concept.
> > >
> > > uri
> > >
> > > #!/home/uri/bin/perl -w
> > >
> > > $| = 1 ;
> > >
> > > use Symbol ;
> > > use IO::Select ;
> > > use LWP::Simple qw( $ua get ) ;
> > >
> > > use strict ;
> > >
> > > sub fork_engines {
> > >
> > > my( $handle, $eng_ref ) ;
> > >
> > > # prepare to read the children's results in parallel
> > >
> > > $io_select = IO::Select->new( ) ;
> > >
> > > # loop over all the search engines
> > >
> > > foreach $eng_ref ( @engine_info ) {
> > >
> > > # get a new file handle
> > >
> > > $handle = gensym ;
> > >
> > > # fork a child process. its STDOUT is connected to this handle in
> the
> > parent.
> > >
> > > if ( open( $handle, '-|' ) ) {
> > >
> > > # in parent: save the handle and make a reverse lookup table
> > > # so we can go from the handle back to the engine entry.
> > > # then add the handle to the io select object
> > >
> > > $eng_ref->{'handle'} = $handle ;
> > > $handle2eng{ $handle } = $eng_ref ;
> > >
> > > $io_select->add( $handle ) ;
> > >
> > > next ;
> > > }
> > >
> > > # in child - never returns - execute a search on a real engine
> > >
> > > child_engine( $eng_ref ) ;
> > > }
> > > }
> > >
> > > # read the hit results from the children
> > >
> > > sub read_engines {
> > >
> > > my( @read_handles, $eng_name, $handle, $hit, $hit_count ) ;
> > >
> > > # slurp hist results in paragraph mode
> > >
> > > local( $/ ) = '' ;
> > >
> > > $hit_count = 0 ;
> > >
> > > # loop while we still have children to read or until we timeout
> > >
> > > HIT:
> > > while ( @read_handles = $io_select->can_read( 10 ) ) {
> > >
> > > #print "read @read_handles\n" ;
> > >
> > > # loop over the handles we can read
> > >
> > > foreach $handle ( @read_handles ) {
> > >
> > > # get the engine name from the handle
> > > # in the future, there may be more stuff in the engine structure
> than
> > the name
> > >
> > > $eng_name = $handle2eng{ $handle }->{'name'} ;
> > >
> > > # print "\n\t$eng_name\n" ;
> > >
> > > # read the hit
> > >
> > > $hit = <$handle> ;
> > >
> > > # see if we actually read one (could be eof)
> > >
> > > if ( $hit ) {
> > >
> > > # stop reading hits if this was a good hit and we have seen enough
> > >
> > > last HIT if hit2html( $hit ) &&
> > > ++$hit_count >= $max_hits ;
> > > }
> > > else {
> > >
> > > # the child is dead, remove its handle and close it
> > >
> > > $io_select->remove( $handle ) ;
> > > close $handle ;
> > > }
> > > }
> > > }
> > > }
> > >
> > > # this code is run in each child process.
> > >
> > > sub child_engine {
> > >
> > > my( $eng_ref ) = @_ ;
> > >
> > > my( $eng_name, $search, $result, $query_text ) ;
> > >
> > > # get the engine name and a search object
> > >
> > > $eng_name = $eng_ref->{'name'} ;
> > > $search = WWW::Search->new( $eng_name ) ;
> > >
> > > die "bad engine $eng_name\n" && next unless $search ;
> > >
> > > # print "$$ $eng_name\n" ;
> > >
> > > # build the query for the engine. require all the terms.
> > > # this may become a perl engine query generator. the @engine_info
> > > # structure would contain a sub ref to the engine specific query
> > > # maker.
> > >
> > > $query_text = join( ' ', map "+$_", @query_terms ) ;
> > >
> > > # start the search
> > >
> > > $search->native_query( WWW::Search::escape_query(
> > $query_text ) ) ;
> > >
> > > # timeout the fetches of the actual pages
> > >
> > > $ua->timeout( 2 ) ;
> > >
> > > # loop over how many hits per engine
> > >
> > > for ( 1 .. $max_engine_hits ) {
> > >
> > > # get a search result (hit)
> > >
> > > last unless $result = $search->next_result() ;
> > >
> > > # send that hit back to the parent process
> > >
> > > send_hit_info( $result->url ) ;
> > > }
> > >
> > > # child dies ;
> > >
> > > exit( 0 ) ;
> > > }
> > >
> > > BEGIN {
> > >
> > > @engine_info = (
> > >
> > > {
> > > 'name' => 'AltaVista',
> > > },
> > > {
> > > 'name' => 'NorthernLight',
> > > },
> > > {
> > > 'name' => 'Infoseek',
> > > },
> > > {
> > > 'name' => 'Lycos',
> > > },
> > > ) ;
> > >
> > > }
> > >
> > > --
> > > Uri Guttman --------- uri@sysarch.com ----------
> > http://www.sysarch.com
> > > SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX
> > Consulting
> > > The Perl Books Page ----------- http://www.sysarch.com/cgi-
> > bin/perl_books
> > > The Best Search Engine on the Net ----------
> > http://www.northernlight.com
> > >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
> >
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 2 Sep 2000 12:13:29 +0200
From: Marvin <ales.romaniuk@zag.si>
Subject: Parsing MySQL TEXT field
Message-Id: <MPG.141af11c4d4ee4f8989684@news.siol.net>
Hi !
I am using MySQL as a database in Perl.
In TEXT field I have several lines, like
===================
Line1
Line2
Line3
===================
When I pull this field into variable, and watch its value in DEBUG, I
can see this:
Line1\cM\cJLine2\cM\JLine3\cM\cJ
which seems to be CR/LF fields.
If I watch line by line made by split "\n",@TEXTFIELD), I can see
Line1\cM
Line2\cM
Line3\cM
with no \cJ fields.
How can I strip TEXT fields and put them into an ARRAY with the split
command ?
(Also split("\c",@TEXTFIELD) won't work)
Thanks
------------------------------
Date: Sat, 02 Sep 2000 14:18:26 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: Parsing MySQL TEXT field
Message-Id: <R_7s5.3309$%t6.363162@nnrp3.clara.net>
In article <MPG.141af11c4d4ee4f8989684@news.siol.net>, Marvin <ales.romaniuk@zag.si> wrote:
>How can I strip TEXT fields and put them into an ARRAY with the split
>command ?
split on \r\n instead of just \n
But better would be:
$/ = "\r\n"; @TEXTFIELD = <FH>;
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Sat, 2 Sep 2000 20:38:43 +0800
From: "multiplexor" <abuse@localhost.com>
Subject: Regexp: Get the index of an alternative matched
Message-Id: <8oqs0g$a61$2@horn.hk.diyixian.com>
For example:
####
$_ = 'ABCDE';
s/(B|C|D)/
my $id;
$id = 0 if ($1 eq 'B');
$id = 1 if ($1 eq 'C');
$id = 2 if ($1 eq 'D');
/e;
####
Does Perl have any function or special variable that can give me the index
of an alternative matched? If so, I wouldn't need to check again in the
regexp, but I can have an array which works with the index and give me B, C
or D.
------------------------------
Date: Sat, 2 Sep 2000 14:37:33 +0200
From: sumus@aut.dk (Jakob Schmidt)
Subject: Re: Regexp: Get the index of an alternative matched
Message-Id: <1egc5u1.1fn31gxgcch03N@[192.168.88.117]>
multiplexor <abuse@localhost.com> wrote:
> $_ = 'ABCDE';
> s/(B|C|D)/
> my $id;
> $id = 0 if ($1 eq 'B');
> $id = 1 if ($1 eq 'C');
> $id = 2 if ($1 eq 'D');
> /e;
> ####
>
> Does Perl have any function or special variable that can give me the index
> of an alternative matched?
I don't think so. I'd do
$_ = 'ABCDE';
my %lookup = ( B => 0, C => 1, D => 2 );
s/(B|C|D)/$lookup{ $1 }/;
Jakob
--
package p;sub TIESCALAR{shift;shift&&print tie$p,p,@_;shift};
tie$p,p,p,p,split//=>"\nrekcaH lreP rehtona tsuJ";
------------------------------
Date: Sat, 2 Sep 2000 14:17:22 -0700
From: "Nabonida$" <nab$@hotmail.com>
Subject: script problems
Message-Id: <j%6s5.31229$rq2.29852@news2-hme0>
every time i try to run one of my scripts i get a the "do you want to
download this file" message box. the permissions are correct, using post
from a form.
never had this problem with any of my other scripts.
can anyone help me.
Nab$
------------------------------
Date: Sat, 2 Sep 2000 09:52:32 -0400
From: "Ken" <techsupp@helpconsulting.net>
Subject: Re: script problems
Message-Id: <BA7s5.1854$H97.61@interramp>
Most of my experience with this type of problem has been on Windows based
servers that don't support PERL. They don't parse the .cgi or .pl as a
script that should be executed and therefore think it is just another file
to be downloaded.
If you use Perl scripts on this server elsewhere you may want to double
check the directory permissions along with the file itself.
Cheers!
Ken
http://www.helpconsulting.net
Home of;
visiPerl+ - The Ultimate Perl IDE
OfficeTalk - How do you talk in your office?
"Nabonida$" <nab$@hotmail.com> wrote in message
news:j%6s5.31229$rq2.29852@news2-hme0...
> every time i try to run one of my scripts i get a the "do you want to
> download this file" message box. the permissions are correct, using post
> from a form.
> never had this problem with any of my other scripts.
> can anyone help me.
> Nab$
>
>
------------------------------
Date: Sat, 2 Sep 2000 15:30:13 -0700
From: "Nabonida$" <nab$@hotmail.com>
Subject: Re: script problems
Message-Id: <E38s5.31244$rq2.30307@news2-hme0>
thanx
no the permissions are ok.
i have bin trying to get the script to work for ages. but this problem has
only just started. before i just got error 500 stuff.
Nab$
Ken <techsupp@helpconsulting.net> wrote in message
news:BA7s5.1854$H97.61@interramp...
> Most of my experience with this type of problem has been on Windows based
> servers that don't support PERL. They don't parse the .cgi or .pl as a
> script that should be executed and therefore think it is just another file
> to be downloaded.
>
> If you use Perl scripts on this server elsewhere you may want to double
> check the directory permissions along with the file itself.
>
> Cheers!
> Ken
>
> http://www.helpconsulting.net
> Home of;
> visiPerl+ - The Ultimate Perl IDE
> OfficeTalk - How do you talk in your office?
>
------------------------------
Date: Sat, 02 Sep 2000 14:41:14 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: script problems
Message-Id: <dk8s5.3344$%t6.365342@nnrp3.clara.net>
In article <j%6s5.31229$rq2.29852@news2-hme0>, "Nabonida$" <nab$@hotmail.com> wrote:
>every time i try to run one of my scripts i get a the "do you want to
>download this file" message box. the permissions are correct, using post
>from a form.
>never had this problem with any of my other scripts.
>can anyone help me.
Written in Perl or not, this is a CGI question, the fiendly.... er friendly
people in the CGI newsgroups comp.infosystems.www.* will be able to help you
far more easily. It would also help if you provide more information besides
"one of my scripts". I would suspect its a mime type problem given that you've
posted with OE and so are probably using IE and IE behaves strangely with
mime types and file extensions that differ. Still ...
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Sat, 2 Sep 2000 13:00:55 +0100
From: "Tom Fotheringham" <tom@webign.co.uk>
Subject: What the joke, no host!?
Message-Id: <8oqq94$4o1$1@uranium.btinternet.com>
I love it, but I need to love it more. What I really want is to get some
Perl powered web sites up on the web.
Can somebody please tell me where I can get free CGI-BIN hosting. I know
theres one in the UK somewhere and that its linux based but I can remember
where I read it.
Thanks
Tom F
------------------------------
Date: Sat, 2 Sep 2000 14:50:07 +0200
From: "Raphael Pirker" <raphaelp@nr1webresource.com>
Subject: Re: What the joke, no host!?
Message-Id: <8oqsvh$rbf$12$1@news.t-online.com>
www.virtualave.net
------------------------------
Date: Sat, 2 Sep 2000 10:01:36 -0400
From: "Ken" <techsupp@helpconsulting.net>
Subject: Re: What the joke, no host!?
Message-Id: <7J7s5.2514$H97.43@interramp>
Here's a few to try;
http://free.prohosting.com - 50megs / CGI-SSI / 1 FTP account
and for a complete 'Large' listing/review go here;
http://www.fwpreview.ngworld.net/fwp/personal3.html
Hope this helps.
Cheers!
Ken
http://www.helpconsulting.net
Home of;
visiPerl+ 2.0 - The Ultimate Perl IDE
OfficeTalk - How do you talk in your office?
"Tom Fotheringham" <tom@webign.co.uk> wrote in message
news:8oqq94$4o1$1@uranium.btinternet.com...
> I love it, but I need to love it more. What I really want is to get some
> Perl powered web sites up on the web.
>
> Can somebody please tell me where I can get free CGI-BIN hosting. I know
> theres one in the UK somewhere and that its linux based but I can remember
> where I read it.
>
> Thanks
> Tom F
>
>
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 4208
**************************************