[16626] in Perl-Users-Digest
Perl-Users Digest, Issue: 4038 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 17 00:05:33 2000
Date: Wed, 16 Aug 2000 21:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <966485112-v9-i4038@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 16 Aug 2000 Volume: 9 Number: 4038
Today's topics:
Re: About Net::Ping <s24673@sp.edu.sg>
anyone know why when I add tr /a-z/A-Z/s i get ERRORS <star@sonic.net>
Re: anyone know why when I add tr /a-z/A-Z/s i get ERRO (Gwyn Judd)
Re: anyone know why when I add tr /a-z/A-Z/s i get ERRO <elephant@squirrelgroup.com>
Re: Array Printing (Gwyn Judd)
Re: array weirdness. <elephant@squirrelgroup.com>
Re: Articles, Stories ... <godzilla@stomp.stomp.tokyo>
Re: Articles, Stories ... <elephant@squirrelgroup.com>
Checking if variables exist <vrillusions@mail.com>
Re: cross platform newline processing <bwalton@rochester.rr.com>
Re: FileHandle in array <abe@ztreet.demon.nl>
Re: Fork & Waitpid (Gwyn Judd)
Help with regex <jab120@student.cs.york.ac.uk>
Re: Image Manipulation Question <eliste@demokratik.net>
Re: LWP question (J.D. Silvester)
md5 metza@my-deja.com
Re: md5 <elephant@squirrelgroup.com>
Re: Negativity in Newsgroup...Newbie Perspective <whataman@home.com>
Re: perl 5.6 (Gwyn Judd)
Re: Replacing lines in a file (Gwyn Judd)
Re: rollback perlcc'd binary to perl code (Gwyn Judd)
Re: sorting ?? <elephant@squirrelgroup.com>
Re: Split Stumper <godzilla@stomp.stomp.tokyo>
Re: Split Stumper <jkline@one.net>
Re: Split Stumper <abe@ztreet.demon.nl>
Re: Split Stumper <sturman@midsouth.rr.com>
Re: Split Stumper <elephant@squirrelgroup.com>
Re: Split Stumper (Gwyn Judd)
Time stamp on Bulletin Board <gallantknave@my-deja.com>
Re: Time stamp on Bulletin Board <elephant@squirrelgroup.com>
Re: uninitialized value??? <bwalton@rochester.rr.com>
Re: windows headache <yhvhboy1@home.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 17 Aug 2000 09:21:46 +0800
From: "s24673" <s24673@sp.edu.sg>
Subject: Re: About Net::Ping
Message-Id: <399b3e2b.0@scctn03.sp.edu.sg>
I was trying to check this out and it did not even work with hostname. I am
using v5.003_07.
Does anyone have any experience with using ping in Perl on Win NT?
Alan Hopper <aahopper@mailbox.ucdavis.edu> wrote in message
news:Pine.GSO.4.21.0008161434050.7730-100000@sandman.ucdavis.edu...
> I am trying a very simple script using the Net::Ping module.
> Whenever I use a hostname this command works fine:
>
> $p = Net::Ping->new();
> print "Found $host\n" if $p->ping($host);
>
> but if I use an ip address it does not work:
>
> $p = Net::Ping->new();
> print "Found $host\n" if $p->ping("xxx.xxx.xxx.xxx");
>
> The documentation for Net::Ping says that both a hostname and an ip
> address are valid. Inside the Net::Ping module I found that the function
> inet_aton was called to tranlate the ip address into something
> useful. According to what I see everything should work. Any suggestions on
> what is wrong or where I can look?
>
> Alan
>
------------------------------
Date: Thu, 17 Aug 2000 01:15:35 GMT
From: arthur <star@sonic.net>
Subject: anyone know why when I add tr /a-z/A-Z/s i get ERRORS
Message-Id: <B5BFE201.648B%star@sonic.net>
Good Day,
I have a script below that works but when I want to make the output in the
files be all uppercase I can't. I know I have to add tr /a-z/A-Z/s and I
have tried every which way but I get malformed header errors or compile
errors every time.
Can some one help, please.
~arthur
star@sonic.net
#!/usr/bin/perl -w
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use IO File;
use strict;
use File::Copy;
print header;
print start_html('A Simple Example'),
start_form,
"What are your questions? ",textfield('question'),
p,
"What are your answers? ",textfield('answer'),
p,
submit,
end_form,
hr;
if (param()) {
print
"Your questions are: ",em(param('question')),
p,
"The answers are: ",em(param('answer')),
p,
open (HOPE, ">/home/www_pages/star/dat.html") || die print "cant open:$!\n";
print (HOPE (param('question')));
close HOPE;
open (YES, ">/home/www_pages/star/dot.html") || die print "cant open: $!\n";
print (YES (param('answer')));
print (YES (param('answer')));
p;
hr;
print end_html;
}
------------------------------
Date: Thu, 17 Aug 2000 02:47:43 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: anyone know why when I add tr /a-z/A-Z/s i get ERRORS
Message-Id: <slrn8pmki9.qj4.tjla@thislove.dyndns.org>
I was shocked! How could arthur <star@sonic.net>
say such a terrible thing:
>Good Day,
>
>I have a script below that works but when I want to make the output in the
>files be all uppercase I can't. I know I have to add tr /a-z/A-Z/s and I
No you don't. What is wrong with uc()?
perldoc -f uc
>have tried every which way but I get malformed header errors or compile
>errors every time.
Well the script you posted didn't use "tr" or "uc" for that matter. My
guess is you have a bug. Hope that helps.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Fortune's real live weird band names #572:
Rectal Nightmare
------------------------------
Date: Thu, 17 Aug 2000 02:52:41 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: anyone know why when I add tr /a-z/A-Z/s i get ERRORS
Message-Id: <MPG.1405f0e1cb76a3d39896bb@localhost>
arthur wrote ..
>I have a script below that works but when I want to make the output in the
>files be all uppercase I can't. I know I have to add tr /a-z/A-Z/s and I
>have tried every which way but I get malformed header errors or compile
>errors every time.
well .. without actually seeing where you're putting that tr/// it's
impossible to tell exactly why you're getting these errors (showing code
is useless if you show code that has nothing to do with the problem)
I'm guessing that you have no idea what the 's' modifier does to tr///
.. you almost certainly do not want to be using it if you're just trying
to convert lowercase to uppercase
you should have a read of the documentation on tr/// in perlop .. it
quite clearly explains and demonstrates what the 's' modifier does
perldoc perlop
then you should have a read of the documentation for the uc function ..
that's probably what you want anyway - it's a solution with an
international flavour
perldoc -f uc
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Thu, 17 Aug 2000 02:08:35 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Array Printing
Message-Id: <slrn8pmi8u.qj4.tjla@thislove.dyndns.org>
I was shocked! How could jason <elephant@squirrelgroup.com>
say such a terrible thing:
>Gwyn Judd wrote ..
>>Or even:
>>
>>$, = "\n";
>>print @block;
>
>eek .. please - never pass up a genuine opportunity to use 'local'
>
> {
> local $, = "\n";
> print @block;
> }
Very true
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Two roads diverged in a wood, and I -- I took the one less travelled by,
and that has made all the difference.
-Robert Frost, "The Road Not Taken"
------------------------------
Date: Thu, 17 Aug 2000 02:03:27 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: array weirdness.
Message-Id: <MPG.1405e55c280f32d99896b8@localhost>
Teodor Zlatanov wrote ..
><MPG.1403d3ee4b63494798ac82@nntp.hpl.hp.com>:Larry Rosler (lr@hpl.hp.com):comp.
>: In article <8nd91k$naj$1@nnrp1.deja.com>, johnvert@my-deja.com says...
>: > Hi, this question may seem trivial, but I can't find a logical
>: > explanation for it: why does:
>: > my @list=([1,2,3,4,5]);
>: > print @{$list[0]};
>: >
>: > outputs the string: 12345
>: > while: print "@{$list[0]}";
>: > outputs the string: 1 2 3 4 5?
>:
>: perlfaq5: "Why do I get weird spaces when I
>: print an array of lines?"
>
>I think he might want to look at perlvar for $" and $, as well :) This was
>just asked in an earlier thread.
yeah .. IMHO the FAQ document should contain references to those vars ..
the explanation in perlfaq5 is fairly dumbed down
[ lines over 80 chars truncated ]
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Wed, 16 Aug 2000 18:07:11 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Articles, Stories ...
Message-Id: <399B3ABF.96756B81@stomp.stomp.tokyo>
JoeB wrote:
You must be Joe Blow. I have heard many
a tall tale told about you. I would rather
hear a tall tale of tail though.
> Being fed up with some of the in-adequacies
> of printed magazines etc...
So don't read articles written by lousy writers,
better known as technical journalists.
> I have decided to publish a magazine, which
> will hopefully fill the gap left by the big
> publishing houses.
I am under contractual obligation with Random
House and Bantam Books. Who is your publisher?
> As a result, I am looking for stories, articles
> about PERL that will make a good read for the
> techie or for the beginner or a decision maker.
*gags*
Looking to create another boring Reader's Digust?
You are a result? Never met a result before.
Tell me of your Resultian culture.
$his_comments =~ s/,/and/;
$his_comments =~ s/that/which/;
$his_comments =~ s/the/a/g;
> If you feel you have something to say or share
> with others, then please let me have your story...
Chances are good I would placed under arrest
should I share my stories and thoughts on Perl
and our Perl community. At very best, I would
only suffer a severe beating in a dark alley.
> of course full credits will be given to
> you in the publication.
You are joking of course. My standard fee
is five-hundred dollars for a short essay,
one-thousand dollars for an article, oh my,
two-thousand-five-hundred for a short story
and somewhere in the range of twenty-thousand
to fifty-thousand for a full length story.
Sequels due to popular demand are a flat fee
of one-hundred-thousand per sequel. Supply
and Demand, you know.
I might dismiss my ten percent thirty year
royalty draw for a magazine such as yours.
However, movie rights I retain, always.
Interested? I can guarantee if you publish
my articles about Perl and my Perl related
stories, out in public, people will set upon
you with stones, clubs and kitchen spatulas.
I will also say local villagers will surround
your old Brownstone at night, chanting, jeering
and waving around flaming torches, hanging nooses
and pitchforks, all with great animation, much
like villagers in Charleton Heston's _Omega Man_.
Should you wisely decide to employ my crafty
talent, practice a mimic of Charleton Heston
crucified, sans wood cross. This will be a
handy and rather eye catching talent.
Godzilla!
--
Solyent Green is PEOPLE!
------------------------------
Date: Thu, 17 Aug 2000 02:39:30 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Articles, Stories ...
Message-Id: <MPG.1405edcd4154abfb9896ba@localhost>
JoeB wrote ..
>Being fed up with some of the in-adequacies of printed magazines etc...
>I have decided to publish a magazine, which will hopefully fill the
>gap left by the big publishing houses.
a gap not already filled by TPJ ? .. interesting
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Thu, 17 Aug 2000 03:58:29 GMT
From: Todd Eddy <vrillusions@mail.com>
Subject: Checking if variables exist
Message-Id: <399B62F0.ECAA3F0D@mail.com>
Here is what I have:
if ($FORM{'realname'} && $FORM{'callsign'} && $FORM{'computer'} &&
$FORM{'email'} && $FORM{'location'}) { $required = "yes"; }
else { die "You did not enter a required field, please make corrections
and try again"; }
Doesn't that mean that if all of those exist, it will set $required to
yes? and if one of those don't exist it will die? then how come when I
have those two lines in the script, I get an error saying that the page
contains no data in netscape and IE I just get a blank page?
--
Todd Eddy
vrillusions@mail.com
http://www.vrillusions.com/
------------------------------
Date: Thu, 17 Aug 2000 03:43:33 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: cross platform newline processing
Message-Id: <399B5F92.E46F8974@rochester.rr.com>
Mark Johnson wrote:
>
> Hi,
> I need to read text files line by line. Problem is these text files
> may have been created on Mac, PC or unix. As a consequence I don't know
> whether the newline code is CR or LF or CR LF.
> I have searched FAQs on CPAN and at www.perl.com, but I can't find
> anything that deals with this situation. Can anybody point me in the
> direction of a solution?
...
> Mark
>
> p.s. The program will be running on a unix box if that matters.
Mark, you should find that Perl will DTRT (do the right thing) in this
case (it does on Windoze, anyway). It should treat "\012", "\015", and
"\015\012" all just like either of these sequences is a "\n" on input.
On output, a "\n" will generate the line separator that is appropriate
for your system. If you find the preceding not to be the case, try
looking up the $/ and $\ variables.
perldoc perlport
perldoc perlvar
Hope that helps.
--
Bob Walton
------------------------------
Date: Thu, 17 Aug 2000 04:07:20 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: FileHandle in array
Message-Id: <80hmps4gcj473g38nqdiv7ok991pln0peh@4ax.com>
On Thu, 17 Aug 2000 00:47:27 GMT, ceeeya <ceeeya@my-deja.com> wrote:
> Newbie question here for which I poked around but couldn't satisfy my
> question so here goes:
Stick with it and peek some more :-)
> Is there any way to reference the file handle in the array without
> resorting to a temporary variable?:
>
> @files = (
> [ "file0.txt", new FileHandle ],
> [ "file1.txt", new FileHandle ],
> [ "file2.txt", new FileHandle ]
> );
>
for my $file (@files) {
open $file->[1], $file->[0] or
die "Can't open[r] '$file->[0]': $!";
while ( readline $file->[1] ) {
print;
}
close $file->[1];
}
See the section "I/O Operators" in perlop and
perldoc -f readline
For printing to $file->[1] see the entry for 'print' in the perlfunc
manpage:
perldoc -f print
--
Good luck,
Abe
------------------------------
Date: Thu, 17 Aug 2000 03:06:45 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Fork & Waitpid
Message-Id: <slrn8pmlm1.qj4.tjla@thislove.dyndns.org>
I was shocked! How could andrewjasper@my-deja.com <andrewjasper@my-deja.com>
say such a terrible thing:
>I'm using fork and waitpid, but waitpid keeps returning an error value
>of 256 after the process has already been forked.
>
>Does anyone have any ideas?
Hmm I think you should read "perldoc perlvar" for an explanation of what
$? actually is. You need to do something like "$? >> 8" to get the exit
value. This will tell you that the exit() return value of your child
process was 1.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Systems people do it with a small, but clean, interface.
------------------------------
Date: Thu, 17 Aug 2000 04:58:28 +0100
From: Jeffri AB <jab120@student.cs.york.ac.uk>
Subject: Help with regex
Message-Id: <399B62E4.B84BF5F7@student.cs.york.ac.uk>
Hi,
I'm writing an application that will extract the contents between
HTML-like tags. I've managed to come out with something but it works
fine with only 1 pair of tags. Here's what I've done:
$body =~ s#<$tag>([\w\W]*?)</$tag>#\1#gm;
$body =~ s#<(.*?)>[\w\W]*?</\1>##gm;
I need help to come out with a regex that'll process nested tags as
well. E.g., if I have:
<aa>aa<bb>bb</bb>aa</aa>
extracting the contents of {aa}: aabbaa
extracting the contents of {bb}: bb
I need it quite desperately. Thanks!
------------------------------
Date: Thu, 17 Aug 2000 03:55:11 GMT
From: Oktay <eliste@demokratik.net>
Subject: Re: Image Manipulation Question
Message-Id: <399B610F.887E9462@demokratik.net>
http://sybermedia.homeip.net/autogallery/
James wrote:
>
> Does anyone know of any routines, scripts or recommendations on creating a
> script that would take
> a directory of images and create a new directory of those
> same images - only shrunken in size?
>
> Basically a script that would make REAL thumbnails
> from images in a certain directory.
>
> I'm guessing the GD module might need to be used, but don't know...
>
> Any help would be appreciated!
>
> P.S. If you want a good laugh, check out:
>
> http://www.nutsackdance.com
--
_______________________________
http://demokratik.net
ucretsiz isminiz@demokratik.net
formatinda eposta hesabi ve
"HERKESE AMA HERKESE SOZ HAKKI"
------------------------------
Date: 17 Aug 2000 03:04:50 GMT
From: jsilves@julian.uwo.ca (J.D. Silvester)
Subject: Re: LWP question
Message-Id: <8nfkoi$i74$1@panther.uwo.ca>
On 16 Aug 2000 15:00:48 GMT J.D. Silvester (jsilves@julian.uwo.ca) wrote:
: I was playing around with LWP to try it out and I was wondering something.
: I was able to use a script to retrieve the contents of a web page and
: display it in my browser however, no images were returned. I assume that
: I would have to parse the HTML as it is coming back, look for image tags
: and generate requests for the images. My question is this: If I didn't
Thanks to all who responded!
------------------------------
Date: Thu, 17 Aug 2000 01:47:04 GMT
From: metza@my-deja.com
Subject: md5
Message-Id: <8nfg6j$auk$1@nnrp1.deja.com>
Hi
I'm using active perl, and have downloaded a module that requires
md5.pm (I assume, it contains the the line:
use md5 )
Can anyone tell me where to get it?
Thanks in advance
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 17 Aug 2000 02:54:51 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: md5
Message-Id: <MPG.1405f169e303e3409896bc@localhost>
metza@my-deja.com wrote ..
>I'm using active perl, and have downloaded a module that requires
>md5.pm (I assume, it contains the the line:
>use md5 )
>
>Can anyone tell me where to get it?
in a Windows command prompt type
ppm install md5
otherwise - go to CPAN
http://www.cpan.org/
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Thu, 17 Aug 2000 03:42:32 GMT
From: "What A Man !" <whataman@home.com>
Subject: Re: Negativity in Newsgroup...Newbie Perspective
Message-Id: <399B5F63.50E00423@home.com>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
To answer your question, Randall, this is one of your posts where I understood
you to be saying that if someone doesn't "get it" they should "stay out
of coding." To me, that's arrogant, and has nothing to do with netiquette...
though I think you knew that already. The whole tone of your reply to Petri,
below, appears to support a superior attitude. FWIW, I didn't come to that
conclusion on this one post of yours. Another post of yours that you refer
to below also seems to support that. I hope that I misunderstood.
<p>Regards,
<br>--Dennis(aka BUCKNAKED)
<p>Subject: Re: Why won't "use strict;" work?
<br>Date: 07/27/2000
<br>Author: Randal L. Schwartz <merlyn@stonehenge.com>
<p>Variable scoping - some people get it, some people don't. I wish
the people that don't get it would stay out of writing code, or especially
sharing code. But that's just my opinion. For what it's worth.
<br>
<br>Programming is a weird art. The money to be made programming
has attracted a lot of people who really don't belong in the biz.
It's ok to tinker on your own time, but I see people come through my classes
every week that just really shouldn't be paid as programmers. They
string together things with cut-n-paste at random. They seem to lack
the ability to take a concrete example and abstract the essence from it.
And yet they've been placed into jobs requiring such skills, either because
the employers are so desperate, or they're really good at BS'ing themselves
or their future bosses.
<br>
<br>My rule of thumb - anyone who thinks that the act of programming is
worth less than $50/hr should leave the industry. :)
<br>
<br>(OK, I'll get flamed on that, but it would sure help me distinguish
what I *can* do in an hour from what most people *attempt* to do in an
hour. :)
<br>
<br>
<blockquote TYPE=CITE>Randall Schwartz said:
<p>You mean the part where I said "newbies are welcome to post here, and
<br>we expect them to follow the normal Usenet Nettiquette"?
<p>What part of that counts as "attitude"?
<p>Seriously, I'm genuinely curious. What are you expecting CLPM
to be?
<br>And how is that different from what it is?
<p>--
<br>Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503
777 0095
<br><merlyn@stonehenge.com> <URL:<a href="http://www.stonehenge.com/merlyn/">http://www.stonehenge.com/merlyn/</a>>
<br>Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
<br>See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl
training!</blockquote>
</html>
------------------------------
Date: Thu, 17 Aug 2000 03:13:12 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: perl 5.6
Message-Id: <slrn8pmm1v.qj4.tjla@thislove.dyndns.org>
I was shocked! How could dwb1@home.com <dwb1@home.com>
say such a terrible thing:
>
>Hello,
>
>I'm about to upgrade some servers from perl 5.005_03 to 5.6. I'm
>wondering if there are any traps I should watch out for. We have
>an aweful lot of source code written in perl, (near 200000 lines
>of code), so I'm naturally concerned.
>
>Any opinions/feedback/warnings would be greatly appreciated.
RUN AWAY! RUN AWAY WHILE YOU STILL CAN!!!
err...I mean...Of course it should just work :) Actually I think you
might like to hold off till 5.6.1 is released.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
"Now this is a totally brain damaged algorithm. Gag me with a smurfette."
-- P. Buhr, Computer Science 354
------------------------------
Date: Thu, 17 Aug 2000 02:22:58 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Replacing lines in a file
Message-Id: <slrn8pmj3s.qj4.tjla@thislove.dyndns.org>
I was shocked! How could Lincoln Marr <lincolnmarr@nospam.europem01.nt.com>
say such a terrible thing:
>> perl -nie 'BEGIN{$key='THEKEY'} print if /^$key|\/';
>
>that didn't help either; am I doing something wrong? :
>
>#!/bin/perl
>$file = "file.txt";
>open(FILE,"$file") || die "error opening file, $!\n";
>perl -nie 'BEGIN{$key='key1'} print if /^$key|\/';
>close(FILE);
>
>I made the file (file.txt) and put in the first line
>'key1|field|text|here|...' and then chmodded it to 777 (just to be safe) but
>the test script says:
>
>String operator found where operator expected at temp.cgi line 4, near "nie
>'BEGIN{$key='" (Do you need to predeclare nie?)
>syntax error....
>Bad name after key1:: at temp.cgi line 4.
yes. He means you should type:
perl -nie 'BEGIN{$key='THEKEY'} print if /^$key|\/';
At the command line. You note the prescence of the word "perl" in that
line? That means to tell perl to do that thing. There is no point
putting that in a perl script like that. An equivalent script would be
something like (you should look in "perldoc perlrun" to see what is an
exactly equivalent script):
#!/usr/bin/perl
$key = 'THEKEY';
while (<>)
{
print if /^$key|\/;
}
You may or may not know that the script I typed and the command he gave
you has a number of bugs:
1) He didn't use the "-w" switch.
2) His command doesn't even execute. It should have been:
perl -ni -e 'BEGIN{$key='THEKEY'} print if /^$key\|/';
3) I didn't "use strict"
4) It doesn't do what you asked. His (and mine) only print lines which
match $key, whereas I think from memory you wanted it the other way
around.
A better script would be something like this:
#!/usr/bin/perl -w
use strict;
my $key = 'THEKEY';
while (<>)
{
print unless /^$key\|/;
}
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
If a person feels he can't communicate, the least he can do is shut up
about it.
-- Tom Lehrer
------------------------------
Date: Thu, 17 Aug 2000 03:18:08 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: rollback perlcc'd binary to perl code
Message-Id: <slrn8pmmb6.qj4.tjla@thislove.dyndns.org>
I was shocked! How could vi_2000@hotmail.com <vi_2000@hotmail.com>
say such a terrible thing:
>HELP....
>
>My rcs hosed up and I have lost several code revisions
>on a perl project. I perlcc'd the code into a binary but
>lost the code. All I have is the binary.
>
>Is it possible to rollback the compilation to obtain the
>perl code and if so, how difficult is it? I don't want to
>recode the entire project if I can help it!!!
Non-sensible advice follows:
#!/usr/bin/perl -w
use strict;
exec "perlcced_binary";
Sensible advice:
You're screwed :) My sympathies, I wouldn't want to be you.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Iron Law of Distribution:
Them that has, gets.
------------------------------
Date: Thu, 17 Aug 2000 02:37:30 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: sorting ??
Message-Id: <MPG.1405ed52f41665089896b9@localhost>
pape_98@my-deja.com wrote ..
>hi,
>I was wondering if any of you could help me with a problem.
>I have a file that needs to be sorted. It looks something like this:
> NIH,B1D-410,52 51 36,135 256,15413,1512
> NIH,B1D-416,52,135 6,1513,52 hi,
> NIH,B1D-403,01 36,13 5 26,15 43,1 5 2 5 2 4
> Suburban,Cardiology Office,52 51,5256,15 13,152
> ...
>
>I've written a script that sorts it but it only sorts from 1 to 9;
>i.e 1,12,131,2,23,26,...
>this is the script I wrote:
>
>use strict;
>my $file = '/home/common/tourep/public_html/ntboxes';
>open (DATA, $file) or die "Can't open file: $!\n";
>my @data;
>while (<DATA>) {
> s/(\d+)\/(\d+)\/(\d+)/sprintf "$3".'%02d'x2,$2,$1/e;
> push @data,$_;
>}
>close T;
just quietly .. the above script does no sorting .. it also closes a
filehandle that isn't open .. someone else has already answered your
string vs numeric sorting question (not that their answer will help if
you're using the above code to sort)
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Wed, 16 Aug 2000 19:13:47 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Split Stumper
Message-Id: <399B4A5B.73A9DACC@stomp.stomp.tokyo>
Jerry Russell wrote:
> I have the following stumper:
Right... sure...
> Suppose we have the following string:
"Suppose we have...."
What is this, a new cliché? I read dozens of people
prefacing articles with this cliché. Hmmm.. or is
it the same person posting dozens of articles with
fake names and fake addresses?
> 'this',5,'is a test, to see',55,83,'if','anyone','can, get it'
> And, we want to split it into the following strings:
We? You do. I don't care either way.
"We want...." Such an unconscious idiom in writing.
> 'this'
> 5
> 'is a test, to see'
> 55
> 83
> 'if'
> 'anyone'
> 'can, get it'
> What is the simplest way to perform this split? Splitting on comma by itself
> will not work because there are some commas that are to be kept.
Really? *laughs*
> Please reply via email.
Take a flying leap. What? Are you brute force cracking passwords
after attaining a sample email with a logon name?
Godzilla!
TEST SCRIPT:
____________
#!/usr/local/bin/perl
print "Content-Type: text/plain\n\n";
$string = "'this',5,'is a test, to see',55,83,'if','anyone','can, get it'";
$string =~ s!, !¦ !g;
@Array = split (/,/, $string);
foreach $element (@Array)
{
$element =~ s/¦/,/;
print "$element\n";
}
exit;
PRINTED RESULTS:
_________________
'this'
5
'is a test, to see'
55
83
'if'
'anyone'
'can, get it'
------------------------------
Date: Wed, 16 Aug 2000 22:19:12 -0400
From: Joe Kline <jkline@one.net>
Subject: Re: Split Stumper
Message-Id: <399B4BA0.11D893A5@one.net>
Jerry Russell wrote:
>
> I have the following stumper:
>
> Suppose we have the following string:
>
> 'this',5,'is a test, to see',55,83,'if','anyone','can, get it'
>
<SNIP>
>
> What is the simplest way to perform this split? Splitting on comma by itself
> will not work because there are some commas that are to be kept.
Have you looked at:
Text::CSV
Text::CSV_XS
DBD::CSV
These can be found at your local, neighborhood CPAN. (or
http://search.cpan.org/ if you're inclined)
--
Joe Kline
It takes a lot of brains to enjoy satire, humor, and wit;
but none to be offended by them. ---The Midnight Skulker
------------------------------
Date: Thu, 17 Aug 2000 04:22:38 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Split Stumper
Message-Id: <mpimps8qh2fp7seev909021f3glb5k4679@4ax.com>
[ comp.lang.perl doesn't exist, alt.perl also removed ]
On Wed, 16 Aug 2000 18:36:56 -0700, Jerry Russell
<jerry@kachinaguide.com> wrote:
> I have the following stumper:
Well, not really. It's just an FAQ.
>
> Suppose we have the following string:
>
> 'this',5,'is a test, to see',55,83,'if','anyone','can, get it'
>
[snip]
> What is the simplest way to perform this split? Splitting on comma by itself
> will not work because there are some commas that are to be kept.
The simplest way: don't
Read perlfaq4:
perldoc -q split
> Please reply via email.
Post here, read here.
--
Good luck,
Abe
------------------------------
Date: Thu, 17 Aug 2000 02:50:36 GMT
From: sturman <sturman@midsouth.rr.com>
Subject: Re: Split Stumper
Message-Id: <399B54F4.421229F1@midsouth.rr.com>
Jerry Russell wrote:
>
> I have the following stumper:
>
> Suppose we have the following string:
>
> 'this',5,'is a test, to see',55,83,'if','anyone','can, get it'
>
> And, we want to split it into the following strings:
>
> 'this'
> 5
> 'is a test, to see'
> 55
> 83
> 'if'
> 'anyone'
> 'can, get it'
>
> What is the simplest way to perform this split? Splitting on comma
> by itself
> will not work because there are some commas that are to be kept.
>
> Please reply via email.
uh...like Abe said...post here, read here.
if you MUST use split then check out zero-width negative look-ahead
assertions, i.e. (?!pattern), in perlre.
sturman
------------------------------
Date: Thu, 17 Aug 2000 03:10:36 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Split Stumper
Message-Id: <MPG.1405f51b410154109896be@localhost>
sturman wrote ..
>Jerry Russell wrote:
>>
>> I have the following stumper:
>>
>> Suppose we have the following string:
>>
>> 'this',5,'is a test, to see',55,83,'if','anyone','can, get it'
>>
>> And, we want to split it into the following strings:
>>
>> 'this'
>> 5
>> 'is a test, to see'
>> 55
>> 83
>> 'if'
>> 'anyone'
>> 'can, get it'
>>
>> What is the simplest way to perform this split? Splitting on comma
>> by itself
>> will not work because there are some commas that are to be kept.
>>
>> Please reply via email.
>
>uh...like Abe said...post here, read here.
>
>if you MUST use split then check out zero-width negative look-ahead
>assertions, i.e. (?!pattern), in perlre.
it's not immediately obvious to me how a negative lookahead would help
in this situation .. are you just guessing that it would help - or can
you show a real example ?
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Thu, 17 Aug 2000 03:21:44 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Split Stumper
Message-Id: <slrn8pmmi2.qj4.tjla@thislove.dyndns.org>
I was shocked! How could Jerry Russell <jerry@kachinaguide.com>
say such a terrible thing:
>I have the following stumper:
>
>Suppose we have the following string:
>
> 'this',5,'is a test, to see',55,83,'if','anyone','can, get it'
>What is the simplest way to perform this split? Splitting on comma by itself
>will not work because there are some commas that are to be kept.
perldoc -q split
See the one that talks about splitting except when inside $character.
>Please reply via email.
*sigh* just this once. I must be getting weak in my young age.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
There is not much to choose between a woman who deceives us for another,
and a woman who deceives another for ourselves.
-- Augier
------------------------------
Date: Thu, 17 Aug 2000 02:43:24 GMT
From: gallantknave <gallantknave@my-deja.com>
Subject: Time stamp on Bulletin Board
Message-Id: <8nfjg8$egn$1@nnrp1.deja.com>
Hi,
Im pretty new at this, but am trying very hard but getting no where.
I have a bulletin board set up to recieve messages and would like to
include a time stamp for each message as per entry. As it stands now, I
can get the time to show up for each message, but I get the same time
for every message. When I refresh the page, which is an shtml page(I
have my cgi bulletin board program print to an html page), the
timestamp for each refreshes as well.
I think it has something to do with the cgi program I created for the
timestamp, but don't know where to look first. The timestamp program is
directed to my shtml page from my bb cgi.
Someone , please throw me some script my way!
Thanks,
Knave
--
I'm not a nay sayer, I'm just a fan.
Knave
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 17 Aug 2000 03:01:19 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Time stamp on Bulletin Board
Message-Id: <MPG.1405f2e83fb9ac499896bd@localhost>
gallantknave wrote ..
>Im pretty new at this, but am trying very hard but getting no where.
>
>I have a bulletin board set up to recieve messages and would like to
>include a time stamp for each message as per entry. As it stands now, I
>can get the time to show up for each message, but I get the same time
>for every message. When I refresh the page, which is an shtml page(I
>have my cgi bulletin board program print to an html page), the
>timestamp for each refreshes as well.
>
>I think it has something to do with the cgi program I created for the
>timestamp, but don't know where to look first. The timestamp program is
>directed to my shtml page from my bb cgi.
>
>Someone , please throw me some script my way!
umm ..
perldoc -f localtime
but .. your problem sounds like it might be caused because your script
regenerates all those timestamps whenever someone refreshes the page
(and therefore the script) .. the nature of a time-stamp is that it
stamps the time into (say) a file .. so that the time doesn't change
from then on
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Thu, 17 Aug 2000 03:20:53 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: uninitialized value???
Message-Id: <399B5A43.E2E63B3F@rochester.rr.com>
Gordon Gidluck wrote:
>
> Hi,
> I am new to Perl, and I have a runtime error on the HP/UX system which I
> do not get on the PC running Indigo Perl. This is a warning message, but
...
> This is the error message...
> Use of uninitialized value at ./findzips.pl line 26, <DATA> chunk 1.
...
> Overview:
...
> Here is the data. The first 5 columns is a zip, then next 10 is a
> telephone number, and the other bytes are misc info.
> file:<DATA>
> 35004205640????040102300000115111 000200000
...
> <snip>
>
> file:<ZIPINFO>
> 50001IA
...
> <snip>
>
> #!/usr/bin/perl -w
>
> use strict;
>
> my %zip=();
> my $i=0;
>
> open ZIPINFO,"<zips" or die "Error: Couldn't open hash info, $!\n";
> while(<ZIPINFO>){
> if(/^(\d{5})(\w{2})/){
> $zip{"$1"}=1;
> ### print "$zip{$1}\n";
> }
> }
> close ZIPINFO or die "Error: Couldn't close hash info file, $!\n";
>
> open DATA,"<data1.tmp" or die "Error: Couldn't open input data file,
> $!\n";
>
> # the errors are coming from each record processed in the WHILE loop
> while(<DATA>){
> chomp;
> if(/^(\d{5})/){
> if (($i==0) && ($zip{$1}==1)) { print "$_ 1\n"; }
> if (($i==0) && ($zip{$1}!=1)) { $i+=1; print "$_ 0\n"; }
...
> print "$_\n";
> }
> }
> close DATA or die "Error: Couldn't close input data file, $!\n";
The "Use of uninitialized value..." messages are coming from attempting
to obtain a value from a nonexistent hash key while the -w "warnings"
switch is in effect (or use warnings; or $^W!=0). You should use:
defined($zip{$1})
to test for the existence of a hash element before attempting to obtain
its value. In your case, replace $zip{$1}==1 with defined($zip{$1}) and
$zip{$1}!=1 with !defined($zip{$1}). Or turn warnings off during your
tests. See:
perldoc warnings
--
Bob Walton
------------------------------
Date: Thu, 17 Aug 2000 01:41:00 GMT
From: yhvhboy1 <yhvhboy1@home.com>
Subject: Re: windows headache
Message-Id: <399B43C2.9284E30B@home.com>
Larry Rosler wrote:
> In article <399B01E6.B8D8D754@vpservices.com> on Wed, 16 Aug 2000
> 14:04:38 -0700, Jeff Zucker <jeff@vpservices.com> says...
> > yhvhboy1 wrote:
> >
> > > print OUT (<IN>);
> >
> > If you should happen to get the message I just canceled, please ignore
> > my idiocy about context. Putting the parens around <IN>, of course puts
> > it in a list context. So that part of your script is fine.
>
> Huh? It is list context with or without the parentheses.
>
> But that part of the program isn't fine, because it unnecessarily reads
> the entire file into memory before printing it, a 'line at a time' yet
> (whatever that means for a binary file).
# but to do this:
while (<IN>) {
print OUT $_;
}
# has the same effect. the outfile is still 85 bytes.
# so what do i do?
# perhaps my computer has an anti-perl virus?
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 4038
**************************************