[10913] in Perl-Users-Digest
Perl-Users Digest, Issue: 4514 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 29 18:07:09 1998
Date: Tue, 29 Dec 98 15:00:21 -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 Tue, 29 Dec 1998 Volume: 8 Number: 4514
Today's topics:
$isdst and the localtime function (Bob MacBob)
Re: $isdst and the localtime function (Mark-Jason Dominus)
Re: An interesesting? problem.... <dgris@moiraine.dimensional.com>
Re: An interesesting? problem.... <tripp.lilley@perspex.com>
Re: An interesesting? problem.... (Randal L. Schwartz)
Re: An interesesting? problem.... <skilchen@swissonline.ch>
Re: Best Perl Book for a "Not Yet" Perl Programmer <nospam_gwynne@utkux.utk.edu>
C++ new to new(nothrow) marin7@my-dejanews.com
Re: EXPERIENCED IN PERL ? (Erik)
Re: help on HTML::LinkExtor (brian d foy)
Re: How to Display multiple image files into HTML templ dturley@pobox.com
matching parentheses quickly <andrew@geac.co.nz>
Re: Newbie help on make (Randy Kobes)
Re: Newest precompiled version of Perl? <Mukke@get2net.dk>
Re: Newest precompiled version of Perl? <mds-resource@mediaone.net>
Perl 5 on HP <ab@ccn.net>
Re: Perl Cookbook <tturton@cowboys.anet-dfw.com>
Re: Perl Cookbook (Mike Stillman)
Re: Perl Cookbook (Brand Hilton)
Re: PERL OO: Function overloading <zenin@bawdycaste.org>
perl with sed question? hallian@hotmail.com
Perl--sql--win32--command??? <damoi985@hotmail.com>
Re: perldocs in print? <nospam_gwynne@utkux.utk.edu>
Re: Searching for Text (Tad McClellan)
Re: Searching for Text <rbruno@mindspring.com>
Segmentation fault <oliverm@bway.net>
Re: Webpage database linkage ? <nospam_gwynne@utkux.utk.edu>
Re: When hashing won't work... <tchrist@mox.perl.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 29 Dec 1998 20:48:44 GMT
From: b_macbob@NOSPAM.hotmail.com (Bob MacBob)
Subject: $isdst and the localtime function
Message-Id: <36893c3e.123424820@news.dircon.co.uk>
Hi all,
I have perl5 on apache/unix - great.
The following code always returns $isdst as 1 (and therefore it's
always BritishSummerTime which here in London it most certainly is
not) no matter what time of year it is:
sub get_date {
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time);
if ($sec < 10) {
$sec = "0$sec";
}
if ($min < 10) {
$min = "0$min";
}
if ($hour < 10) {
$hour = "0$hour";
}
$month = ($mon + 1);
if ($month < 10) {
$month = "0$month";
}
if ($mday < 10) {
$mday = "0$mday";
}
$longyear = ($year + 1900);
if ($year > 99) {
$year = ($year - 100);
}
if ($year < 10) {
$year = "0$year";
}
if ($isdst = 1) {
$dst = "BST";
} else {
$dst = "GMT";
}
Is it correct that $isdst returns 1 when DST is in place? What does it
return when DST is not in place?
Am I completely missing something?
TVMIA,
Bob.
------------------------------
Date: 29 Dec 1998 17:16:36 -0500
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: $isdst and the localtime function
Message-Id: <76bkc4$8bd$1@monet.op.net>
In article <36893c3e.123424820@news.dircon.co.uk>,
Bob MacBob <b_macbob@NOSPAM.hotmail.com> wrote:
>The following code always returns $isdst as 1
> if ($isdst = 1) {
>Am I completely missing something?
Yeah. You're completely missing the `-w' option on your program. Had
you included it, Perl would have given you a warning message that
pointed out that you were completely missing the second `=' in between
`$isdst' and `1'.
------------------------------
Date: 29 Dec 1998 13:12:07 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: An interesesting? problem....
Message-Id: <m3yanqlnc8.fsf@moiraine.dimensional.com>
syran@best.com (Jim Matzdorff) writes:
<snip description>
> ALL the iterations and possible combinations.
This will do what you want, but it's more than just a little ugly.
$string = '10(4).3.4(2).2(2)';
@parts = map { /(\d+)(?:\((\d+)\))?/;
[ $1, $2 ? $1 + $2 : $1 ] } split /\./, $string;
for my $a ($parts[0][0] .. $parts[0][1]) {
for my $b ($parts[1][0] .. $parts[1][1]) {
for my $c ($parts[2][0] .. $parts[2][1]) {
for my $d ($parts[3][0] .. $parts[3][1]) {
print "$a.$b.$c.$d\n";
}
}
}
}
This could probably be done in a single line, but damned if my
brain will turn on enough to figure it out.
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: Tue, 29 Dec 1998 15:23:20 -0500
From: Tripp Lilley <tripp.lilley@perspex.com>
Subject: Re: An interesesting? problem....
Message-Id: <36893A38.B0A2D203@perspex.com>
Jim Matzdorff wrote:
> I have an string (suspiciously like an ip address) such as:
>
> 10(4).3.4(2).2(2)
>
> I need to get every combination of ip address out of that, assuming the number in parens
> are number of addtions to that particular part of the ip address. For instance, the string
> above would (hopefully) get expanded to:
For each octet, grab the base and the range with a regex like this:
/^[0-9]+(\([0-9]+\))?$/
Then do four nested loops, starting at the most-significant octet (the '10(4)' octet, in this
case) in to the least-significant octet ('2(2)').
However, there may exist a much more direct solution to your problem if you'd tell us what the
/actual/ problem is, not your solution.
For instance, if you're trying to represent all of the IP addresses on all of the networks you
own, it might make more sense to just list each network or contiguous range, along with its subnet
mask. Or perhaps you have a network with a non-contiguous subnet mask and want to explore it? In
either case, using the subnet mask for math like this is always going to get you more mileage.
Tell us more...
------------------------------
Date: 29 Dec 1998 12:46:48 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: An interesesting? problem....
Message-Id: <m167aun0av.fsf@halfdome.holdit.com>
>>>>> "Randal" == Randal L Schwartz <merlyn@stonehenge.com> writes:
Randal> A little messy, but this does it:
Randal> my $input = "10(4).3.4(2).2(2)";
Randal> my @item =
Randal> map { /^(\d+)\((\d+)\)$/ ? [$1, $1 + $2] : [$_,$_] } split /\./, $input;
Randal> for my $zero ($item[0][0]..$item[0][1]) {
Randal> for my $one ($item[1][0]..$item[1][1]) {
Randal> for my $two ($item[2][0]..$item[2][1]) {
Randal> for my $three ($item[3][0]..$item[3][1]) {
Randal> print "$zero.$one.$two.$three\n";
Randal> }
Randal> }
Randal> }
Randal> }
Randal> You could also factor out some of the commonality there by creating a
Randal> recursive subroutine (that'd also make it more general) but this
Randal> should handle your direct request.
And since three other people just posted the same basic foreach
solution (including one that looks spookily like mine), here's the
recursive solution I hinted at:
my $input = "10(4).3.4(2).2(2)";
my @item =
map { /^(\d+)\((\d+)\)$/ ? [$1, $1 + $2] : [$_,$_] } split /\./, $input;
&recurse([], @item);
sub recurse {
my @left = @{+shift};
if (@_) {
my $bounds = shift;
for ($bounds->[0]..$bounds->[1]) {
&recurse([@left, $_], @_);
}
} else {
print join (".", @left), "\n";
}
}
print "Just another Perl hacker,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Tue, 29 Dec 1998 23:03:31 +0100
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: An interesesting? problem....
Message-Id: <76bjnd$9mg2@news-sol.swissonline.ch>
Jim Matzdorff schrieb in Nachricht <76b8cq$cs7$1@shell18.ba.best.com>...
>I have a problem here at work that I was wondering if anyone may have
thoughts on.
>
>I have an string (suspiciously like an ip address) such as:
>
>10(4).3.4(2).2(2)
>
>I need to get every combination of ip address out of that, assuming the
number in parens
>are number of addtions to that particular part of the ip address. For
instance, the string
>above would (hopefully) get expanded to:
>
>10.3.4.2
>10.3.4.3
>10.3.4.4
>10.3.5.2
>10.3.5.3
>10.3.5.4
>.and so on...
>14.3.6.2
>14.3.6.3
>14.3.6.4
>
>ALL the iterations and possible combinations.
>
>Suggestions?
>
If you like somewhat obfuscated code, you may try something like the script
below. (please note: this one does not use recursion)
It can be called as:
perl scriptname.pl 10(4).3.4(2).2(2)
Called as
perl scriptname.pl 1(2).3.4(2)
it produces
1.3.4
1.3.5
2.3.4
2.3.5
3.3.4
3.3.5
which seems to be ok.
--------------------snip-----------------
use strict;
sub build_reversed_lol {
my $istr = shift;
my @list;
my @lst = split(/\./, $istr);
foreach my $elt (reverse @lst) {
my ($n, $r) = $elt =~ /^(\d+)(?:\((\d+)\))*/;
if (defined($r)) {
my @tmplst;
for (my $i = $n; $i <= $n + $r; $i++) {
push(@tmplst, $i);
}
push(@list, \@tmplst);
}
else {
push(@list, [$n]);
}
}
return \@list;
}
sub permute_lol {
my $lolref = shift;
my @result;
if ($lolref) {
@result = map {[$_]} @{$lolref->[0]};
shift @{$lolref};
foreach my $lref (@{$lolref}) {
my @curr = ();
foreach my $item (@{$lref}) {
my @new;
foreach my $r (@result) {
my @r1 = @{$r};
push(@r1, $item);
push(@new, \@r1);
}
push(@curr, @new);
}
@result = @curr;
}
}
else {
@result = ();
}
return \@result;
}
sub build_result_list {
my $lol = shift;
my @reslist;
foreach my $lref (@{$lol}) {
push(@reslist, join(".", reverse @{$lref}));
}
return \@reslist;
}
sub print_result {
my $lref = shift;
print join("\n", @{$lref});
}
my $permuted_lol = permute_lol(build_reversed_lol($ARGV[0]));
print_result(build_result_list($permuted_lol));
--------------------snip-----------------
--
Samuel Kilchenmann
skilchen@swissonline.ch
------------------------------
Date: Tue, 29 Dec 1998 16:23:07 -0500
From: "Robert Gwynne" <nospam_gwynne@utkux.utk.edu>
Subject: Re: Best Perl Book for a "Not Yet" Perl Programmer
Message-Id: <76bjv3$mrv$1@gaia.ns.utk.edu>
Get a copy of Perl 5 Interactive Course by Jon Orwant. It has many
exercises, illustrations, etc. The O'Reilly books are probably too advanced
for you and the dummy books are too dumb. Once you plow through Orwant's
book, get the O'Reilly books: Learning Perl, Programming Perl, and the Perl
Cookbook.
As always, a newbie,
Bob Gwynne
Speech Comm.
University of Tennessee
KJPhilbr13 <kjphilbr13@aol.com> wrote in message
news:19981225124503.21535.00001412@ng-fp1.aol.com...
>Background in C, C++, Visual Basic, sh, ksh, etc...
>
>What is the best book to start? Need to understand program structure,
language
>references, hints/examples, etc.
>
>Thanks in advance...Kevin P. in Charlotte, NC
------------------------------
Date: Tue, 29 Dec 1998 20:45:41 GMT
From: marin7@my-dejanews.com
Subject: C++ new to new(nothrow)
Message-Id: <76bf1l$8j1$1@nnrp1.dejanews.com>
I am switching to a new C++ compiler that conforms to the C++ ANSI standard.
On failure, the new operator now throws an exception unless you specify
new(nothrow). I need to change new to new(nothrow) in over 1000 C++ source
files. Anybody have a Perl script that will only change the operator new to
new(nothrow) in C++ source code. Thank you
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 29 Dec 1998 20:03:22 GMT
From: eln@cyberhighway.net (Erik)
Subject: Re: EXPERIENCED IN PERL ?
Message-Id: <76bcia$m90$1@news.cyberhighway.net>
In article <368931C2.20681CEE@usa.net>,
GSX <gsx97@usa.net> writes:
> I'm presently writing a Perl Coffee Maker. I've got the code to brew a
> great cup of Hazelnut...but I'm having a problem with the code for
> decaf.
>
> Will this make me ineligible for the job?
No, but you better get that code for the cappucino extension working
properly...these people are obviously high class.
--
Erik Nielsen, Cyberhighway Internet Services NOC
I think it's a new feature. Don't tell anyone it was an accident. :-)
-- Larry Wall on s/foo/bar/eieio in <10911@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Tue, 29 Dec 1998 15:25:31 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: help on HTML::LinkExtor
Message-Id: <comdog-ya02408000R2912981525310001@news.panix.com>
In article <3689302D.93C9438F@xs4all.nl>, Frank de Bot <debot@xs4all.nl> posted:
> Can someone give me a simple example how to use: HTML::LinkExtor ?
NAME
HTML::LinkExtor - Extract links from an HTML document
SYNOPSIS
require HTML::LinkExtor;
$p = HTML::LinkExtor->new(\&cb, "http://www.sn.no/");
sub cb {
my($tag, %links) = @_;
print "$tag @{[%links]}\n";
}
$p->parse_file("index.html");
--
brian d foy <brianNOSPAM@NOSPAM.smithrenaud.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
remove NOSPAM or don't. it doesn't matter either way.
------------------------------
Date: Tue, 29 Dec 1998 20:30:18 GMT
From: dturley@pobox.com
Subject: Re: How to Display multiple image files into HTML template with perl
Message-Id: <76be4q$7s2$1@nnrp1.dejanews.com>
In article <aF6i2.2473$Hp.3295@news.rdc1.on.home.com>,
"Webmaster" <shadow01@shaw.wave.ca> wrote:
>the resulting HTML file has only a blank img source code, which means that
> the variable "$image" is not being printed.
Nope, it does not mean that at all. It most likely means your image source
path is wrong. The image path must be relative to your script file, or a
complete url like http://www.domain.com/image.jpg. Clay gave you the correct
advise, you just didn't think about it enough. :-)
I would suggest you store the URL to your image directory in variable and
append your image file name to it. Something like:
$image_dir = 'http://www.domain.com/images/
$image_path = $image_dir . $image;
# then img{src=>"$image_path"}
error checking, etc. left as an excersize for the reader,
____________________________________
David Turley
dturley@pobox.com
http://www.binary.net/dturley/
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 30 Dec 1998 11:33:07 +1300
From: "Andrew Mayo" <andrew@geac.co.nz>
Subject: matching parentheses quickly
Message-Id: <76blrp$b47$1@news.akl.netlink.net.nz>
I have this nagging feeling that the problem below can be solved with an
elegant regular expression - but for the life of me I can't see the
solution.
The problem, stated canonically, is simple; given some input via STDIN
(which is actually source code itself), look for a particular function;
we'll call it foo(), in this case, where foo's arguments can themselves be
parenthesized, viz:-
foo(arg1,(arg2+arg3),(arg4))
etc.
We want to return
arg1,(arg2+arg3),(arg4)
as the argument list to foo.
The classic algorithm is of course to iterate through the text string, one
character at a time from the opening bracket, adding one to a counter for
each open bracket and decrementing by one for each closing bracket. Then the
argument list is found when the counter returns to zero.
This is not stunningly fast (if you have a lot of source code to scan),
though obviously using a global match and iterating over the match set will
optimise it somewhat. But being that time of year, I got to wondering if
there's a *really* cunning solution.
Has anyone got a cunning regular expression that might do the trick - some
kind of ingenious use of negative lookahead assertions etc?. Or is this
particular problem not resolvable via a regular expression?. In any case,
would anyone care to suggest an elegant and fast solution to the generic
problem of returning a substring inside balanced parentheses? It seems like
an interesting problem for you Perl experts out there - I am but an
insignificant hacker, as yet, though I gain confidence by the day.....
------------------------------
Date: 29 Dec 1998 22:36:59 GMT
From: randy@theory.uwinnipeg.ca (Randy Kobes)
Subject: Re: Newbie help on make
Message-Id: <slrn78imu5.dqv.randy@theory.uwinnipeg.ca>
On Tue, 29 Dec 1998 17:16:21 +0100, Simon Biela <biela@netdienste.de> wrote:
>I try to install some perl modules. I try to run the make command after
>running perl Makefile.PL and it says:
>
>Checking if your kit is complete...
>Looks good
>Writing Makefile for .... (whatever)
>==> Your Makefile has been rebuilt. <==
>==> PLease rerun the make command. <==
>false
>make: *** [Makefile] Error 1
>
>What did I do wrong ?
Hello,
Does this happen even with a fresh distribution, with no
editing of any of the files? And for any module package?
It might be a problem with the timestamps of the files,
particularly the difference in times of Makefile and
Makefile.PL. Maybe try with a fresh distribution, and if
there's a difference in the timestamps of the files,
`touch` all the files so they have the same timestamp.
--
Best regards,
Randy Kobes
Physics Department Phone: (204) 786-9399
University of Winnipeg Fax: (204) 774-4134
Winnipeg, Manitoba R3B 2E9 e-mail: randy@theory.uwinnipeg.ca
Canada http://theory.uwinnipeg.ca/
------------------------------
Date: Tue, 29 Dec 1998 22:27:37 +0100
From: "Thomas Turn Jensen" <Mukke@get2net.dk>
Subject: Re: Newest precompiled version of Perl?
Message-Id: <GObi2.583$KN.629@news.get2net.dk>
Thank you all for your help - I'm rushing to the activestate site to get it.
The reason I haven't done this earlier (yes - I have looked at perl.com
under newest realease) is that when I downloaded my current version I had to
decide whcih of the two "standards" I wanted - and for some reason I
remember that I thought that something about the ActiveState thing didn't
sound that good - anyway - I'm gonna switch to it now.
Once Again, thank you
***
Thomas Turn Jensen
Icq uin => 8128636
IRC, Undernet => Mukke
***
So long, and thanks for all the fish
***
Jonathan Stowe skrev i meddelelsen <76amc1$cq$1@gellyfish.btinternet.com>...
>On Mon, 28 Dec 1998 22:47:25 -0600 Michael D. Schleif
<mds-resource@mediaone.net> wrote:
>> Ronald J Kimball wrote:
>>>
>>> A quick trip to www.perl.com to download the latest version of Perl for
>>> Win32 systems led me to the following page:
>>>
>>> http://www.ActiveState.com/ActivePerl/
>>>
>>> ActivePerl is the "'merge' of the two popular Perl ports, and has the
>>> absolute best of both plus more! And, ActivePerl is FREE!"
>>>
>>> Build 508 is based on the latest stable Perl release, 5.005_02.
>>
>> From this remark, shall we infer that ActivePerl is the *only* Perl
>> recommended for win32?
>
>There is no reason that people shouldnt continue to use the 5.004.02
>port except that 5.005.02 is the one that most people will be using
>on any platforms - so for instance people here will give examples and
>cite documentation based on the current stable release - eventually the
>Modules that are available for Win32 may only be available for ActivePerl
>(or rather those for other distributions may no longer be maintained ).
>
>> Is this a question legitimate to ask?
>
>Of course it is a legitimate question, however it does seem to be
>motivated by something that you are not making apparent - why wouldnt
>one want to have a Perl based on the lastest stable source code ?
>
>There seems to be an element of FUD around this but I cant determine by
>what it is motivated.
>
>>
>> Of course, this also begs the question, recommended by whom ? }:-^
>>
>
>ActivePerl is based on the same code as the standard source code
>distribution indeed their extensions have been applied to that source
>code - if you are in a position to compile your own Perl with a Borland or
>Microsoft compiler then you would end up with largely the same executable.
>
>Until the release of ActivePerl I had used the 5.00402 release on Win32
>machines and was happy with it. I have no axe to grind here in either
>direction - I would (and I guess so would most other people) just rather
>have the most most up to date Perl available for my platform.
>
>The developer of the previous *standard* 5.00402 port, Gurasamy Sarathy,
>now works for ActiveState so that kind of obviates any more debate on
>the matter.
>
>/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: Tue, 29 Dec 1998 16:38:04 -0600
From: "Michael D. Schleif" <mds-resource@mediaone.net>
Subject: Re: Newest precompiled version of Perl?
Message-Id: <368959CC.CC384BB0@mediaone.net>
To the point: what is the difference between ActivePerl and compiling
stable.zip source on win32?
Clearly, there is a difference; but, why the divergence? Or, is there
divergence?
Jonathan Stowe wrote:
>
> ActivePerl is based on the same code as the standard source code
> distribution indeed their extensions have been applied to that source
> code - if you are in a position to compile your own Perl with a Borland or
> Microsoft compiler then you would end up with largely the same executable.
--
Best Regards,
mds
mds resource
888.250.3987
"Dare to fix things before they break . . . "
"Our capacity for understanding is inversely proportional to how much we
think we know. The more I know, the more I know I don't know . . . "
------------------------------
Date: Tue, 29 Dec 1998 23:56:49 +0100
From: Arndt Baerschneider <ab@ccn.net>
Subject: Perl 5 on HP
Message-Id: <36895E31.E3257F73@ccn.net>
Hi folks,
who can help me finding a binary distribution of perl 5.00x for HP-UX
10.20?
Thanks in advance
Arndt Baerschneider
------------------------------
Date: Tue, 29 Dec 1998 14:08:33 -0600
From: Tom Turton <tturton@cowboys.anet-dfw.com>
Subject: Re: Perl Cookbook
Message-Id: <368936C1.D815D2FF@cowboys.anet-dfw.com>
I too, find the Perl Cookbook to be very good. I do not wish to add to the
carping over minor typos, but I just noticed one which wasn't in the online
errata list at O'Reilly. It is another apparent minor typo which you all may
already be aware of. I couldn't find any info on the O'Reilly web page as to
how to report suspected errata, so please forgive the bandwidth here.
Hopefully Tom or someone else will see it here and disgard it if it is already
known, correct me if I'm wrong, or add it for the next printing change.
Perl Cookbook, page 163, last sentence of first paragraph under Special
Variables
"$' and $` are the strings before and after the successful match,
respectively:"
I believe those are reversed and that $' is the Postmatch and $` is the
Prematch.
Thanks again to Tom and Nathan for an extremely helpful book.
---Tom Turton
------------------------------
Date: 29 Dec 1998 20:20:15 GMT
From: mikebvc@ripco.com (Mike Stillman)
Subject: Re: Perl Cookbook
Message-Id: <76bdhv$rop$1@gail.ripco.com>
Tom Christiansen (tchrist@mox.perl.com) wrote:
: In comp.lang.perl.misc, mikebvc@ripco.com (Mike Stillman) writes:
: :Lots of errors, too. Check the O'Reilly website for a list of errata that
: :runs 25+ pages.
: Listen: this is a myth, and it deeply annoys me to hear it repeated.
How is it a myth? The 25+ page list of errors exists.
: If you consider that a lot of bugs in a 750 page book, then you have
: never written one. I could produce many more `errors' than that if I
: went over any other book with as finely-toothed a comb as I do my own.
: It is misleading of you to make so much of this.
I don't see how I made "so much of this." I did say that it is a very useful
book. But I thought that anyone else, like me, who purchased the first
edition would also want the list of errors, most of which are very minor
errata. I don't think that I implied that the entire book is invalid because
of these errors.
: I happen to have listed *all* the changes I wanted to make for the
: second printing. That includes things like the alignment of equals
: signs in expressions.
: I believe that the only thing I can do now is to remove those.
: I am tired of this unmerited whining. And anyway, we burned up
: the first printing in early September, so that is no longer
: relevant anyway.
The first printing is still in the stores. Why would you remove the list of
errors from the website?
: Thank for nothing,
: tom
I think you're being a little oversensitive here.
_.,-*~'`^'*-,._ _.,-*'`^'*-,.
'*-,._ Mike Stillman '*-,
'*-,.__.,-*' Chicago, IL _.,-*~'`^'*-,._
mikebvc@rci.ripco.com '*-,._.,-*'`^ '
------------------------------
Date: 29 Dec 1998 20:51:10 GMT
From: bhilton@tsg.adc.com (Brand Hilton)
Subject: Re: Perl Cookbook
Message-Id: <76bfbu$he62@mercury.adc.com>
In article <368930e6$0$9738@nntp1.ba.best.com>,
Bill Moseley <moseley@best.com> wrote:
>I'm only a hundred pages or so into Tom and Nathan's Perl Cookbook and think
>it is great and I'd highly recommend it to people like myself that have
>read Programming Perl and now want to see some things in action. _For me_,
>I feel like it's got more bang-for-the-buck than the other Perl books I've
>bought. I like the problem & solution format, and that it's good reading
>when not sitting in front of a computer screen.
>
>Frankly, I wish I would have bought the book sooner (as probably many on
>on this newsgroup would have, too ;)
I got mine at the Perl Conference for being an early registrant. It's
definitely my favorite Perl book. The best $2000+ of the company's
money I ever spent ;-) I take it with me every time I go to the
"library", so I also am grateful that it reads well when I'm not in
front of the computer screen.
I do think the errata page should be stripped of everything but
technical bugs, though. Nobody but Tom, Nat, and ORA care about the
rest.
My $0.02.
--
_____
|/// | Brand Hilton bhilton@adc.com
| ADC| ADC Telecommunications, ATM Transport Division
|_____| Richardson, Texas
------------------------------
Date: 29 Dec 1998 22:42:03 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: PERL OO: Function overloading
Message-Id: <914971468.898091@thrush.omix.com>
[posted & mailed]
Damian Conway <damian@cs.monash.edu.au> wrote:
>snip<
: You can do this (and much more) with the Class::Multimethods
: module which will be going up on the CPAN early in the new
: year.
Is there a beta version out yet we could take a look at?
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Tue, 29 Dec 1998 21:29:00 GMT
From: hallian@hotmail.com
Subject: perl with sed question?
Message-Id: <76bhiq$avv$1@nnrp1.dejanews.com>
Hi everyone..,
I have a simple statement:
sed -e "1,5d" $file > /tmp/test
I need to put this statement in Perl:
system "sed -e '1,5d' $file > /tmp/test";
My statement does not work!! It's does work form the prompt, but when calling
within Perl with the system command, it does not and dump /tmp/test with file
size of zero. Any help would be appreciated.
thanxs,
sm
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 29 Dec 1998 22:46:42 +0100
From: Damoi <damoi985@hotmail.com>
Subject: Perl--sql--win32--command???
Message-Id: <36894DC2.F01CBBE6@hotmail.com>
I have a base named: Data
consist of two tables: One and Two
Table one has three fields: Name, Number and City
What would be the sql command to add a value (let's say: '2') straigth
into the Number-field in Table One of Data??????
I keep getting the error that a constant can't be changed and it drives
me nuts by now.
I am using an Access Database over NET::ODBC Perl.....
but I am interested in the command to increase the integer value of the
field Number only.
Thanks a zil.
------------------------------
Date: Tue, 29 Dec 1998 15:42:02 -0500
From: "Robert Gwynne" <nospam_gwynne@utkux.utk.edu>
Subject: Re: perldocs in print?
Message-Id: <76bhf8$lln$1@gaia.ns.utk.edu>
Why not use your browser to access the HTML version and print the pages that
you want. They would be less expensive than a book, would be the specific
ones you want, and would be easy to pack in a suitcase.
Bob Gwynne
Bill Moseley <moseley@best.com> wrote in message
news:36891b6e$0$9750@nntp1.ba.best.com...
>Does anyone publish the perl docs and current faqs? As much as I like the
>on-line docs, it would be nice to have a printed version for when I'm not
>on-line. For example, a perfect time for such exciting reading would be
>for my upcoming trip to the in-laws ;-).
>
>I looked at the Perl Resource Kit, but is really more than I'm looking for.
>
>Wish me luck.
>
>
>--------------
>Bill Moseley
>moseley@best.com
>
------------------------------
Date: Tue, 29 Dec 1998 14:10:49 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Searching for Text
Message-Id: <90db67.oev.ln@magna.metronet.com>
Robert Bruno (rbruno@blue-pumpkin.com) wrote:
: I am working on getting this script to work, but have encountered some
: trouble with it.
But you are not going to share what the nature of the trouble is?
Does it not compile?
Never terminates?
Writes too many lines?
Writes too few lines?
Does not write any lines?
...
: I want to open a file (rpt1204.txt) and have it look for
: certain information to pull out (Date and time interval) and then print the
: output of the search to another document (rpt1204.out). If someone could
I don't see anywhere in your code where you
"print the output of the search".
Might that be the problem?
: lend any assistance and point me in a general direction, it would be greatly
: appreciated.
: Here is the code I'm using currently.
: $theInputFile = 'C:\rpt1204.txt';
: open( INPUT, "<$theInputFile" ) or die "couldn't find file for writing\n";
There is no need to put it into a variable first.
You are missing out on some potential helpful information by
not printing the $! special variable:
You're die() says "writing", but you are opening it for reading...
open( INPUT, '<C:\rpt1204.txt') or die "couldn't open file $!";
: $theOutputFile = 'C:\rpt1204.out';
: open( OUTPUT, ">$theOutputFile" );
You should always check the return value from open() calls.
You did if for the first one, but not for this one...
: ($TodayDay, $TodayMonth, $TodayYear) = (localtime)[3, 4, 5];
: printf OUTPUT "Report Date: %02d/%02d/%02d\n", (($TodayMonth + 1),
: $TodayDay, $TodayYear);
: print OUTPUT "\n";
[ snip while() loop code that never writes to the OUTPUT filehandle. ]
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 29 Dec 1998 17:04:49 -0500
From: "Robert Bruno" <rbruno@mindspring.com>
Subject: Re: Searching for Text
Message-Id: <76bjfk$ic7$2@camel25.mindspring.com>
This is a multi-part message in MIME format.
------=_NextPart_000_002C_01BE334D.58108A90
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Unfortunately it only writes the line of today's date.
Here is the file attachment.
Tad McClellan <tadmc@metronet.com> wrote in message
news:90db67.oev.ln@magna.metronet.com...
>Robert Bruno (rbruno@blue-pumpkin.com) wrote:
>
>: I am working on getting this script to work, but have encountered some
>: trouble with it.
>
>
> But you are not going to share what the nature of the trouble is?
>
> Does it not compile?
>
> Never terminates?
>
> Writes too many lines?
>
> Writes too few lines?
>
> Does not write any lines?
>
> ...
>
>
>: I want to open a file (rpt1204.txt) and have it look for
>: certain information to pull out (Date and time interval) and then print
the
>: output of the search to another document (rpt1204.out). If someone could
>
>
> I don't see anywhere in your code where you
> "print the output of the search".
>
> Might that be the problem?
>
>
>: lend any assistance and point me in a general direction, it would be
greatly
>: appreciated.
>
>: Here is the code I'm using currently.
>
>: $theInputFile = 'C:\rpt1204.txt';
>: open( INPUT, "<$theInputFile" ) or die "couldn't find file for
writing\n";
>
>
> There is no need to put it into a variable first.
>
> You are missing out on some potential helpful information by
> not printing the $! special variable:
>
> You're die() says "writing", but you are opening it for reading...
>
>
> open( INPUT, '<C:\rpt1204.txt') or die "couldn't open file $!";
>
>
>: $theOutputFile = 'C:\rpt1204.out';
>: open( OUTPUT, ">$theOutputFile" );
>
>
> You should always check the return value from open() calls.
>
> You did if for the first one, but not for this one...
>
>
>: ($TodayDay, $TodayMonth, $TodayYear) = (localtime)[3, 4, 5];
>: printf OUTPUT "Report Date: %02d/%02d/%02d\n", (($TodayMonth + 1),
>: $TodayDay, $TodayYear);
>: print OUTPUT "\n";
>
>
>[ snip while() loop code that never writes to the OUTPUT filehandle. ]
>
>
>--
> Tad McClellan SGML Consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
------=_NextPart_000_002C_01BE334D.58108A90
Content-Type: text/plain;
name="rpt1204.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="rpt1204.txt"
=0C=1BL
SYSTEM SUMMARY =
REPORT
FROM: December 2, =
1998 01:00
TO: December 2, =
1998 02:00
blah blah blah blah blah blahblah blah blahblah blah blahblah blah =
blahblah blah blahblah blah blahblah blah blah
blah blah blahblah blah blahblah blah blahblah blah blahblah blah =
blahblah blah blahblah blah blahblah blah blah
blah blah blahblah blah blahblah blah blahblah blah blahblah blah =
blahblah blah blah
------=_NextPart_000_002C_01BE334D.58108A90--
------------------------------
Date: Tue, 29 Dec 1998 15:08:01 -0500
From: Oliver Moffat <oliverm@bway.net>
Subject: Segmentation fault
Message-Id: <368936A1.DE69624E@bway.net>
I'm building a web log tracker. I use JavaScript to capture the
referring URL with a single pixel gif. This works fine, except that many
of the referrer's show up with url encoded data. I was stupid and didn't
think to decode them before recording them to my DBM hash file. Now when
I attempt to access the data, it reads in for a while and then dies:
"Segmentation fault"
Dose anyone know a way to go in and just delete this bad entry? Or
better yet, a way to decode that chunk?
Or am I on the wrong track here? Is there something else wrong?
In the future what should I do to avoid it?
------------------------------
Date: Tue, 29 Dec 1998 15:38:55 -0500
From: "Robert Gwynne" <nospam_gwynne@utkux.utk.edu>
Subject: Re: Webpage database linkage ?
Message-Id: <76bh99$lla$1@gaia.ns.utk.edu>
I have a search app that can be sampled at
http://web.utk.edu/cgi-bin/cgiwrap/gwynne/bib_lookup.
It's currently very basic, but it is fast and does the job of searching a
newline delimited textfile, but can be changed to use other delimiters. The
database is merely a \n delimited textfile--one entry per line.
If you want the code, you are welcome to it. Note: that the source code you
access from your browser is not the Perl code.
You should also take a look at Eric Bohlman's new module at
http://members.xoom.com/omsdev/ebohlman/perlmodules
Eric's module accommodates boolean searches.
Bob Gwynne
<chall5@hotmail.com> wrote in message
news:76b7un$2dr$1@nnrp1.dejanews.com...
>Could anyone please tell me what the best way to provide a search facility
on
>my website is using Perl scripting and CGI. I have a CGI-BIN and am trying
>to achieve a search function for a job database.
>
>Also what would be the format of the database file that the jobs were
stored
>in ? Would it be a .txt file or something more complicated ?
>
>Any help appreciated.
>
>chris hall
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 28 Dec 1998 18:07:26 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: When hashing won't work...
Message-Id: <768hcu$2j9$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, rick@marinweb.com writes:
:Sometimes, though, when I want to do something like that, I can't
:because hash keys can only consist of certain characters. For
:instance, I can't use a hash to do the above mentioned sorts of things
:with a list of email addresses... foo@bar.com will not work as a hash
:key.
This is completely false.
--tom
--
"Espousing the eponymous /cgi-bin/perl.exe?FMH.pl execution model is like
reading a suicide note -- three days too late."
--Tom Christiansen <tchrist@mox.perl.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 4514
**************************************