[12961] in Perl-Users-Digest
Perl-Users Digest, Issue: 371 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 4 18:07:23 1999
Date: Wed, 4 Aug 1999 15:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 4 Aug 1999 Volume: 9 Number: 371
Today's topics:
Re: => only in hash initialization? (WAS: mySQL & Perl (Larry Rosler)
Re: [offtopic]RE:Quot St and the Jeop Gm (I R A Darth Aggie)
Re: [offtopic]RE:Quot St and the Jeop Gm (Larry Rosler)
Re: [offtopic]RE:Quot St and the Jeop Gm (Greg Bacon)
Re: Autovivification? (Bart Lateur)
Re: Autovivification? <uri@sysarch.com>
Re: Change User & Export Dipslay <biju.abraham@ebay.sun.com>
Re: chomp not working (I R A Darth Aggie)
Cookbk p228 - sysopen error <jdudley@inna.net>
Re: Cookbk p228 - sysopen error <sariq@texas.net>
Re: Cookbk p228 - sysopen error <tchrist@mox.perl.com>
ftp module...please help <johng12@hotmail.com>
Re: Help me .........please!! (Bob Trieger)
Re: how to substitute strings in a newly created file (Matthew David Zimmerman)
Re: Inconsistancy between Perl's @INC and @ISA <garethr@cre.canon.co.uk>
Re: Inconsistancy between Perl's @INC and @ISA <uri@sysarch.com>
Re: Jeoparder's Jest (Larry Rosler)
Re: Jeoparder's Jest <tchrist@mox.perl.com>
Re: Perl counter muckup <aqumsieh@matrox.com>
Re: Perl seems to be LAME! <gellyfish@gellyfish.com>
Re: Perl vs HTML <biju.abraham@ebay.sun.com>
Re: Please Help with regex <aqumsieh@matrox.com>
Re: reading in multiple unknown files and writing to it <biju.abraham@ebay.sun.com>
Re: tar <gellyfish@gellyfish.com>
Re: towards uploading binary files... (Larry Rosler)
Wanted: Perl Script to parse email headers and body <a_s_hearn@yahoo.com>
Re: Wanted: Perl Script to parse email headers and body (Greg Bacon)
Re: while loop teminates too early <makarand_kulkarni@my-deja.com>
Re: Why is it.... <tchrist@mox.perl.com>
Re: Why is it.... (I R A Darth Aggie)
Re: Why is it.... (I R A Darth Aggie)
Re: Why is it.... (Larry Rosler)
Re: Why is it.... (Greg Bacon)
Re: Working Telnet Script Needed <carvdawg@patriot.net>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 4 Aug 1999 14:46:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: => only in hash initialization? (WAS: mySQL & Perl -> Something simple)
Message-Id: <MPG.121254a5c4888542989dcb@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <19990804204428.54651.qmail@hotmail.com> on Wed, 04 Aug 1999
16:44:28 EDT, Perl King <perlking@hotmail.com> says...
> Alex Farber <alex@kawo2.rwth-aachen.de>
> >Perl King wrote:
> > > ObPerl: Use the => operator only in hash initialization.
> >
> >why?
>
> => ist entsprechen-zum Bediener. Es soll nicht als "phantastisches
> Komma" verwendet werden und kann Fehler verursachen, wenn Sie auf diese
> Weise verwendet werden:
>
> open PW => '/etc/passwd'; # Vorausgehenproblem!
>
> An gängige Praxis und verwenden an passen sich => Bediener nur in
> der Durcheinander-initialisierung.
>
> Perl König
That's just one opinion. Saying it in German only makes it less
accessible.
And now that you have started a new thread by losing the References
header, let's rename it (without the typo this time :-) as Matthew
Bafford has done.
There are 33 messages in the thread in comp.lang.perl.moderated. Please
let's not repeat them all here.
http://x34.deja.com/[ST_rn=ps]/getdoc.xp?AN=499000536&search=thread
This seems like a classic case of TMTOWTDI, in this case involving
nothing but taste and judgment, on which we can all differ.
De gustibus non disputandum est.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 4 Aug 1999 21:12:05 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: [offtopic]RE:Quot St and the Jeop Gm
Message-Id: <slrn7qhb9b.3ej.fl_aggie@thepentagon.com>
On 04 Aug 1999 10:48:33 -0600, llornkcor@earthlink.net
<llornkcor@earthlink.net>, in <wkyafrv6e6.fsf@earthlink.net> wrote:
+ hmm, maybe there isn't very good info on using perldoc? Oh, there's a
+ few explainations on perldoc perl, but where's perldoc perldoc??? :o)
It exists...
+ my windlows system has grep...
+ and also ls, sort and a bunch of unix commands.
+ but I am not talking about a windblows system, I am talking linux.
Ok, here's the results from 'man perldoc' on my debian distribution:
PERLDOC(1) Perl Programmers Reference Guide PERLDOC(1)
NAME
perldoc - Look up Perl documentation in pod format.
[snip]
James
------------------------------
Date: Wed, 4 Aug 1999 14:18:42 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: [offtopic]RE:Quot St and the Jeop Gm
Message-Id: <MPG.12124e0e15aaf6eb989dc8@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <37a8a3e6@cs.colorado.edu> on 4 Aug 1999 14:34:46 -0700, Tom
Christiansen <tchrist@mox.perl.com> says...
> Clueless again, llornkcor@earthlink.net (llornkcor@earthlink.net)
> blathers on with:
>
> :I was talking about html docs.... on perl.com. sorry-
>
> 1) There are no HTML docs on perl.com that you can access.
> 2) HTML is the opiate of the masses. Learn to use real tools.
> 3) Your message was illegal: it was missing a mandatory header.
Huh???
<URL:http://www.perl.com/cgi-bin/pace/pub/doc/manual/html/pod/perl.html>
for example.
Maybe we are existing in parallel universes.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 4 Aug 1999 21:41:56 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: [offtopic]RE:Quot St and the Jeop Gm
Message-Id: <7oac34$ovu$1@info2.uah.edu>
In article <MPG.12124e0e15aaf6eb989dc8@nntp.hpl.hp.com>,
lr@hpl.hp.com (Larry Rosler) writes:
:
: In article <37a8a3e6@cs.colorado.edu> on 4 Aug 1999 14:34:46 -0700,
: Tom Christiansen <tchrist@mox.perl.com> says...
: > 1) There are no HTML docs on perl.com that you can access.
:
: <URL:http://www.perl.com/cgi-bin/pace/pub/doc/manual/html/pod/perl.html>
perl.com and www.perl.com refer to different machines.
Greg
--
Bluto: My advice to you is to start drinking heavily.
Otter: Better listen to him, Flounder. He's pre-med.
------------------------------
Date: Wed, 04 Aug 1999 21:12:17 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Autovivification?
Message-Id: <37a8ac6f.6298084@news.skynet.be>
Ala Qumsieh wrote:
> It allows
>you to do something like:
>
> my %hash;
> $hash{'a'}{'b'}{'c'} = 1;
The rotten thing about it is this:
my %hash;
$hash{'a'}{'b'} = "xxx";
$hash{'a'}{'b'}{'c'} = 1;
print $xxx{'c'};
prints "1".
You can catch this by "use strict refs", but it's annoying, anyway.
Bart.
------------------------------
Date: 04 Aug 1999 17:32:28 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Autovivification?
Message-Id: <x7emhji64z.fsf@home.sysarch.com>
>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:
>> my %hash;
>> $hash{'a'}{'b'}{'c'} = 1;
BL> The rotten thing about it is this:
BL> my %hash;
BL> $hash{'a'}{'b'} = "xxx";
BL> $hash{'a'}{'b'}{'c'} = 1;
that will not overwrite $hash{'a'}{'b'} with a new anon hash for you. if
you want to extend a structure, don't assign regular values to leaf
nodes
BL> print $xxx{'c'};
BL> prints "1".
BL> You can catch this by "use strict refs", but it's annoying, anyway.
you don't run with use strict in general?
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
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Wed, 04 Aug 1999 14:41:35 -0700
From: Biju Abraham <biju.abraham@ebay.sun.com>
Subject: Re: Change User & Export Dipslay
Message-Id: <37A8B38F.C6A24CF1@ebay.sun.com>
For display setting try this
$ENV{"DISPLAY"} = "machine:0";
In the second snippet, what's ur aim ?
Biju
Greg Guerin wrote:
>
> I cannot seem to get my export DISPLAY command to work when running the
> code below nor will the following code accept my unix 'su - user'
> command. These two snippets are in separte scripts but they should be
> enough to show the problem. Is there a module to handle these
> environment and user issues? All suggestions are appreciated! Thanks.
>
> Greg
> mailto: gregory_guerin@hp.com
>
> $cmd = 'export DISPLAY=machine_name:0';
> system("$cmd"); # Doesn't Change the Display
> exit 0;
>
> $pid = open2(\*RDR, \*WTR, "/usr/bin/su - user);
> die "Open2 failed: $!\n" unless ($pid =~ /^\d+$/);
> while (<STDIN>) {
> print WTR "password\n"; # Doesn't seem to receive the password being
> sent here.
> # It just hangs.
> $line = <RDR>;
> print STDOUT "$line";
> }
> exit 0;
------------------------------
Date: 4 Aug 1999 20:59:04 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: chomp not working
Message-Id: <slrn7qhagu.3ej.fl_aggie@thepentagon.com>
On Wed, 4 Aug 1999 10:51:21 -0700, jembow@my-deja.com <jembow@my-deja.com>, in
<v04210107b3ce2de2f91e@[206.169.190.24]> wrote:
+ ""chomp" may clash with future reserved word at ./chomp_test line
+ I'm using perl5.00502 on FreeBSD 2.2.8
No, you aren't. You may want to check that the perl refered
to on the #! line of your script is really perl5.
/whatever/path/to/perl -v
James
------------------------------
Date: Wed, 4 Aug 1999 17:13:59 -0400
From: Jane Dudley <jdudley@inna.net>
Subject: Cookbk p228 - sysopen error
Message-Id: <Pine.BSF.3.96.990804170623.29072A-100000@butterfly.inna.net>
Greetings, all.
I am testing something from the Cookbook, p. 228, and getting an error
that doesn't make sense to me. (Using Perl 5.004, RH Linux 5.2).
The program is intended to open a file for writing, create new file,
file must not exist. Here's the program snippet:
#!/usr/bin/perl -w
$path = "\/tmp\/fopentest";
sysopen(FH, $path, O_WRONLY | O_EXCL | O_CREAT) || die "Problem: $path
$!\n";
print FH "This is a test file.\n";
close FH;
and here's the error:
Argument "O_WZOO\\Y" isn't numeric in sysopen at ./amrep line 38.
Problem: /tmp/fopentest No such file or directory
Huh?? I have typed the O_WRONLY etc. carefully, using O for open, not 0 as
zero, etc.
Jane
------------------------------
Date: Wed, 04 Aug 1999 16:40:06 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Cookbk p228 - sysopen error
Message-Id: <37A8B336.DEF25D9B@texas.net>
Jane Dudley wrote:
>
> Greetings, all.
>
> I am testing something from the Cookbook, p. 228, and getting an error
> that doesn't make sense to me.
Did you read the entire recipe? You're missing something *very*
important that usually is placed near the beginning of a program.
- Tom
------------------------------
Date: 4 Aug 1999 15:52:21 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Cookbk p228 - sysopen error
Message-Id: <37a8b615@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
Jane Dudley <jdudley@inna.net> writes:
:Argument "O_WZOO\\Y" isn't numeric in sysopen at ./amrep line 38.
You forgot to use Fcntl. And strict.
--tom
--
Installing unix fixes the [VMS] bug.
-Barry Shein
------------------------------
Date: 4 Aug 1999 21:10:48 GMT
From: john <johng12@hotmail.com>
Subject: ftp module...please help
Message-Id: <7oaa8o$jtl11@usilws15.ca-nethaven.com>
NET::ftp question......
when i run a perl script it complains with the follwoing message
Global symbol "%NetConfig" requires explicit package name at c:\perl\lib/Net/ftp.pm at line 57
(ofcourse i am using te ftp module) Please email me asto what is wrong and how can i make it work. BTW the Telnet module just works fine, no problem,only the FTP is complaining....
please email me at johng12@hotmail.com
thanks all
------------------------------
Date: Wed, 04 Aug 1999 21:48:12 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: Help me .........please!!
Message-Id: <7oabfc$s7e$1@birch.prod.itd.earthlink.net>
[ courtesy cc sent by mail if address not munged ]
Your subject line sucks!! Please use something more descriptive.
hads6307@my-deja.com wrote:
>Can somebody help me with this problem? I need to take input from a
>single textbox in a form and output the data into another frame. Can
>somebody help with the framework below.
Perl doesn't output to frames. It outputs to filehandles.
>
>#!/usr/bin/perl
You should have a -w swicth in your shbang line!
You should also be using Strict.
># load CGI library
>use CGI qw(:standard);
>
>#Create header
>
>#Capture form input and save into scalar variable
>if ( $method eq 'POST' )
>{
>print "HI THERE";
>read(STDIN, $_, $ENV{'CONTENT_LENGTH'});
>}
What's this crap?!? You've loaded CGI.pm, now use it!
>
># set condition so that if input is not equal to "" print "You are
>thinking <input>"
>
>#else print out ""
>
May I suggest that you check out the documentation that comes with
CGI.pm? There are loads of examples and explanations in it.
Once you get the basics of CGI down, then you can worry about frames and
such. And, then if you have any specific questions, try asking in the
apporopriate newsgroup after consulting their FAQ:
news:comp.infosystems.www.authoring,cgi
HTH
------------------------------
Date: 4 Aug 1999 21:47:22 GMT
From: mdz4c@node5.unix.Virginia.EDU (Matthew David Zimmerman)
Subject: Re: how to substitute strings in a newly created file
Message-Id: <7oacda$j4v$1@murdoch.acc.Virginia.EDU>
In article <37A8AA26.6C865241@ccrs.nrcanDOTgc.ca>,
Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca> wrote:
>I'm writing a script to make files of directory listings. However, I'd
>like to strip the extensions off all files listed in the new file, but
>can't seem to get the syntax correct:
>
>#!/public/bin/perl -w
Good use of the -w tag, but you should have 'use strict' too.
>opendir FLTCOR, "fltcor" or die "can't open directory: $!";
>@rsps = grep !/^\.\.?$/, readdir FLTCOR;
>closedir FLTCOR;
>
>open(RSP, ">rsp.list");
You ought to check the return value of this too ('or die(...);').
>print RSP "@rsps";
>
>while (<>)
>{
>s/.*txt.*//g; # extension to be removed is ".txt"
This is going to remove any line with "txt" in it, which I don't think you
want.
>}
You've written the list to the file before you've modified it, and the
magic <> filehandle thingie is probably waiting for you to enter something
on STDIN. Try this instead:
#
#
opendir FLTCOR, "fltcor" or die "can't open directory: $!";
@rsps = grep !/^\.\.?$/, readdir FLTCOR;
closedir FLTCOR;
open (RSP, ">rsp.list") or die "Can't open rsp.list: $!";
while(@rsps) {
s/\.txt$//g; #This should work better.
print RSP;
}
close (RSP) or warn "Can't close rsp.list: $!";
#
#
HTH! Good luck.
Matt
--
Matthew Zimmerman ------------ http://www.people.virginia.edu/~mdz4c
Interdisciplinary Biophysics Program --------- University of Virginia
| "You got to be very careful if you don't know where you're going, |
| because you might not get there." -- Yogi Berra |
------------------------------
Date: Wed, 4 Aug 1999 21:16:59 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
To: schmickl@magnet.at
Subject: Re: Inconsistancy between Perl's @INC and @ISA
Message-Id: <siso5z1c1g.fsf@cre.canon.co.uk>
Thomas Schmickl <schmickl@magnet.at> wrote:
> That leads me to the point, that the @INC and the @ISA array
> are not implemented consistantly.
Perl does not require developers to give a module and any package it
creates the same name. I can create a module Foo.pm which creates a
package Foo -- or a package Bar, or no packages at all, or many
packages. On the other hand, the definition of the package Foo might be
spread over any number of modules.
If your module is called "/myprog/class/BaseWidget.pm" and it creates a
package called `BaseWidget', then there are two possibilities:
1. If you want `use BaseWidget' to work, then `use lib "/myprog/class"'.
2. If you want `use base qw(class::BaseWidget)' to work, then change
the package name to `class::BaseWidget'.
Either way, the package name will match the module name and you'll be
happy. Or you could live with the difference.
--
Gareth Rees
------------------------------
Date: 04 Aug 1999 17:27:24 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Inconsistancy between Perl's @INC and @ISA
Message-Id: <x7iu6vi6df.fsf@home.sysarch.com>
>>>>> "TS" == Thomas Schmickl <schmickl@magnet.at> writes:
TS> So why do I have to specify the subfolder in the use-statement but
TS> I am not allowed to specify it in the @ISA array.
TS> That leads me to the point, that the @INC and the @ISA array
TS> are not implemented consistantly.
they are not related.
@INC is used by both require and use and is a simple global array of
dirs to search for libraries and modules. any modules with :: have that
converted to / (or the OS dir separator). simple, nothing else to it.
@ISA is a package global and is used to find methods. it has nothing to
do with @INC. you could create multiple classes with package names and
@ISA'a in a single source file and never have a use statement or need
@INC.
so claiming they are inconsistant is not meaningful.
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
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Wed, 4 Aug 1999 14:23:53 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Jeoparder's Jest
Message-Id: <MPG.12124f43b559496e989dc9@nntp.hpl.hp.com>
In article <37a8a4da@cs.colorado.edu> on 4 Aug 1999 14:38:50 -0700, Tom
Christiansen <tchrist@mox.perl.com> says...
> In comp.lang.perl.misc, lr@hpl.hp.com (Larry Rosler) writes:
> :Yeah, yeah. Meanwhile, Tom, what's the question?
>
> Q: What's an interesting and idiosyncratically perlish way of
> coping with the multiple possible return values from fork()?
Presuming that the parity of a pid is potentially of interest to anyone.
I am liking Uri's EVENing OTTers more and more.
:-)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 4 Aug 1999 16:01:14 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Jeoparder's Jest
Message-Id: <37a8b82a@cs.colorado.edu>
In comp.lang.perl.misc, lr@hpl.hp.com (Larry Rosler) writes:
:I am liking Uri's EVENing OTTers more and more.
No reason to reveal the joke. If they don't get it, no need
to hit them over the head with it.
--tom
--
There are still some other things to do, so don't think if I didn't fix
your favorite bug that your bug report is in the bit bucket. (It may be,
but don't think it. :-) Larry Wall in <7238@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Wed, 4 Aug 1999 15:40:36 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Perl counter muckup
Message-Id: <x3yn1w7cp1n.fsf@tigre.matrox.com>
Richard Lawrence <ralawrence@my-deja.com> writes:
> I have written a small webpage counter (no big deal) in Perl and yet
> every so often it resets itself (well, it reset itself today and had
> been going for about 7 months before then). I've come to the not-so-
> unreasonable conclusion that its my perl that is at fault. Could anyone
> point me to what I've done wrong that makes this counter currently
> unreliable please?
Well, since it worked fine for several months, I would think that your
code is fine and the problem is elsewhere.
Looking at your code I see two errors, both of which *MIGHT* have given
you an idea of what the problem is.
> #!/usr/bin/perl
1st error. Always use the '-w' switch here.
> # a simple counter by Rich
>
> use strict;
> use 5.004;
> use Fcntl qw(:flock);
>
> my $from = $ENV{'REMOTE_HOST'};
>
> # realised that I have no idea how to just read one line from
> # a file - this seems to work although I suspect its bad perl.
No .. this is the correct way to read one line from a file. I wouldn't
save that line to $_ though. Choose some other variable since $_ can
very easily get updated; and very often.
> open (SITE, "counter.dat");
2nd error. You don't check the result of your open().
open SITE, "counter.dat" or
die "Error reading 'counter.dat': $!\n";
If (somehow) the file "counter.dat" was deleted, then the open() would
fail, but you won't know.
> $_ = <SITE>; # urg?
> chomp;
> close SITE;
>
> # split the details up
>
> my @details = split(/ /);
So ... if your open() above failed, @details will be an empty array.
And $details[0] will be undefined. But the statement
$details[0]++
will make $details[0] == 1 although it would've warned you about it if
you had the '-w' switch on.
HHT,
Ala
------------------------------
Date: 3 Aug 1999 22:04:43 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl seems to be LAME!
Message-Id: <7o7p1r$5jd$1@gellyfish.btinternet.com>
On Tue, 03 Aug 1999 23:19:57 +0200 Moritz Mertinkat wrote:
Subject: Perl seems to be LAME!
Oh deary deary deary me. In the midst of the newbie backlash this has to
come from under its bridge.
> I'm using a text file (~1.11 MB) with about 10000 entries
> for searching. Now, when I just run through all the lines
> - without even doing *anything* - it takes up to 7 seconds!
> And with the search algorithm about 11 seconds!
>
> ------------------------------------
>
> Here's the code snippet:
>
> $found = 0;
>
> foreach $line (<FILE>) {
>
> $match = 0;
>
> foreach $term (@query) {
>
> # Perform case insensitive comparison
>
> if (!($line =~ /$term/i)) {
>
> # Term did not match.
> $match = 0;
> last;
>
> } else {
>
> # Term matched
> $match = 1;
>
>
> }
> }
>
>
> if ($match == 1) {
> $found = 1;
>
> print "$line<br>\n";
> }
>
> }
>
Your method bears an uncanny similarity to the following from perlfaq6:
=head2 How do I efficiently match many regular expressions at once?
The following is super-inefficient:
while (<FH>) {
foreach $pat (@patterns) {
if ( /$pat/ ) {
# do something
}
}
}
note the term 'super-inefficient' here. I would suggest you read the
remainder of that item before you go any further with this.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Wed, 04 Aug 1999 14:29:02 -0700
From: Biju Abraham <biju.abraham@ebay.sun.com>
Subject: Re: Perl vs HTML
Message-Id: <37A8B09E.D6962EDB@ebay.sun.com>
How are you receiving the value to $ch ? If its within perl, then you
will have
$ch = " <A HREF=\"/toto/titi.html\" ></A> ";
Then there should not be any problem.
Try this
$ch =~
s/^(.*?href\s*=\s*)(\"*|\'*)(.*?)("*|'*)(\s*>\s*.*$)/$1$2hello.html$4$5/i;
Biju
YANG Tong wrote:
>
> Hi,
>
> Just a question: with HTML we can write *crazy* code... And with Perl
> I must manipulate all this HTML particularities...
>
> So how can I do, if I want someting like :
>
> $ch=" <A HREF=/toto/titi.html ></A> ";
> $ch=~s/(^.*?href\s*=\s*)("|'|)(.*?)(\1|\s|>)(.*$)/$1$2hello.html$4$5/i;
>
> In fact I want to recup the link (/toto/titi.html); treat it and replace
> it ! The problem is the symbol " or ' or nothing ...
>
> Thanks.
------------------------------
Date: Wed, 4 Aug 1999 15:50:25 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Please Help with regex
Message-Id: <x3ylnbrcola.fsf@tigre.matrox.com>
"Pieter Brouwer" <p.brouwer@prevalent.nl> writes:
> I'm trying to strip a piece of text out of a string. The text that need to
> be stripped from the string should start with "/*" and ends with "*/". This
> can be nested and spanning multiple lines.
Your question is a FAQ. From perlfaq6:
How do I use a regular expression to strip C style comments
from a file?
Always consult the FAQs first. They are more complete than what you
think.
HTH,
Ala
------------------------------
Date: Wed, 04 Aug 1999 14:00:48 -0700
From: Biju Abraham <biju.abraham@ebay.sun.com>
Subject: Re: reading in multiple unknown files and writing to it
Message-Id: <37A8AA00.E5FD18F3@ebay.sun.com>
Try this...
$dirname = ".";
opendir(DIR,$dirname);
@files = grep(/.*\.dat/, readdir(DIR));
foreach $file (@files) {
open(FILEHD,">$file");
seek (FILEHD,0,0);
printf(FILEHD "Written");
close (FILEHD);
}
Biju
quyluu@my-deja.com wrote:
>
> Hi Im trying to open all *.txt files in a directory and append to
> the beginning of the file. I know my appending part is not correct,
> but I cannot seem to be able to open *.txt files in a dir, for writing,
> just raeding.
>
> Here is one of the things i've tried:
>
> while(open(FILE,<*.txt>)) {
> print ("Opening works!\n");
>
> seek FILE,0,0; #this statement doesnt seem tow ork
> write(FILE,"IT WORKS!"); #this doesn't cuz i can't open it for
> #writing
> close(FILE);
> }
>
> I've tried...doing open(FILE,">*.txt") doesn't work
>
> Any help is GREATLY Appreciated!
>
> Kevin
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
------------------------------
Date: 3 Aug 1999 22:05:58 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: tar
Message-Id: <7o7p46$5jg$1@gellyfish.btinternet.com>
On Tue, 03 Aug 1999 22:09:45 +0100 Peter wrote:
> I don't really know that much about unix, but if I download a file of
> type .tar how do I open/decompress it?
>
I would find out all about it with:
man tar
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Wed, 4 Aug 1999 14:26:34 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: towards uploading binary files...
Message-Id: <MPG.12124fe1c56cf5c7989dca@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7oa4hj$sln$1@nnrp1.deja.com> on Wed, 04 Aug 1999 19:33:07
GMT, irf@netexecutive.com <irf@netexecutive.com> says...
[omitting the attribution of the quotes to our beloved Abigail]
> >> hi i am relatively new to perl & :
> >You are new to colons?
> read it like someone cool be sayin it (urrk)
>
> %% read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> %% $dat=$buffer;
>
> >THAT IS WRONG!
>
> eh? no it's not. i'm using it now, and thanks to a nudge from sexy larry
> (what a great pic on your homepage, man) :)
I expect to find a spike in my access log. You should see the picture
in my attic, though.
> it works. it's better to
> check bytes,and this whole thing is probably ultra-insecure, but it
> isn't WRONG.
It is correct, provided the 'POST' method is used, which you could check
for. I always allow only one access method per program, usually 'POST'.
> >What if you don't read enough? Why don't you use 'use CGI;'?
> because i'm a fussy little satan, and i want to know how to parse it
> myself. don't ask why :)
That is the way I learned about CGI. And having learned it (and HTML
before that) and having created a small personal library of utility
functions, I don't need CGI.pm. But you and I are probably not typical.
I have since bought and read Lincoln Stein's book, and find the host of
subroutine interfaces to generate HTML to be Yet Another Little Language
to learn, so what's the point? (It has its own set of gotchas, such as
'td => ...' but 'Tr => ...'. Yuk.)
...
> anyway, here's the code that works, if anyone cares for it. i'd
> appreciate it if someone could tell me if my bytes-checking is correct
> (see the $bytesread variable)
> --------------------------------------------------
> print "Content-type: image/gif\n\n";
> binmode(STDIN);
> $bytesRead=read(STDIN, $dat, $ENV{'CONTENT_LENGTH'});
> if ($bytesRead==$ENV{'CONTENT_LENGTH'}){
I would prefer to die with an error message if it doesn't match.
> $dat=~s/.*\n.*\n.*\n//;
> $dat=~s/\-+\d+\-+//;
> $dat=~s/\n//;
> $dat=~s/\r//;
> binmode (STDOUT);
> print "$dat";
The quotes aound a simple variable are superfluous and misleading.
> }
Have fun!
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 04 Aug 1999 21:07:50 GMT
From: Andrew Hearn <a_s_hearn@yahoo.com>
Subject: Wanted: Perl Script to parse email headers and body
Message-Id: <7oaa2t$159$1@nnrp1.deja.com>
Hello,
I am looking foer a per script that will take an email as STDIN and then
parse it so that the header information is stored in name/value pairs
and the body is put into a string or something.
I have seen what Majordomo uses, but this only strips the Header
information.
Thank you very much.
Andrew Hearn
a_s_hearn@yahoo.com
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 4 Aug 1999 22:05:34 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Wanted: Perl Script to parse email headers and body
Message-Id: <7oadfe$paf$2@info2.uah.edu>
In article <7oaa2t$159$1@nnrp1.deja.com>,
Andrew Hearn <a_s_hearn@yahoo.com> writes:
: I am looking foer a per script that will take an email as STDIN and then
: parse it so that the header information is stored in name/value pairs
: and the body is put into a string or something.
Check out Graham Barr's Mail-Tools distribution on the CPAN.
Greg
--
Fenster: I had a guy's fingers in my asshole tonight.
Hockney: Is it Friday already?
------------------------------
Date: Wed, 04 Aug 1999 21:06:26 GMT
From: Makarand Kulkarni <makarand_kulkarni@my-deja.com>
Subject: Re: while loop teminates too early
Message-Id: <7oaa09$tq$1@nnrp1.deja.com>
[In article <37A89BC0.E073F6EC@uiuc.edu>,
Andy Collado <acollado@uiuc.edu> wrote:]
> I have a while loop that should verify that a user
> is valid, but it will only validate whoever
>is the first user in the user file.
You need not call exit; inside the while.
So after it decides whether there was a
match or not on the first line it will exit.
-Makarand
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 4 Aug 1999 15:07:02 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Why is it....
Message-Id: <37a8ab76@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc, feinster@my-deja.com writes:
:gee... it just maybe _possibly_ might be easier to ASK a question in a
:newsgroup rather than spend hours searching through the docs... ya'
:think?
You've hit the nail on the head here, and you know what? It's completely
unacceptable. Our time is *not* worth less than your time. In fact,
amortized over the thousands and thousands of readers around the world
whom you have in this fashion inconvenienced, the crime is compounded
to a point of unconscionablely self-centered thievery?
Why in the name of all that is automatable didn't it ever occur to you
that if it takes you "hours to search through the docs" that you are doing
something FUNDAMENTALLY BRAIN-DAMAGED AND UTTERLY WRONG-HEADED? This is
an issue that should take you no more than a matter of a few seconds,
not hours! You're sitting in front of a COMPUTER! For goodness sake,
man, either learn how to use it or else give it to somebody who can.
--tom
--
I took you for a shallow lazy misguided opportunist who could be bought for a
cheap token gift
------------------------------
Date: 4 Aug 1999 21:09:47 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: Why is it....
Message-Id: <slrn7qhb50.3ej.fl_aggie@thepentagon.com>
On Wed, 04 Aug 1999 19:48:35 GMT, John Casey <jcasey@workingventures.ca>, in
<37a898b8.109056685@wv-proxy> wrote:
+ When you figure out how to hook a database up to a web page with full
+ view/modify/add/delete capability then we will be impressed...we will
+ still think you are a boastful ass hole though.
That's been done. The solution is known. That's a boring problem.
James
------------------------------
Date: 4 Aug 1999 21:01:06 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: Why is it....
Message-Id: <slrn7qhako.3ej.fl_aggie@thepentagon.com>
On Wed, 04 Aug 1999 19:34:10 GMT, feinster@my-deja.com
<feinster@my-deja.com>, in <7oa4jh$sm7$1@nnrp1.deja.com> wrote:
+ gee... it just maybe _possibly_ might be easier to ASK a question in a
+ newsgroup rather than spend hours searching through the docs... ya'
+ think?
No, I don't. If you have to spend hours searching the docs, you may want
to consider a different line of work...
James
------------------------------
Date: Wed, 4 Aug 1999 14:14:42 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Why is it....
Message-Id: <MPG.12124d18f41205dd989dc7@nntp.hpl.hp.com>
In article <7oa6kp$njb$1@info2.uah.edu> on 4 Aug 1999 20:08:57 GMT, Greg
Bacon <gbacon@itsc.uah.edu> says...
> In article <MPG.12122761cffe50ed989dc1@nntp.hpl.hp.com>,
> lr@hpl.hp.com (Larry Rosler) writes:
> : Some are born programmers, some achieve programming, and some have
> : programming thrust upon 'em.
>
> Some are born physicians, some achieve medicine, and some have medicine
> thrust upon 'em.
>
> How ridiculous does that sound?
>
> : Too many of the latter these days, I trow! But there is lots of hope
> : for the middle class, especially with modern tools and with this kind
> : of newsgroup support.
>
> Perhaps we can improve the state of health care by providing newsgroup
> support and more modern tools too.
>
> Get serious.
I am serious. Very serious.
For generations, IBM used the Mongol Horde approach to programming --
put low-paid programmers in a big room and have them implement specs
written by gurus. IBM made tons of money, no matter what we may think
about the quality of the products. And now Micro$oft has done the same.
Your analogy to medical care is somewhat bogus. Though even there, many
HMOs employ journeymen physicians, and those patients who don't have the
freedom to choose their physicians are stuck with them. And maybe
newsgroup support and modern tools would help them also.
But beware physicians who have had medicine thrust upon 'em.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 4 Aug 1999 22:04:54 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Why is it....
Message-Id: <7oade6$paf$1@info2.uah.edu>
In article <MPG.12124d18f41205dd989dc7@nntp.hpl.hp.com>,
lr@hpl.hp.com (Larry Rosler) writes:
: For generations, IBM used the Mongol Horde approach to programming --
: put low-paid programmers in a big room and have them implement specs
: written by gurus. IBM made tons of money, no matter what we may think
: about the quality of the products.
What's your point? Are you claiming that programmers who earn low
salaries are necessarily bad programmers?
: And now Micro$oft has done the same.
False. The RFCs (arguably written by gurus) are available, but
Microsoft just ignores them. They implement software that loosely
resembles but doesn't adhere to those standards. Don't believe for
a second that it isn't intentional.
: Your analogy to medical care is somewhat bogus.
That's why they call it reductio ad absurdum.
: Though even there, many HMOs employ journeymen physicians, and those
: patients who don't have the freedom to choose their physicians are
: stuck with them. And maybe newsgroup support and modern tools would
: help them also.
Would you go to a doctor who was a recent graduate of the "Get Your
MD in 21 Days" program? Would you go to him even if he had great
tools and access to Usenet?
Would you want your children in a classroom with a teacher who was a
recent graduate of the "Get Your Teaching Certificate in 21 Days"
program? Even if he had great books and access to Usenet?
Would you take your car to a someone who was a recent graduate of
the "Learn to Fix Cars in 21 Days" program? Even if he had great
tools and access to Usenet?
One doesn't develop the knowledge and experience to render professional
services overnight. To qualify as anything more than a hobbyist, one
needs talent and other natural gifts.
Greg
--
In the end, we had a visit from an embarrassed Digital Special Systems guy
who found an unused inverter pin and added some white wires. These days,
such a problem would be harder to fix in the field.
-- dmr
------------------------------
Date: Wed, 04 Aug 1999 17:18:28 -0400
From: HC <carvdawg@patriot.net>
Subject: Re: Working Telnet Script Needed
Message-Id: <37A8AE24.BA1BD194@patriot.net>
> So I vote for giving him a break. Today,
> anyway. :-)
Dave,
Thanks. Much appreciated.
Carv
------------------------------
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". 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 V9 Issue 371
*************************************