[12238] in Perl-Users-Digest
Perl-Users Digest, Issue: 5838 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 31 00:07:20 1999
Date: Sun, 30 May 99 21:00:15 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 30 May 1999 Volume: 8 Number: 5838
Today's topics:
Re: Can I execute a string? <rootbeer@redcat.com>
Re: CGI.pm & popup_menu() <hasant@trabas.co.id>
Re: cont'd (Ronald J Kimball)
Re: Couple of basic questions from newbie (Ronald J Kimball)
Re: Downloading large files with LWP <walton@frontiernet.net>
Re: HTML Tag Parsing Across Line Breaks <rootbeer@redcat.com>
Re: Im not asking for much <jbc@shell2.la.best.com>
Opendir on the root of a NT Server <*removethis*mpmcmahon@sprynet.com>
Re: parsing problem <rootbeer@redcat.com>
Perl Newbee <mlikvan@home.com>
Re: Problems w/ Perl 5.005_03 & tying hashes to dbm dat <walton@frontiernet.net>
Re: Shorter solution ? (Larry Rosler)
Welcome back, rootbeer! <jdf@pobox.com>
Re: Y2K infected Perl code <uri@sysarch.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 30 May 1999 18:44:37 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Can I execute a string?
Message-Id: <Pine.GSO.4.02A.9905301835130.8091-100000@user2.teleport.com>
On Mon, 31 May 1999, TheHat wrote:
> I want to store the name of a variable in a string, and then later set
> that variable to a value.
You (almost certainly) just think you want to do this. Yes, it's possible,
since Perl is the kind of language willing to give you enough rope to let
you shoot yourself in the foot.
But you probably want to simply use a hash instead. Now, your variable is
$hash{$name}, and there's nothing wrong with that.
For a cautionary tale about such things, see this.
http://www.plover.com/~mjd/perl/varvarname.html
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 29 May 1999 14:56:45 +0700 (JAVT)
From: Hasanuddin Tamir <hasant@trabas.co.id>
To: comp.lang.perl.misc@list.deja.com
Subject: Re: CGI.pm & popup_menu()
Message-Id: <Pine.LNX.3.96.990529142101.7061A-100000@borg.intern.trabas.co.id>
On Fri, 21 May 1999, Luis F. Salas wrote:
unclelui] Date: Fri, 21 May 1999 19:44:10 -0700
unclelui] From: "Luis F. Salas" <unclelui@grin.net>
unclelui] To: comp.lang.perl.misc@list.deja.com
unclelui] Subject: CGI.pm & popup_menu()
unclelui] Reply-To: comp.lang.perl.misc@list.deja.com
unclelui] Organization: Creative Photography
unclelui]
unclelui] Hola,
Aloh,
unclelui] CGI.pm
unclelui] ======
unclelui]
unclelui] Tr(td(
unclelui] ['Department:', popup_menu('department',
unclelui] [''Accounting','Administration','Human Resources',
unclelui] 'Information Systems', 'Programming']),
unclelui]
CGI's popup_menu() provides `-default' as the
third parameter to set SELECTED element(s).
my $name = 'department';
my @depts = ('Accounting','Administration','Human Resources',
'Information Systems', 'Programming',
);
## if you need to sort first...
@depts = sort @depts;
## what to be SELECTED
## assumes `Programming' is set to default also
my @defaults = ('Information Systems', 'Programming');
## named parameters
popup_menu(
-name => $name,
-value => \@depts,
-default => \@defaults, ## equivalent to SELECTED
);
## or using positional parameters
popup_menu($name, \@depts, \@defaults);
HTML (notice the SELECTED on Information Systems and Programming):
====
<SELECT NAME="department" SIZE=1>
<OPTION VALUE="Accounting">Accounting
<OPTION VALUE="Administration">Administration
<OPTION VALUE="Human Resources">Human Resources
<OPTION VALUE="Information Systems" SELECTED>Information Systems
<OPTION VALUE="Programming" SELECTED>Programming
</SELECT>
If you need only one element as default, you can supply
`-default' a single value. So instead of passing array
reference, you can just pass the default element:
-default => 'Information Systems',
HTH,
-hasan-
+================================================================+
Hasanuddin Tamir <hasant@trabas.co.id>
TRABAS Technical Dept. PT Meitraco Bahana Sejahtera
IT Solution Provider http://www.trabas.co.id/
Surya Sumantri Blok B1 No. 35 Phone: +62-22-216660
Setrasari Mall Bandung 40146 Fax : +62-22-2007633
+================================================================+
SORRY: I ignore most of attachments but plain text type
+================================================================+
"Hingga saat kita nyaris tak percaya
bahwa roda nasib memang berputar"
--Iwan Fals (Belum Ada Judul)
------------------------------
Date: Sun, 30 May 1999 21:15:03 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: cont'd
Message-Id: <1dsmynn.1kohkt0lj41r1N@p67.block1.tc5.state.ma.tiac.net>
Kai Henningsen <kaih=7Hpl0whmw-B@khms.westfalen.de> wrote:
> Well, I'm not so sure I understood it, but mostly that is because what I
> *think* he(?) wants doesn't make very much sense. Sorry, let me rephrase
> that: it doesn't make any sense at all. It looks like a pretty pointless
> exercise - a little like "given a potato and red paint, can I make it look
> like a cherry?" Sure, you can - but why on earth would you want to?
You seem to be asking why on earth one would want to print newlines...
I think the original post makes more sense than the above!
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Sun, 30 May 1999 21:15:02 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Couple of basic questions from newbie
Message-Id: <1dsmvfm.ajrvzb1ob0kryN@p67.block1.tc5.state.ma.tiac.net>
Tom Phoenix <rootbeer@redcat.com> wrote:
> On Sun, 30 May 1999 marshal@marshal.co.uk wrote:
>
> > 1) I note that the perl print statment (command? Method?)
>
> Function? Operator? :-)
>
> > hates having double quotes in it -
>
> [various examples snipped]
Note also that this is an issue with double-quoted strings, not with the
print function.
Just wanted to make that clear, because I think the original poster
missed that point.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Sun, 30 May 1999 23:44:19 -0400
From: Bob Walton <walton@frontiernet.net>
To: weixian_shen@my-deja.com
Subject: Re: Downloading large files with LWP
Message-Id: <37520593.C4CDBF06@frontiernet.net>
Check out the three-argument form of LWP::UserAgent method
"simple_request" or method "request". With these, you can specify a sub
to receive the data in chunks of approximately a specified size. Then you
can write your 20 Mb file to disk while never using more than, say, 100 Kb
of memory.
weixian_shen@my-deja.com wrote:
> Hi,
> I need to write a robot script that download huge files (might be
> well over 20M). Could LWP library handle that? It seems that LWP
> functions stores the content of a downloaded file into a scalar
> variable, which is certainly not suited for this situation. I need to
> be able to resume if the connection times out. Is there a module out
> there that would do it? Thanks for your suggestions.
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
------------------------------
Date: Sun, 30 May 1999 18:24:22 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: HTML Tag Parsing Across Line Breaks
Message-Id: <Pine.GSO.4.02A.9905301822360.8091-100000@user2.teleport.com>
On Sun, 30 May 1999 themuppet@my-deja.com wrote:
> Subject: HTML Tag Parsing Across Line Breaks
If you want to parse HTML, you want to use a well-written module. You
can't do it with simple regular expressions. See HTML::Parser on CPAN.
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 31 May 1999 00:57:13 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: Im not asking for much
Message-Id: <3751de69$0$219@nntp1.ba.best.com>
I R A Aggie <fl_aggie@thepentagon.com> wrote:
> Learning to program *and* learning perl is a tough thing.
And yet, *lots* of people are doing it. I think the conventional wisdom
in these parts that "Perl is a poor choice as a 1st programming
language" could use a little scrutiny.
Because of the Web Thing, jillions of former non-programmers have been
making effective (not necessarily pretty, and not necessarily
appropriate, but effective) use of Perl for a number of years now, and
their ranks appear to be growing.
Part of it, I think, has to do with the blurring of the traditional
user/programmer dividing line that HTML and Perl-enabled-CGI-stuff has
caused. Once you give a former PoB some simple standards (like HTML)
and a sense that they can use their own markup to create a
computer-based representation of some personal vision, rather than
having to live within the constraints of a particular set of menu and
dialog-box choices, it's hard to get that genie back in the bottle. The
same sense of creativity and power that made you experts want to learn
to program makes these people want to build bigger and more interactive
Web sites, with Perl-based CGI scripting as the preferred upgrade path.
Then you have Perl itself, which has succeeded so spectacularly in
making easy things easy that it has made the previously impossible
possible: non-programmers can actually do useful things with it.
An analogy that stikes me is that of CPR training (which I did for a
while for the Red Cross). When CPR instruction programs were first
instituted, there was some resistance from the physician community:
these people learning CPR were not doctors; what made them think they
could provide care? Well, they could. The non-physicians who learned
CPR provided lots of sloppy, inefficient, unprofessional care, and that
care has saved lots of lives, since a given heart-attack victim's
chances of survival are a lot better if there are a few CPR-trained
laypeople on the golf course than if he or she has to hope for an MD to
be there.
In the same way, there is a lot of really cool information on the Web
today because someone with no formal background as a programmer wanted
to make it available, and didn't bother asking permission from the
experts on c.l.p.m. before using Perl to make it happen.
I realize this is an exceptionally boring issue to many of the regulars
around here. But in the larger Perl-as-a-social-phenomenon sense, I
think it's worth at least a minor mention.
These accidental programmers have been learning Perl on their own,
struggling to make sense of documentation that assumes they know far
more than they actually do, and enduring countless snide remarks when
they blunder into this newsgroup. So they end up trading poorly written
code snippets back and forth among themselves, and misinform each other
in comp.infosystems.www.authoring.cgi, and generally make as much of a
mess (and have as much fun, sometimes) as a bunch of preschoolers in a
mud puddle.
Meanwhile, the exalted experts of c.l.p.m. continue to opine that Perl
is an awful choice as a 1st programming language, and that no one
should try to learn it on their own without getting a solid
underpinning in some college's comp sci department first. After all,
that's how *they* came to Perl.
With all due respect to my Perl elders (including those younger than
me), I think the evidence argues otherwise. For a certain subset of
people, the road to Perl does not lead that way. Maybe it's not a "1st"
programming language for them, since they aren't now and probably never
will be fulltime programmers. Call it a "0th" programming language,
then, if that makes you feel better, but the fact is that they are
using it.
In the nobler traditions of some of the people admired most by the
people who gave us Perl, maybe a little bridge-building would be in
order. Maybe it wouldn't be such a bad thing to put a little more
effort into spreading the Word among the gentiles, encouraging the
babies in their efforts to express themselves with babytalk, and so
on, rather than just laughing at them.
There are now, what, 10 kajillion pages of Official Perl Documentation?
How much of it written specifically for this audience I'm talking
about? Any of it? How often does an obvious newbie posting to this
group get more polite, helpful followups (of the sort that Tom Phoenix
used to provide so tirelessly) than snippy asides to other experts
about the incidence of stupid comments from particular domains?
--
John Callender
jbc@west.net
http://www.west.net/~jbc/
------------------------------
Date: Sun, 30 May 1999 22:10:43 -0400
From: "Mike Mc Mahon" <*removethis*mpmcmahon@sprynet.com>
Subject: Opendir on the root of a NT Server
Message-Id: <7isr1d$6kr$1@juliana.sprynet.com>
I am trying to do an opendir() of the root of an NT server share and it is
failing. I am not using UNC convention and the userid has full rights to the
share. I can open a directory off the root but I cannot open the root.
Anyone have any ideas?
Thanks
------------------------------
Date: Sun, 30 May 1999 18:45:54 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: parsing problem
Message-Id: <Pine.GSO.4.02A.9905301845050.8091-100000@user2.teleport.com>
On 30 May 1999, Raul R Ramirez wrote:
> If I have a (string) variable $foo that is composed of
> multiple "sentences" (i.e multiple substrings terminated by \n),
> how can I reliably extract each sentence line????
Well, that's not how I'd define "sentences", but it sounds as if split
would do the job very easily. Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 31 May 1999 03:24:26 GMT
From: Mike Likvan <mlikvan@home.com>
Subject: Perl Newbee
Message-Id: <37521C99.DCA0FB55@home.com>
I've been working with PC networking for years, but I'm
just now getting into web design and using perl scripts
- in particular - formmail.pl. I would appreciate it
if someone in this group could help fill in a few knowledge
holes for me.
What I've learned:
=================
If I create some HTML that points to a copy of formmail.pl
on Internet server "A", and I run the HTML from my C drive
while I'm connected to the Internet, formmail does what it's
supposed to do. (It creates an e-mail and sends the results
of the form to my e-mail address.)
If on the other hand, I try to run that same HTML from Internet
server "B" and point to a copy of formmail.pl in the cgi-bin
folder of Internet server "A" (like I did in my first example)
I get some error about permissions.
My questions:
============
1) Are there parameters in the formmail.pl that look at the location
of the HTML that's trying to use it and only lets authorized Internet
servers use it? I read something about "@refers" or something like
that. Is this an authorization list where the formmail.pl keeps
track of who can get at it? If this is an authorization list, what
do I change in it so that the copy of formmail.pl will allow me
to use it (assuming I can get at the copy and modify its parameters).
2) What does it take for formmail.pl to run on an Internet server?
Let me clarify. Does the server that the formmail.pl resides on
HAVE to be running UNIX? Can it be running NT?
Is the formmail.pl complete (like an EXE or COM file) so that it can
be put on either kind of O/S and it will do its thing? Or, is it
reliant on other files/programs loaded/running in order for it to
run properly. In other words, if it's on a UNIX server, must it have
other "Perl enabling" software to help it function properly? And if
formmail needs other programs running in the background in order
for it to run, are these programs typically already loaded and
running on most UNIX and NT Internet servers?
I ask this because my ISP is running a UNIX box (I think) and that
is where I store web sites I design until the client has viewed it
to make sure it's what they want. Once they give me the OK, I then
load the web site's files onto the domain that will be hosting
their web site. My fear is everything will work well while on my
ISPs UNIX server, and then I'll load it onto some NT domain server
and things like formmail won't work, and I'll be at a loss as to
what to change or suggest for the NT server in order to get the
formmail.pl to work. Or maybe it doesn't even work on an NT server
and I'd have to use a completely different script...
Can anyone help me sort out these questions?
Thanks so much in advance.
------------------------------
Date: Sun, 30 May 1999 23:04:01 -0400
From: Bob Walton <walton@frontiernet.net>
To: Brad Knowles <brad@shub-internet.org>
Subject: Re: Problems w/ Perl 5.005_03 & tying hashes to dbm databases...
Message-Id: <3751FC20.690F9A21@frontiernet.net>
Brad, it looks like your tied hash values are references to another hash (like
$LogFile{x}{y}, for example). The problem with that is that the tied hash saves
the reference to the inner hash (which is a scalar and can be stored in a hash).
Later, when the tied hash returns a key value, it returns a reference to a hash
that no longer exists. Data::Dumper is one possible solution to the problem:
stringify the referenced hash and save that as the value of the tied hash. Then
when the tied hash is read again later, the string is retrieved, and the complete
referenced has may be reconstructed with an eval.
In your case, it looks like a simpler solution might be to just append the
"begin", "end", "count", "entry", etc strings to the key of the tied hash, and
use that instead of having the values of the tied hash be another hash. For
example, replace $LogLine{$oldEntry}{begin} with $LogLine{$oldEntry.'begin'},
with like changes throughout your code.
Hope that helps.
Brad Knowles wrote:
> Folks,
>
> I've got a script that I've put together to try to help reduce the
> amount of noise you might see if you were running a program like
> logcheck. The idea is that instead of seeing each individual log entry
> with a separate date/time stamp, you instead see something akin to a `sort
> | uniq -c | sort -nr` list of log entries (sans optional pid), and then an
> indication of when the first and last log entries were made with that
> exact string.
>
> Anyway, the program seems to work okay with hashes, but when I run the
> exact same program but have it tie the hash to a dbm file, the output is
> different. I'm really *very* curious as to what could be going on, but I
> haven't the faintest clue.
>
> The OS is Slackware 3.5.0 running Linux kernel 2.2.9. The version of
> Perl is 5.005_03, and the program is included below. I really would
> appreciate any comments you may have on this program, even if they aren't
> related to the problems I'm having with tying hashes to dbm files.
>
> TIAFAHYMBATP!
>
> #!/usr/local/bin/perl -T
> #
> # syslog-count Effectively do a `sort | uniq -c | sort -nr` on lines
> # in the format of a syslog file, taking into account the
> # potential pid information that is logged and the first
> # and last times we see this exact line logged.
> #
> # Note: This tool is designed to help further reduce the
> # amount of noise you see if you're running something like
> # logcheck. Of course, since this destroys information,
> # you want to keep the original log files around until
> # you've had a chance to take the information reduced by
> # this program and returned by logcheck and ensure that
> # everything is as you expect.
> #
> #=====================================================================
> #
> # Author: Brad Knowles <blk@skynet.be>
> # Date: Thu May 27 11:57:30 CEST 1999
> #
> #=====================================================================
> #
> # Copyright 1999 by Belgacom Skynet SA/NV, all rights reserved.
> #
> # Permission is hereby granted, free of charge, to any person obtaining a
> # copy of this software and associated documentation files (the "Software"),
> # to deal in the Software without restriction, including without limitation
> # the rights to use, copy, modify, merge, publish, distribute, sublicense,
> # and/or sell copies of the Software, and to permit persons to whom the
> # Software is furnished to do so, subject to the following conditions:
> #
> # The above copyright notice and this permission notice shall be included
> # in all copies or substantial portions of the Software.
> #
> # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> # THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
> # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
> # OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> # THE SOFTWARE.
> #
> # Except as contained in this notice, the name of Belgacom Skynet SA/NV
> # shall not be used in advertising or otherwise to promote the sale, use
> # or other dealings in this Software without prior written authorization
> # from Belgacom Skynet SA/NV.
> #
> #=====================================================================
>
> require HTTP::Date;
> require Getopt::Std;
>
> use HTTP::Date;
> use Getopt::Std;
>
> $prog = $0;
>
> $prog =~ s|^.*/||;
>
> $Usage = "Usage: $prog [-dh]\n\nWhere:\n\t-h\tPrint this help\n\t-d\tUse
> dbm file for temporary storage instead of in-memory hash\n";
>
> getopts('dh');
>
> if ($opt_h)
> {
> print $Usage;
> exit;
> }
>
> if ($opt_d)
> {
> use DB_File;
> $dbmfile = "/var/tmp/$prog.$$";
> dbmopen(%LogLine, $dbmfile, 0600) || die "Can't open dbm file $dbmfile.";
> }
>
> while ($Line = <>)
> {
> next unless ($Line =~ /^(... .. \d\d:\d\d:\d\d) (\w+
> \w+)\[?\d*\]?(.*)\s$/o);
> $LogTime = str2time($1);
> $LogEntry = $2 . $3;
> if ($LogEntry =~ /last message repeated (\d+) times/io)
> {
> $Count = $1;
> if ($OldEntry ne "")
> {
> $LogLine{$OldEntry}{count} += $Count;
> if ((!exists $LogLine{$OldEntry}{begin}) ||
> ($LogLine{$OldEntry}{begin} > $LogTime))
> {
> $LogLine{$OldEntry}{begin} = $LogTime;
> }
> if ((!exists $LogLine{$OldEntry}{end}) ||
> ($LogLine{$OldEntry}{end} < $LogTime))
> {
> $LogLine{$OldEntry}{end} = $LogTime;
> }
> }
> }
> else
> {
> $LogLine{$LogEntry}{entry}=$LogEntry;
> $LogLine{$LogEntry}{count}++;
> if ((!exists $LogLine{$LogEntry}{begin}) ||
> ($LogLine{$LogEntry}{begin} > $LogTime))
> {
> $LogLine{$LogEntry}{begin} = $LogTime;
> }
> if ((!exists $LogLine{$LogEntry}{end}) ||
> ($LogLine{$LogEntry}{end} < $LogTime))
> {
> $LogLine{$LogEntry}{end} = $LogTime;
> }
> $OldEntry = $LogEntry;
> }
> }
>
> foreach $i (sort Complex keys %LogLine)
> {
> @Start = localtime($LogLine{$i}{begin});
> @Stop = localtime($LogLine{$i}{end});
> $Begin = sprintf "%04d/%02d/%02d %02d:%02d:%02d", $Start[5]+1900,
> $Start[4]+1, $Start[3], $Start[2], $Start[1], $Start[0];
> $End = sprintf "%04d/%02d/%02d %02d:%02d:%02d", $Stop[5]+1900,
> $Stop[4]+1, $Stop[3], $Stop[2], $Stop[1], $Stop[0];
> write;
> }
>
> if ($opt_d)
> {
> dbmclose %LogLine;
> $numfiles = unlink $dbmfile;
> printf STDERR "Deleted %d files.\n", $numfiles;
> }
>
> format STDOUT =
> @>>>>> @<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<< @*
> $LogLine{$i}{count}, $Begin, $End, $LogLine{$i}{entry}
> .
>
> sub Complex
> {
> $LogLine{$b}{count} <=> $LogLine{$a}{count}
> ||
> $LogLine{$a}{begin} <=> $LogLine{$b}{begin}
> ||
> $LogLine{$a}{end} <=> $LogLine{$b}{end}
> ||
> $LogLine{$a}{entry} cmp $LogLine{$b}{entry}
> }
>
> --
> Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>
> <http://wwwkeys.pgp.net:11371/pks/lookup?op=get&search=0xE38CCEF1>
>
> Are you looking for a news feed from a site in the Freenix Top 130?
> If so, contact me via private e-mail for details.
------------------------------
Date: Sun, 30 May 1999 20:06:52 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Shorter solution ?
Message-Id: <MPG.11bb9c97f5b58496989b37@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7isgv1$esn$1@nnrp1.deja.com> on Sun, 30 May 1999 23:17:52
GMT, tvn007@my-deja.com <tvn007@my-deja.com> says...
> I came up with a solution to solve the problem. However,
> the solution does looks very long and not very elegant.
>
> Would someone give me a better solution or more elegant solution ?
The following seems more elegant than a ladder of tests, but requires
perl 5.005.
I eliminated your odd habit of chomping the trailing newline off each
line then adding it back when you print, as well as superfluous
punctuation in the print loop.
UNTESTED (except in principle):
my @regexen = (
[ qr/X4/ => \*DATA ],
[ qr/XY/ => \*DATA_XY ],
[ qr/UP/ => \*XY_Z ],
[ qr/DOWN/ => \*F2_DATA ],
[ qr/MP/ => \*LS ],
[ qr/C4/ => \*XYZ ],
);
for my $regex (@regexen) {
next unless $in_file_name =~ /$regex->[0]/;
my $fh = $regex->[1];
print OUTFILE while <$fh>;
close $fh;
last;
}
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 30 May 1999 22:29:01 -0400
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Welcome back, rootbeer!
Message-Id: <m3vhdax98y.fsf@joshua.panix.com>
Long time no see. Spread your magic blend of wisdom, patience, and
humor, so that all might learn and be amused.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: 30 May 1999 23:48:38 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Y2K infected Perl code
Message-Id: <x7iu99gaqx.fsf@home.sysarch.com>
>>>>> "K" == Kristina <kristina@greatbasin.net> writes:
K> I could also mention that some of us who post scripts are not (as you can
K> see from my code) programmers, and thus could probably really benefit
K> from someone saying, "Hey, look, your stuff is broken. Look at the damn
K> man page for thus-and-so!" :)
i don't mean to be down on you, but why would you (or anyone) post a
script if you are not a programmer? what bewilders me is why there is so
much free perl/cgi stuff out there in those archives and how little was
written by someone who IS a professional programmer.
i went looking for a polling cgi script and i found well over a dozen but
none was even close to good enough for me to stomach using it. cut and
paste cgi code, no here docs, lots of backwhacked double quotes,
etc. not one had any quality to it and the authors all seem to act like
their program was the greatest thing ever written.
there is plenty of well written code in cpan but most of that is modules
which IMO require a higher level of programming ability. also they have to
exist under a sharper eye of the perl community who will use and reuse
them so they have to be more robust and written more skillfully.
so my big question for you and for the other archive authors is, why
don't you go back to your scripts and apply the knowledge you have
learned since then (hopefully some came from this group!) and clean up
your programs. i don't recall any of those script authors being active
in the perl community. one reason why is that they would most likely be
laughed or insulted out of their skins.
for some reason, many perl newbies get exposed to those archives
(probably since they just got their pc and want their own cutesy web
site), and think that is the way to code in perl. i have seen people who
have learned perl by reading exisiting code. my recent boss was one and
i spent time with him uneducating the incorrect synapse connections he
had from learning from bad code (i was the replcement for the idiot who
wrote that code and let me tell you his code stunk!).
if we could somehow get newbies to see good code first and then the
archive crap then they would know what was good and what was bad (i know
that is a fantasy!) and matt would be out of business. the chutzpah of
him writing a perl/cgi book based on his broken scripts is incredible.
so in conclusion, i am glad you stood up and claimed the broken code as
yours. i hope you get a chance to fix/update the scripts and replace the
archived ones with the new ones.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.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 5838
**************************************