[13410] in Perl-Users-Digest
Perl-Users Digest, Issue: 820 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 16 15:07:22 1999
Date: Thu, 16 Sep 1999 12:05:13 -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: <937508713-v9-i820@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 16 Sep 1999 Volume: 9 Number: 820
Today's topics:
Re: [Help] Problem with AuthCookie on Apache Server (Kragen Sitaker)
DBD::Sybase not testing correct - help sparky21@my-deja.com
Diff of string arrays. <andrew_cragg@csi.com>
Re: Diff of string arrays. <andrew_cragg@csi.com>
Help with a regular expression <k.thomson@scet.com>
Re: Help with a regular expression <koharik@primenet.com>
Re: Help with a regular expression <emschwar@rmi.net>
Re: Help with a regular expression (Kragen Sitaker)
How to assign filehandle to scalar? <bomr@lin01.triumf.ca>
How to direct output to /dev/speech <yngwie@home.com>
Re: How to direct output to /dev/speech (Kragen Sitaker)
Re: how to produce a 'beep'? (Larry Rosler)
Re: Installing Tk module failed. Please help. <zzhang@bayou.uh.edu>
Making Tk the Top <sridharg@interra.com>
Re: need to write www search engine <channel@metalab.unc.edu>
Re: Output pipes to a browser <makkulka@cisco.com>
Re: Parsing Tab Delimited File (Kragen Sitaker)
Re: Parsing Tab Delimited File (Kragen Sitaker)
Question on Hash of Hash namnan@my-deja.com
Question on Hash of Hash namnan@my-deja.com
Re: Question on Hash of Hash (Larry Rosler)
references in dbms <todds@infotraxsys.com>
Re: references in dbms (Kragen Sitaker)
Re: REQ: tell-a-friend script chetohevia@my-deja.com
Re: REQ: tell-a-friend script <flavell@mail.cern.ch>
Some e-mails get sent, some don't (Greg Miller)
Re: Some e-mails get sent, some don't (Kragen Sitaker)
Re: Threads question <dan@tuatha.sidhe.org>
Re: trimming spaces from a string (Kragen Sitaker)
Where do I get perl2exe for Win32? <andrew_cragg@csi.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 16 Sep 1999 18:40:02 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: [Help] Problem with AuthCookie on Apache Server
Message-Id: <6QaE3.14803$N77.1098862@typ11.nn.bcandid.com>
In article <Ox591NGA$GA.275@cpmsnbbsa03>,
Nguyen Nguyen <nguyen.nguyen@infosoft-consulting.com> wrote:
>I am trying to setup AuthCookie to work with
>our Apache server. The AuthCookie comes
>with a sample script called "login.pl". In that
>script, it has a line of
>
>my $r = Apache->request;
>
>which produces the following error message in the
>Apache error log file:
How are you running the script? I think this is a mod_perl script
(with no justification except for a hunch, as I haven't used
mod_perl).
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Thu Sep 16 1999
53 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Thu, 16 Sep 1999 17:29:04 GMT
From: sparky21@my-deja.com
Subject: DBD::Sybase not testing correct - help
Message-Id: <7rr9ce$la4$1@nnrp1.deja.com>
The make works, but when I do the make test I get:
Running make test
PERL_DL_NONLAZY=1 /usr/local/bin/perl -Iblib/arch -Iblib/lib
-I/usr/local/lib/perl5/5.00502/sun4-solaris
-I/usr/local/lib/perl5/5.00502 -e 'use Test::Harness qw(&runtests
$verbose); $verbose=0; runtests @ARGV;' t/*.t
t/autocommit........install_driver(Sybase) failed: Panic: clientmsg_cb:
Can't find handle from connection at
/usr/local/lib/perl5/5.00502/sun4-solaris/DynaLoader.pm line 187.
at t/autocommit.t line 40
dubious
Test returned status 2 (wstat 512, 0x200)
DIED. FAILED tests 2-4
Failed 3/4 tests, 25.00% okay
t/base..............install_driver(Sybase) failed: Panic: clientmsg_cb:
Can't find handle from connection at
/usr/local/lib/perl5/5.00502/sun4-solaris/DynaLoader.pm line 187.
at t/base.t line 18
dubious
Test returned status 2 (wstat 512, 0x200)
Undefined subroutine &Test::Harness::WCOREDUMP called at
/usr/local/lib/perl5/5.00502/Test/Harness.pm line 288.
*** Error code 2
make: Fatal error: Command failed for target `test_dynamic'
/usr/ccs/bin/make test -- NOT OK
Running make install
make test had returned bad status, won't install without force
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 16 Sep 1999 18:46:32 +0100
From: "Andy Cragg" <andrew_cragg@csi.com>
Subject: Diff of string arrays.
Message-Id: <7rraat$gpo$1@ssauraab-i-1.production.compuserve.com>
hi,
Anyone know how to do a quick comparison between two arrays (of strings) and
return the differences in another array? Perhaps using cmp?
Thanks in anticipation ...
Andy
------------------------------
Date: Thu, 16 Sep 1999 19:04:15 +0100
From: "Andy Cragg" <andrew_cragg@csi.com>
Subject: Re: Diff of string arrays.
Message-Id: <7rrbdf$h72$1@ssauraab-i-1.production.compuserve.com>
Doh! It's in the FAQ
(http://www.perl.com/CPAN/doc/FAQs/FAQ/PerlFAQ.html#How_do_I_compute_the_dif
erence_)
Sorry.
Let this be a lesson to you all :{
Andy
------------------------------
Date: Thu, 16 Sep 1999 18:21:05 +0100
From: "Kevin Thomson" <k.thomson@scet.com>
Subject: Help with a regular expression
Message-Id: <7rr8in$5mq$1@nclient7-gui.server.ntli.net>
Is their a perl guru out their that can help me?
I have a number of files which have directory refernces in them like so
img src="nl/dir1/dir2/image.gif
img src="/dir1/image2.gif
img src="nl/dir2/image.gif
you get the idea
i need a regular expression whcih will go through the file and substitute
img src"/$mydir/image.gif for each of these references regardless of how
many dir (/) slashes they have.
I tried
$_ =~ s/[sS][Rr][Cc]\=\"[\/|.]*[.]*\//src\=\"$graphics_directory/gm;
where graphics dir is the directory I want all the references to point to.
it works with
/graphics.gif
but not with
dir1/graphics.gif
or
/dir1/dir2/graphics.gif
can you help please
Much abliged kevin.
------------------------------
Date: Thu, 16 Sep 1999 10:36:56 -0700
From: Chris Koharik <koharik@primenet.com>
Subject: Re: Help with a regular expression
Message-Id: <Pine.BSI.3.96.990916102741.19323C-100000@usr05.primenet.com>
> Date: Thu, 16 Sep 1999 18:21:05 +0100
> From: Kevin Thomson <k.thomson@scet.com>
>
> Is their a perl guru out their that can help me?
No guru here, as I'm sure other will attest to.
> I have a number of files which have directory refernces in them like so
>
> img src="nl/dir1/dir2/image.gif
> img src="/dir1/image2.gif
> img src="nl/dir2/image.gif
>
> you get the idea
>
> i need a regular expression whcih will go through the file and substitute
>
> img src"/$mydir/image.gif for each of these references regardless of how
> many dir (/) slashes they have.
>
> I tried
>
> $_ =~ s/[sS][Rr][Cc]\=\"[\/|.]*[.]*\//src\=\"$graphics_directory/gm;
Here is a little test script I tried. I'm sure the others out there have
better suggestions.
#!/bin/perl -w
use strict;
my $string1 = "img src=\"/dir1/graphic.gif\"";
my $string2 = "img src=\"http://www.server.com/dir1/dir2/graphic.gif\"";
my @strings = (${string1},${string2});
my $newsrc = "img src=\"/src_dir/";
foreach (@strings) {
print STDOUT "$_\n";
$_ =~ s/.*\//$newsrc/;
print STDOUT "$_\n";
}
HTH
-Chris
------------------------------
Date: 16 Sep 1999 12:17:24 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Help with a regular expression
Message-Id: <xkflna6k9fv.fsf@valdemar.col.hp.com>
"Kevin Thomson" <k.thomson@scet.com> writes:
> I have a number of files which have directory refernces in them like so
>
> img src="nl/dir1/dir2/image.gif
> img src="/dir1/image2.gif
> img src="nl/dir2/image.gif
>
> you get the idea
>
> i need a regular expression whcih will go through the file and substitute
> img src"/$mydir/image.gif for each of these references regardless of how
> many dir (/) slashes they have.
No, you don't. <waves his magic wand>You're trying to use a regex to
parse HTML, which is a bad idea, and just plain won't work. HTML::Parser
is the current favourite way to do this, but you can also use an SGML
parser with the appropriate DTD, if you feel like being even more
pedantic (and who doesn't, these days?).
Attempting to parse HTML with a regex is like combing your hair with a
balloon. Sure, it'll probably work (eventually), but it's generally a
waste of time and effort.
-=Eric
------------------------------
Date: Thu, 16 Sep 1999 18:48:32 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Help with a regular expression
Message-Id: <4YaE3.14810$N77.1099525@typ11.nn.bcandid.com>
In article <Pine.BSI.3.96.990916102741.19323C-100000@usr05.primenet.com>,
Chris Koharik <koharik@primenet.com> wrote:
>Here is a little test script I tried. I'm sure the others out there have
>better suggestions.
Good regex. Let me comment on your script, as others have done on
mine, so people will know what not to emulate.
>#!/bin/perl -w
>use strict;
Good!
>my $string1 = "img src=\"/dir1/graphic.gif\"";
>my $string2 = "img src=\"http://www.server.com/dir1/dir2/graphic.gif\"";
>my @strings = (${string1},${string2});
Easier:
my @strings = (
q(img src="/dir1/graphic.gif"),
q(img src="http://www.example.com/dir1/dir2/graphic.gif")
);
>foreach (@strings) {
> print STDOUT "$_\n";
You can just say print "$_\n", or print $_, "\n" if you like.
> $_ =~ s/.*\//$newsrc/;
s/// operates on $_ by default; no need for the $_ =~.
Very nice script, though. It uses strict and -w, and appears to have
been tested :)
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Thu Sep 16 1999
53 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 16 Sep 1999 18:54:26 GMT
From: "Rod B. Nussbaumer" <bomr@lin01.triumf.ca>
Subject: How to assign filehandle to scalar?
Message-Id: <7rred2$fav$1@nntp.itservices.ubc.ca>
perl Gurus:
I have a need to read data from a file, and according to
flags embedded within the file, copy said data to any of
an arbitrary number of files. The data stream should be
directed to a 'current' output file, until a flag is
detected to re-route to a different (open) file.
My test code won't compile, and I guess I don't grasp
some fundamental concept here, despite considerable research
in the Camel book, and past postings here. Enclosed is
the sample code, annotated with the compiler error meessages.
Enlighten me, please.
--------<code starts here>---------
#! /bin/perl -w
use strict;
my (
$FileName1,
$FileName2,
$FileName3,
$OutFile
);
$FileName1 = "File1.txt";
$FileName2 = "File2.txt";
$FileName3 = "File3.txt";
open( FH1, ">$FileName1" ) || die "Err 1 : $!\n";
open( FH2, ">$FileName2" ) || die "Err 2 : $!\n";
open( FH3, ">$FileName3" ) || die "Err 3 : $!\n";
$OutFile = FH1; # start writing to File1.txt
while( <> ){
if( /Flag1/ ){
$OutFile = FH1; #Switch back to File1
next;
}
elsif( /Flag2/ ){
$OutFile = FH2; #Switch back to File2
next;
}
elsif( /Flag3/ ){
$OutFile = FH3; #Switch back to File3
next;
}
print $OutFile $_; # write 'current' file
}
close FH1;
close FH2;
close FH3;
# Bareword "FH1" not allowed while "strict subs" in use at test1.pl line 20.
# Bareword "FH1" not allowed while "strict subs" in use at test1.pl line 26.
# Bareword "FH2" not allowed while "strict subs" in use at test1.pl line 30.
# Bareword "FH3" not allowed while "strict subs" in use at test1.pl line 34.
# Execution of test1.pl aborted due to compilation errors.
Thanks,
--- rod.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Rod Nussbaumer, Programmer/Technologist Internet: bomr@triumf.ca
TRIUMF --- University of British Columbia, Phone: (604)222-7449
Vancouver, BC, Canada. FAX: (604)222-7307
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Thu, 16 Sep 1999 18:47:35 GMT
From: David <yngwie@home.com>
Subject: How to direct output to /dev/speech
Message-Id: <37E13ACD.530102BF@home.com>
When is the correct format for redirecting a variable's contents to
/dev/speech? or a sound file to /dev/audio?
------------------------------
Date: Thu, 16 Sep 1999 19:01:32 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: How to direct output to /dev/speech
Message-Id: <g8bE3.14821$N77.1101218@typ11.nn.bcandid.com>
In article <37E13ACD.530102BF@home.com>, David <yngwie@home.com> wrote:
>When is the correct format for redirecting a variable's contents to
>/dev/speech? or a sound file to /dev/audio?
Open the device and print the variable to the filehandle.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Thu Sep 16 1999
53 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Thu, 16 Sep 1999 10:56:17 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: how to produce a 'beep'?
Message-Id: <MPG.124acf1ba4af38da989f91@nntp.hpl.hp.com>
In article <37e12291@cs.colorado.edu> on 16 Sep 1999 11:02:09 -0700, Tom
Christiansen <tchrist@mox.perl.com> says...
> In comp.lang.perl.misc,
> Nick Lee <leenick@interchange.ubc.ca> writes:
> :I guess the title explains itself. My question is: how to produce a
> :beep from a perl program?
>
> use Curses;
> initscr();
> beep();
> endwin();
It might be simpler (and more portable?) first to try:
print "\a";
Or perhaps "\a\n" or whatever it takes to flush the output immediately.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 16 Sep 1999 13:16:14 -0500
From: "zzhang" <zzhang@bayou.uh.edu>
Subject: Re: Installing Tk module failed. Please help.
Message-Id: <7rrc33$f13$1@Masala.CC.UH.EDU>
Hello everyone. The problem has been solved.
The reason why I cannot install Tk perl module is that when I set up the
RHLinux 6.0 I didn't install the XFree86-devel package, which is required
for Tk.
Thanks.
Zhengdong Zhang
zzhang@bayou.uh.edu
------------------------------
Date: Thu, 16 Sep 1999 10:54:10 -0700
From: Sridhar Gangadharan <sridharg@interra.com>
Subject: Making Tk the Top
Message-Id: <37E12EC2.FD3DDA06@interra.com>
I have an application that has perl embedded in it. But from this
application I am not able to call any Tk routines. The moment I do this
it says that
"failed to load tk.so because It cannot locate symbol main"
Is there a way to circumvent this problem. Or could anybody suggest a
way by which Tk can be made the top of application and then embed perl
in it.
Thanks,
Sridhar
--
---------------------------------------------------------------------
SRIDHAR GANGADHARAN Interra, Inc.
2001 Gateway Place, #440W
San Jose, CA 95110.
Direct: (408)-467-4214 URL: http://www.interra.com
Tel: (408)-573-1400 x214
Fax: (408)-573-1430
Email: sridharg@interra.com
---------------------------------------------------------------------
------------------------------
Date: Thu, 16 Sep 1999 14:01:24 -0400
From: Roger Jacques <channel@metalab.unc.edu>
To: Benjamin Franz <snowhare@long-lake.nihongo.org>
Subject: Re: need to write www search engine
Message-Id: <Pine.GSO.4.05.9909161347330.26187-100000@titan.oit.unc.edu>
Benjamin,
Thank you very much for your help so far. I do have financial backing for
this project and would be able to farm it out to a professional service,
or perhaps find an ISP with the required resources willing to take it on.
Therefore, could you give me figures for the disk space needed and the
amount of time it would take through a fractional T3 with a reasonably
efficient crawler, plus any other specifications I would need to to
provide to such a service.
What I want is a massive database with all URLs and the contents of each
<title>, meta:title and first headers <h1/h2>. I have found a use for
such a database that would definitely fill a needed gap, and that would be
popular and profitable to my group.
Also I could use your further recommendations and suggestions as to the
best crawler (harvester agent?) to use or to write.
What sites should I browse for further guidance?
I am an experienced SQL programmer and now web content engineer. I just
have had no experience querying the Web.
Again, thanks for your help so far.
Roger
------------------------------
Date: Thu, 16 Sep 1999 11:16:48 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Output pipes to a browser
Message-Id: <37E13410.EC579703@cisco.com>
[ Carlo Mantini wrote:
> When I run the script from a command line, the output is
> sent to my screen. No error messages are being written to the log by the
> web server.
Do you see lines like
Content-Type:text/html\n\n
which tell the browser the content type, printed out when you run
your programs on the command line. If not, then you have
to add this HTTP header.
--
------------------------------
Date: Thu, 16 Sep 1999 18:15:59 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Parsing Tab Delimited File
Message-Id: <ztaE3.14789$N77.1095270@typ11.nn.bcandid.com>
In article <37e11a5f@cs.colorado.edu>,
Tom Christiansen <tchrist@mox.perl.com> wrote:
>In comp.lang.perl.misc,
> kragen@dnaco.net (Kragen Sitaker) writes:
>:It's not a general-purpose data format, though; you can't store commas
>:in its fields.
>
>And a C string is not a general purpose data format because
>you can't use nulls in it. Well, perhaps, but we seldom
>care. The normal thing is to use an alternate representation.
Yes. Note that Perl strings have no trouble with nulls. :)
>:>No thought
>:>is given to simplicity of parsing, which means you get something
>:>that is *not* simple to parse. Do not call things so-called "CSV
>:
>:"things like"?
>
>This is not CSV:
>
> this,"peter, paul, and mary",jane
> this,"peter, paul, and mary","jane"
> this,"peter, paul, and mary",'jane''s game',here
>
>Because any xSV can be processed with split /x/.
Granted.
The meaning of my question was whether "things so-called" should be
"things like so-called". I wasn't disagreeing with your opinion.
>Those are just screwed up idiocies. I hate them. They were designed
>by someone who didn't design.
Yes. They were inherited from the elder generations.
>None of that crap is present in any of the Unix colon-separated data
>formats. You don't have the quote crap. And even if you have colons
>in your fields, you simply do something like:
>
> for (@fields = split /:/) { s/\\0(\d+)/ord $1/ge }
This is also an inherited solution. You and I just happened to inherit
Unix. Fortunate we are to have such a well-designed heritage. Well,
sort of. :)
>You get to use a trivial parser, not those completely hellish
>regexes that you posted.
Yes, they are hellish. Here's another hellish regex to parse the
format you posted in above (embedded in a program to test it).
#!/usr/bin/perl -w
use strict;
# demo parsing truly evil formats
my @evil = (
q(Yes,"Peter, Paul, and Mary",Jane),
q(Yes,"Peter, Paul, and Mary","Jane"),
q(Yes,"Peter, Paul, and Mary",'Jane''s Addiction',Who),
q(Yes,'files' integrity is sometimes unchecked',ouch!),
q("and sometimes people forget to close quotes)
);
foreach (@evil) {
my @chunks;
push @chunks, $1 while /
\G((?:
[^,"']* | # an unquoted string, or
"(?: # a quoted string containing
[^"] | # nonquote characters, or
"" # doubled doublequotes
)*" | # or
'(?: # a single-quoted string containing
[^'] | # nonquote characters, or
'' # doubled single quotes
)*'
)(,|$) # followed by a comma or the end of the line
| (?: # error-handling: the things that don't match
# any of the above. Quoted strings that
# run to the end of the line and quoted strings
# without a comma after them (which will
# be treated as if they run to the end
# of the line, since in all likelihood someone
# forgot to double a quote, but simply
# correcting the error isn't sufficiently
# offensive, so we'll be obnoxious)
"(?: # a double-quoted string containing
[^"] | # nondoublequotes or
"" # doubled doublequotes
)*" # but then, after the closing quote,
[^,"] # a character that is neither comma
# nor quote! wrong! so we
.*$ # eat the rest of the line
| # or
'(?:[^']|'')*'[^,'].*$ # analogous singlequote thing
| # or
"(?:[^"]|"")*$ # a doublequoted string running to $
| # or
'(?:[^']|'')*$ # a singlequoted string running to $
)
)/xg;
print join (':', @chunks), "\n";
# The above regex should match everything, one way or another, except
# for a null string.
}
It's got a couple of problems.
One is that it always matches the null string at the end of the line
once, giving you an extra unwanted field.
Another is that it includes the trailing comma in the field value.
This could be fixed by using smaller capturing parentheses and using
logic to decide which set matched.
A third is that it doesn't really tell you when there's an erroneous input.
The fourth is that it probably has bugs in it I'm not aware of, simply
because it's so complicated.
Someone may think I posted this to show I disagree with Tom. I don't.
In fact, after writing the above, I agree with him more than ever.
>What you are calling Comma-Separated Data *is not*.
Please don't claim I called it comma-separated.
>:hex encoding,
>
>That's admissible.
Last time I needed a data format for two-dimensional arrays of
arbitrary strings, I used chomp; map {pack "H*", $_} split /:/ to
decode and join (':', map {unpack "H*", $_} @whatever) . "\n" to
encode. Space-inefficient, hard to read in a text editor, trivially
easy to encode and decode in Perl.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Thu Sep 16 1999
53 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Thu, 16 Sep 1999 18:37:19 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Parsing Tab Delimited File
Message-Id: <zNaE3.14799$N77.1098533@typ11.nn.bcandid.com>
In article <37e11ee7@cs.colorado.edu>,
Tom Christiansen <tchrist@mox.perl.com> wrote:
>In comp.lang.perl.misc,
> "Samuel Kilchenmann" <skilchen@swissonline.ch> writes:
>:No, unfortunately even the gurus posted mostly rubbish based on split or
>:regexp's. I don't get the point about the "moral issue" of values containing
>:the separator or the quote character. And as long, as values may contain
>:these characters, neither regexp's nor split's are very useful.
>
>Anybody who creates external data in that format should be shot,
>plain and simple. Yes, many people do it. The world would be a far,
>far better place without those people programming. They're idiots who
>make life hard for others. There are better jobs for them at the
>local hot dog stand. They'd do less damage there.
The original poster's question was about how to read data other people
had put in that format -- not how to put data in that format himself.
I disagree with you about what these people should be doing instead. I
think your stance is elitist and incorrect. Most people don't know how
to spell, write, read, or program, due primarily to a lack of education
-- not due to innate inability to do these things.
The solution is not to prohibit them from programming, voting, or
trying to read and write. The solution is to educate them. This is
often a very difficult solution to implement, and will not succeed in
every case. But it is the only morally defensible solution.
Another part of the solution is to avoid pointless difficulty. For
example, writing learned books in vulgar tongues instead of Latin
greatly eases the burden of literacy -- although folks like you and me
will study Latin anyway.
The Perl analogue is, in part, to do what you have done: write
comprehensible books explaining the language to a popular audience.
Unfortunately, this seems to be only a part of the solution. I'm not
sure what the rest of the solution is.
>:really simple to parse CSV data on a character by character basis, together
>:with a very simple state machine.
>
>Oh for crying out loud, 95% of the people using Perl have never even
>heard of a state machine, and if they have, probably connect it with a
>fascist government.
Good thing we have the CSV module available for those people, then. :)
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Thu Sep 16 1999
53 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Thu, 16 Sep 1999 17:21:58 GMT
From: namnan@my-deja.com
Subject: Question on Hash of Hash
Message-Id: <7rr8v7$ku4$1@nnrp1.deja.com>
I am trying to print my hash of hash of the following code. It is not
printing anything. Could any expert please shed light on this. I have
referred to perlds and perlref and am getting stumped.
Best regards.
The data structure looks like this:
$hoh =
{
$timestamp => {$cookie,$hr,$min,$directory}
}
#!/usr/local/bin/perl5/perl
open (STUFF, "c:/perl/work/sesssorttemp.txt");
while (<STUFF>)
{
chomp;
@fields=split(/,/,$_);
$timestamp=$fields[0];
$hr=$fields[2];
$min=$fields[3];
$sec=$fields[4];
$cookie=$fields[8];
$directory=$fields[10];
foreach $timestamp (keys %hoh)
{
my $hash = $hoh->{$timestamp};
print "$timestamp: ";
foreach $cookie (keys (%hash))
{
print "$cookie, $hash->{$cookie}";
}
print "\n";
}
}
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 16 Sep 1999 17:21:58 GMT
From: namnan@my-deja.com
Subject: Question on Hash of Hash
Message-Id: <7rr8v7$ku3$1@nnrp1.deja.com>
I am trying to print my hash of hash of the following code. It is not
printing anything. Could any expert please shed light on this. I have
referred to perlds and perlref and am getting stumped.
Best regards.
The data structure looks like this:
$hoh =
{
$timestamp => {$cookie,$hr,$min,$directory}
}
#!/usr/local/bin/perl5/perl
open (STUFF, "c:/perl/work/sesssorttemp.txt");
while (<STUFF>)
{
chomp;
@fields=split(/,/,$_);
$timestamp=$fields[0];
$hr=$fields[2];
$min=$fields[3];
$sec=$fields[4];
$cookie=$fields[8];
$directory=$fields[10];
foreach $timestamp (keys %hoh)
{
my $hash = $hoh->{$timestamp};
print "$timestamp: ";
foreach $cookie (keys (%hash))
{
print "$cookie, $hash->{$cookie}";
}
print "\n";
}
}
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 16 Sep 1999 11:05:18 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Question on Hash of Hash
Message-Id: <MPG.124ad136f225555e989f92@nntp.hpl.hp.com>
In article <7rr8v7$ku4$1@nnrp1.deja.com> on Thu, 16 Sep 1999 17:21:58
GMT, namnan@my-deja.com <namnan@my-deja.com> says...
[one posting would have been enough]
> I am trying to print my hash of hash of the following code. It is not
> printing anything. Could any expert please shed light on this. I have
> referred to perlds and perlref and am getting stumped.
>
> Best regards.
>
>
> The data structure looks like this:
> $hoh =
> {
> $timestamp => {$cookie,$hr,$min,$directory}
> }
>
> #!/usr/local/bin/perl5/perl
You are missing the -w flag and 'use strict;', which would have made
your primary error obvious. Maybe that should be a ground-rule here:
use them first, post only if the problem still isn't obvious.
> open (STUFF, "c:/perl/work/sesssorttemp.txt");
How do you know this succeeded? ... or die "Couldn't open file. $!\n"
...
> foreach $timestamp (keys %hoh)
> {
> my $hash = $hoh->{$timestamp};
> print "$timestamp: ";
> foreach $cookie (keys (%hash))
Here is the problem. $hash is a hash ref. %hash is a separate
undeclared and undefined variable. The docs should show you how to
correct this problem, if it isn't obvious already.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 16 Sep 1999 17:23:04 GMT
From: Todd Smith <todds@infotraxsys.com>
Subject: references in dbms
Message-Id: <7rr919$kue$1@nnrp1.deja.com>
I'd like to store complicated data structures, such as lots of
references inside references, into a db file. Is there any way to do it?
--
--
---------------------
Todd Smith - japh
Perl Programmer, InfoTrax
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 16 Sep 1999 18:53:41 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: references in dbms
Message-Id: <V0bE3.14814$N77.1099493@typ11.nn.bcandid.com>
In article <7rr919$kue$1@nnrp1.deja.com>,
Todd Smith <todds@infotraxsys.com> wrote:
>I'd like to store complicated data structures, such as lots of
>references inside references, into a db file. Is there any way to do it?
Not really. db files hold strings. Data::Dumper, which turns
complicated data structures into strings, is one way.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Thu Sep 16 1999
53 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Thu, 16 Sep 1999 16:58:38 GMT
From: chetohevia@my-deja.com
Subject: Re: REQ: tell-a-friend script
Message-Id: <7rr7jl$jth$1@nnrp1.deja.com>
> Anyone who's bothered to look at a CGI tutorial, I reckon.
>
> This was not a perl language question - f'ups set
Perhaps I have asked the wrong question, and perhaps i have selected the
wrong group-- but my question was indeed in reference to perl. I
understand that document.referer is a javascript property, and that the
kind of task I am trying to perform is a CGI-related task, but one of the
major uses of perl, as i'm sure you're aware, is in relation to CGI
programming.
I can indeed use $ENV{HTTP_REFERER} (pls. note-- this is a PERL
variable, in PERL syntax, making this a PERL question) to access the
referring page's URL, but--as you said-- only if that variable exists,
which is not the case when a page is accessed in any other way than
click-through.
my CGI tutorials, PERL tutorials, Deja.com searches, c|net searches, FAQ
searches, calls to friends, etc. yielded no more sure way to access a
previous page than the referer--in PERL.(javascript *can* do it with the
window.parent and history objects, and i'm pretty much resigned to
teaching myself javascript this week in order to do it)
what I want to know is this-- can perl be used to access a parent
window's url or the browser history object? yes, i'm working on a CGI-
based web application, but **i'm doing it in perl**. so, can I ask a
perl question here? can perl access a parent window/history object's URL,
and if so, how?
please, if it's totally obvious, forgive my ignorance. I'm not
brilliant, but i'm trying to ask questions clearly and follow reasonable
rules of politeness...
cheto.
"they needed bread & medicine, and we had only songs & poems in our bags"
-alejandro casona-
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 16 Sep 1999 20:07:29 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: REQ: tell-a-friend script
Message-Id: <Pine.HPP.3.95a.990916194704.27653A-100000@hpplus03.cern.ch>
On Thu, 16 Sep 1999 chetohevia@my-deja.com wrote:
>
> > Anyone who's bothered to look at a CGI tutorial, I reckon.
> >
> > This was not a perl language question - f'ups set
>
> Perhaps I have asked the wrong question,
Well, judging from your present posting, yes you have, because you
already knew the answer to the question that you asked; but even if you
hadn't already known the answer, this would have been the wrong place to
ask it.
> and perhaps i have selected the
> wrong group-- but my question was indeed in reference to perl.
Yeah, and you typed it on a keyboard, so it was relevant to
comp.hardware.keyboards. Honestly, you need to work harder at
understanding what feature of your problem is relevant to what, and I
can promise you that problem solving will get significantly easier when
you've mastered that issue.
> understand that document.referer is a javascript property, and that the
> kind of task I am trying to perform is a CGI-related task, but one of the
> major uses of perl, as i'm sure you're aware, is in relation to CGI
> programming.
One of the many uses of Perl is in CGI programming, but that does not
make CGI questions into Perl language questions, even when they happen
to be written in Perl. This is an important principle and if you really
are so keen to learn as you want us to believe, then it would be wise to
pay attention to the answers you get, rather than being so stubborn
about it.
> I can indeed use $ENV{HTTP_REFERER}
You made no mention before that you already possessed this knowledge.
That's rude, when you're trying to get free advice.
> (pls. note-- this is a PERL variable, in PERL syntax,
Yes it is, but that isn't the point. This just happens to be Perl's way
of referring to HTTP headers, and your problem is with HTTP headers in
the CGI environment.
> making this a PERL question)
And you wrote it in English, so it's on topic for alt.usage.english?
Of course not.
> to access the
> referring page's URL, but--as you said-- only if that variable exists,
And that's your answer, pretty much. This is only Perl's way of
telling it to you. If you were programming in COBOL then you'd access
it in COBOL's way, whatever that might be. It would still be a CGI
question.
> which is not the case when a page is accessed in any other way than
> click-through.
Hmmm?
The (mis-spelled) "Referer:" header is there when it's there, and it
isn't there when it isn't there. And anyway it can be spoofed.
> my CGI tutorials, PERL tutorials, Deja.com searches, c|net searches, FAQ
> searches, calls to friends, etc. yielded no more sure way to access a
> previous page than the referer--in PERL.
In any CGI program. In any language.
So, in short, there is, in the CGI initerface as it stands, no better
way of knowing the referring URL. I wouldn't use it for anything more
than informatory purposes. Any application that absolutely relies on it
is doomed, IMO.
> (javascript *can* do it with the
> window.parent and history objects, and i'm pretty much resigned to
> teaching myself javascript this week in order to do it)
And when the user turns JS off, or their site filters it at the
firewall?
> what I want to know is this-- can perl be used to access a parent
> window's url or the browser history object?
Perl is _a_ programming language. It isn't snake oil; it can't work
magic. If you are programming to the CGI interface, then you can get
what the CGI interface says you can get. And that's true whatever
language you program in.
If you want more, then you must make it for yourself. E.g by creating
custom URLs or such. All the usual techniques for "preserving state",
as discussed in CGI FAQs.
The bottom-line is that you have some partially worked out solution and
you're trying to put a square peg into the remaining round hole. It
won't fit, so you'll really have to reconsider your application. But it
still isn't a Perl language question, no matter that you propose to
choose Perl for programming it.
Take a look at Merlyn's Web Techniques, you'll find some excellent
ideas for further study, and I'd expect it would position you to make a
better selection of solutions to real-world web problems.
good luck
------------------------------
Date: Thu, 16 Sep 1999 17:17:16 GMT
From: gmiller@iglou.com (Greg Miller)
Subject: Some e-mails get sent, some don't
Message-Id: <37e12499.14524988@news.iglou.com>
I've been having a problem for quite some time now which
appears on different servers I've worked with. The problem is that
when using a CGI script to send e-mail, the majority of the messages
get sent fine, but about 10% fail with no error message, and no
dead.letter.
I'm using code similar to the following:
if(!open(M,"|mail $addr"){
error
}
print the message headers and messsage text to M.
I've tried using rmail in place of mail as well as using the -w
option. No luck yet. This happens on several servers from different
ISPs. Any ideas?
------------------------------
Date: Thu, 16 Sep 1999 18:42:54 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Some e-mails get sent, some don't
Message-Id: <OSaE3.14804$N77.1099028@typ11.nn.bcandid.com>
In article <37e12499.14524988@news.iglou.com>,
Greg Miller <gmiller@iglou.com> wrote:
> The problem is that
>when using a CGI script to send e-mail, the majority of the messages
>get sent fine, but about 10% fail with no error message, and no
>dead.letter.
>
>if(!open(M,"|mail $addr"){ error }
>
>print the message headers and messsage text to M.
Most pipe errors show up when you close the filehandle, not when you
open it. Are you checking close M for errors?
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Thu Sep 16 1999
53 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Thu, 16 Sep 1999 18:37:23 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Threads question
Message-Id: <DNaE3.13947$wW2.17215@news.rdc1.ct.home.com>
bhaskaracharya@my-deja.com wrote:
> hi,
> I have a simple question on threads.
> I have 10 items in array and run 2 subs sub1 and sub2 which is
> to be sequential but the 10 are independent.
Do you mean that sub1 needs to process its argument before sub2 processes
the same argument? If that's the case, then you probably ought to just
have sub1 call sub2. If that's not feasable you still are going to need to
do something more complex than what you've got, since there's no guarantee
that any thread is going to complete in a particular amount of time, nor
is there any guarantee on the order the threads complete. If you want
guaranteed behaviour you need to put in the code to do it.
> I do this this way
> but is it possible to run it in one foreach loop? what happens if i have
> to run 10 subs sequentially..10 foreach koops make it ugly...
If you just want to spawn a bunch of threads to do a bunch of stuff, then
sure, put them all in one foreach loop.
You are going to want to wait for them all to complete, though--exiting
the main thread will normally kill the child threads. (And not always
cleanly)
Dan
------------------------------
Date: Thu, 16 Sep 1999 19:00:07 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: trimming spaces from a string
Message-Id: <X6bE3.14819$N77.1100736@typ11.nn.bcandid.com>
In article <7rqvkl$1ts$1@info2.uah.edu>, Greg Bacon <gbacon@cs.uah.edu> wrote:
>In article <MPG.1249a5df7d34dc56989f71@nntp.hpl.hp.com>,
> lr@hpl.hp.com (Larry Rosler) writes:
>: tr/ \n\r\f\t/ /s for $s, $t;
>
>Is there any conforming implementation of isspace() that recognizes a
>character outside this set as being whitespace?
I don't have my C standard handy, but Friedl's regex book claims that
at least Perl's \w is locale-dependent.
If I were writing Unicode, I'd be miffed if \s didn't match the various
non-ASCII spaces in Unicode.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Thu Sep 16 1999
53 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Thu, 16 Sep 1999 18:43:23 +0100
From: "Andy Cragg" <andrew_cragg@csi.com>
Subject: Where do I get perl2exe for Win32?
Message-Id: <7rra50$pv4$1@ssauraaa-i-1.production.compuserve.com>
Hi,
Erm, where do I get perl2exe for Win32?
Not on CPAN or ActiveState documentation. Is it free?
Thanks
Andy
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu.
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 820
*************************************