[18565] in Perl-Users-Digest
Perl-Users Digest, Issue: 733 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 21 03:05:33 2001
Date: Sat, 21 Apr 2001 00:05:06 -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: <987836706-v10-i733@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 21 Apr 2001 Volume: 10 Number: 733
Today's topics:
Re: (do not read, only a test) (Abigail)
another duplicate email question <dkelly@quisic.com>
Append <vtbowes@superaje.com>
Re: Command Piping in Perl (Abigail)
Re: Dynamic graphics generation (Abigail)
Re: File path not getting resolved correctly. (Abigail)
Re: How to use Perl subroutines/submodules from other s (Abigail)
http://www.perl.org/advocacy/ fails to load anything in <webmaster@webdragon.unmunge.net>
Re: logic programming in perl <gtoomey@usa.net>
Re: LWP, getting the default index page name from a web (Abigail)
Re: openfile <adustipujo1@mediaone.net>
Silly User Friendly module...any interest to put it on <zenin@rhps.org>
Re: Things I'm just not getting in Perl (Abigail)
Re: two associative arrays printed at the same time (Tad McClellan)
Re: use of Perl, Was Re: Can't open file, dies (Jim Kroger)
Writing and retrieving tied hashes to a file? <bduffy@nycap.nospam.please.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 21 Apr 2001 02:42:03 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: (do not read, only a test)
Message-Id: <slrn9e1srr.tgm.abigail@tsathoggua.rlyeh.net>
echo 'Rudolf Polzer'>/dev/null (rpolzer@www42.t-offline.de) wrote on
MMDCCLXXXIX September MCMXCIII in <URL:news:slrn9e0rjn.6t6.rpolzer@www42.t-offline.de>:
<> Sorry for this, but I am trying to make fetchnews get this NG again.
<> So I cannot use test NGs for this.
If you do your testing over in alt.test, your acne will clear up, your
compiles will run in half the time, and you will become irresistible to
the opposite sex. Much good karma will accrue to you and the Usenet gods
will smile.
If you post tests HERE, small boys will taunt your mother, you'll be
unable to mount your CD even as root, and strangers will cross the
street to kick your dog.
In other words, THIS AIN'T A FLIPPING TEST GROUP!!!
(Kevin Martin)
*plonk*
Abigail
------------------------------
Date: Fri, 20 Apr 2001 19:30:47 -0700
From: Darnell Kelly <dkelly@quisic.com>
Subject: another duplicate email question
Message-Id: <3AE0F0D7.8E0AD927@quisic.com>
gang,
i have opened a file within tcl, passing the to, cc, from, subject, and
message fields to my perl script which reads them as:
#!/usr/local/bin/perl
use Net::SMTP;
print "Content-type: text/html\n\n";
my ($to,$cc,$from,$subject,$message) = @ARGV;
my $smtp = Net::SMTP->new('IP ADDRESS') or die "Can't open mail
connection\n";
$smtp->mail($from);
my $textfile = "/usr/local/apache/htdocs/qlbs/new.txt";
my @response;
my $newline;
$smtp->to($to);
$smtp->to($cc);
# my %done;
# foreach (@ARGV) {
# next if $done{$to}++;
#}
#checking for duplicates here
my ($incoming_email_hash, $duplicate_hash_check);
$incoming_email_hash->{$to}{$cc}{$from}="$subject";
while($newline = shift @ARGV)
{
$duplicate_hash_check->{$to}{$cc}{$from}="$subject";
}
if (!exists($duplicate->{$to}{$cc}{$from}))
{
# get rid of nasty carraige returns
chomp($subject);
chomp($to);
@response = ("To: $to\n", "Cc: $cc\n",
"Subject:" . $subject . "\n",
"From: $from\n\n",
$message,
);
$smtp->data(@response);
$smtp->quit;
}
what happens is, as a test from the command prompt, i execute 'perl
script.pl email1, email2' yet only email2 gets a message sent to it and
not email1. its only looking at the last index in the array. what DOES
work is this
while(<>) {
etc...
but what happens is i get can't open file email1 or 2 or whatever yet
the emails are filtered fine, no duplicates are sent, very good yet that
pesky can't open file script error gets in the way but when i check the
emails it should have gone to, all's good.
what am i doing wrong here, people, i need some hard advice...i'm
getting back into the perl game which i've wanted to for a while but
still need assistance.
while you're looking at this pay close attention to where i'm filtering
off the duplicates and also why, in the present state, i'm only sending
one email out for x number of command line arguments.
all help appreciated,
darnell
------------------------------
Date: Fri, 20 Apr 2001 23:20:56 -0500
From: "Tom Bowes" <vtbowes@superaje.com>
Subject: Append
Message-Id: <6j7E6.17608$u7.7085577@e3500-chi1.usenetserver.com>
use cgi ':standard';
open (APPEND, ">>messages.htm") or die "$! error trying to append";
print APPEND "Name:";
print APPEND (param('name'));
print APPEND (param('message'));
what is wrong with this the variables will not append to the file?
------------------------------
Date: Sat, 21 Apr 2001 02:44:49 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Command Piping in Perl
Message-Id: <slrn9e1t11.tgm.abigail@tsathoggua.rlyeh.net>
Tom Hoffmann (tom.hoffmann@worldnet.att.net) wrote on MMDCCLXXXIX
September MCMXCIII in <URL:news:slrn9e1ed2.lq.tom.hoffmann@localhost.localdomain>:
:: I want to implement the following shell construct in Perl:
::
:: echo "some message" | write jdoe pts/10
::
:: so I code:
::
:: system ('echo "some message" | write jdoe pts/10');
::
:: Is there is another/better way to do this in Perl? Also, how can I
:: generalize this? If I try:
man perlipc
:: $message = 'some message';
:: $user = 'jdoe';
:: $pty = 'pts/10';
:: system ('echo $message | write $user $pty');
::
:: it returns a usage errro for 'write' since variable interpolation does
:: not take place in the single quotes. Is there a way to get
:: interpolation using the system function?
Eh, let me guess. Use a quoting style that does allow interpolation?
Abigail
--
#!/opt/perl/bin/perl -w
$\ = $"; $; = $$; END {$: and print $:} $SIG {TERM} = sub {$ := $_}; kill 15 =>
fork and ($; == getppid and exit or wait) foreach qw /Just another Perl Hacker/
------------------------------
Date: Sat, 21 Apr 2001 02:51:39 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Dynamic graphics generation
Message-Id: <slrn9e1tdr.tgm.abigail@tsathoggua.rlyeh.net>
Simon Stiefel (SiStie@nuclear-network.com) wrote on MMDCCLXXXIX September
MCMXCIII in <URL:news:3AE04F26.6B08036B@nuclear-network.com>:
`` Hi,
``
`` Does someone have a howto of dynamic graphics generation with perl?
``
`` Background:
`` I have a picture of 800x400 pixels with 100 items to be generated
`` dynamically.
That's kind of a broad question. There are a billion different graphical
formats, and even more ways of storing the information of the items that
need to be combined.
There are many graphical modules on CPAN. Go there and see if anything
is useful for you.
And then there's always the netpbm toolset you can shell out to.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: Sat, 21 Apr 2001 03:00:36 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: File path not getting resolved correctly.
Message-Id: <slrn9e1tuk.tgm.abigail@tsathoggua.rlyeh.net>
Gwyn Judd (tjla@guvfybir.qlaqaf.bet) wrote on MMDCCLXXXIX September
MCMXCIII in <URL:news:slrn9e1mit.2it.tjla@thislove.dyndns.org>:
))
)) Perl interprets a backslash '\' as being a single character escape. It
)) affects the next character along. For example, "\r" is a carriage
)) return. Windows in braindead in that it uses backslashes rather than
)) forward slashes as path element separators since this means you have to
)) write your paths like this:
))
)) system ("isql -SDB2SOL -Utmerenes -PCOGRULES
)) -iD:\\DC\\12.00.03\\236669\\repro.sql");
))
)) By escaping the backslashes, they come through as single backslashes.
)) Alternatively, Perl supports unix style forward slashes as path
)) separators, so you can do this:
))
)) system ("isql -SDB2SOL -Utmerenes -PCOGRULES
)) -iD:/DC/12.00.03/236669/repro.sql");
Eh, while it's true that Perl supports UNIX style slashes on windows,
it doesn't mean the above will work. See, if you use system, you are
basically saying "ok, Perl, go step aside, you've got to let someone
else play for a moment". It won't be perl that's going to interpret
"-iD:/DC/12.00.03/236669/repro.sql"! It's going to be isql. It might
work, but that's because isql does the right thing, not Perl.
Abigail
------------------------------
Date: Sat, 21 Apr 2001 03:30:43 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: How to use Perl subroutines/submodules from other server
Message-Id: <slrn9e1vn3.tgm.abigail@tsathoggua.rlyeh.net>
Tony Van der Voort (tvdv@advalvas.be) wrote on MMDCCLXXXIX September
MCMXCIII in <URL:news:3ae00aaf.5340546@news.skynet.be>:
<> Hello,
<>
<> I'm trying to make a perl script (CGI) with subroutines in a separate
<> file, using the instruction 'require'. This works very good. BUT... I
<> want to install this separate file on another server. The reason I
<> will do this, is to protect the code of the subroutines. The 'require'
<> instruction does not work here. Can some-one explain me, how I can
<> solve this problem ?
You forgot the NFS mount the disk from the other server! You should
ask the sysadmin of the other server to share the disk with the world,
and have the sysadmin of your server mount the remove disk.
Then it will work all handy-dandy.
Abigail
--
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
------------------------------
Date: 21 Apr 2001 04:43:21 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: http://www.perl.org/advocacy/ fails to load anything interesting
Message-Id: <9br359$n0o$2@216.155.32.50>
you get a big "Advocacy" header, and that's about it.. anyone watching
this, that can fix it?
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: Sat, 21 Apr 2001 15:51:04 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: logic programming in perl
Message-Id: <l09E6.8063$482.36509@newsfeeds.bigpond.com>
For logic programming (a la Prolog) you need backward chaining and
unification.
I can't find anyting on unification in CPAN.
This sounds like an interesting idea though.
gtoomey
----- Original Message -----
From: "Mark" <mmm_spam@excite.com>
Newsgroups: comp.lang.perl.misc
Sent: Saturday, 21 April, 2001 9:10 AM
Subject: logic programming in perl
> I have heard that Perl can be written in different programming styles..
> from the standard syntax to something that has the look and feel of a
> functional language... but what I want to know is can it be used in a
> logic programming style? I've searched the web and can't find anything
> on it, but that doesn't mean it can't be done!
>
> -Mark
------------------------------
Date: Sat, 21 Apr 2001 02:38:01 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: LWP, getting the default index page name from a web directry.
Message-Id: <slrn9e1sk9.tgm.abigail@tsathoggua.rlyeh.net>
Steve (steve@zeropps.uklinux.net) wrote on MMDCCLXXXIX September MCMXCIII
in <URL:news:slrn9e0jup.u5v.steve@zero-pps.localdomain>:
|| Hi
||
|| Using LWP, I can get content from web servers and parse it with
|| HTML::Parser etc, but the one thing that I can't get is the
|| name of the page that I'm getting if the input is just something
|| like "http://www.perl.com".
||
|| What I want to know is how to get the file name of the file that
|| the server gives me preferably without having to save the file
|| to disk.
||
|| I've tried a lot of stuff from the man pages for HTTP and LWP,
|| but havn't found anything that gives me what I want yet.
Huh? What do you mean "the file name"?
HTTP isn't about files. HTTP serves object, or as they are sometimes
called, documents. An HTTP server *might* satisfy a request for a URL by
returning the content of a file, but that's a pure local implementation
issue, and is absolutely beyond the scope of HTTP.
The assumption there is a 1-to-1 relationship between URLs and files
is a fallicy. It contains less truth than the story of the sleeping
beauty.
This of course has no relationship with Perl.
Abigail
--
$_ = "\112\165\163\1648\141\156\157\164\150\145\1628\120\145"
. "\162\1548\110\141\143\153\145\162\0128\177" and &japh;
sub japh {print "@_" and return if pop; split /\d/ and &japh}
------------------------------
Date: Sat, 21 Apr 2001 06:18:37 GMT
From: "Pujo C A" <adustipujo1@mediaone.net>
Subject: Re: openfile
Message-Id: <1D9E6.31885$uh5.933264@typhoon.mw.mediaone.net>
Hi,
The think is I put the input file in the same directory to make me easy.
so it should look in the same directory.
thanks
PUJO
<nobull@mail.com> wrote in message news:u9oftrcwdr.fsf@wcl-l.bham.ac.uk...
> "Pujo C A" <adustipujo1@mediaone.net> writes:
>
> > Guys, I am new in perl , but struggling to know this powrfull
> > langguage.
>
> But not everything you experience while using Perl will be related to
> Perl.
>
> > I want to open a file contain a data and create a hash from that table.
> > I can do it in perl script but when I do it in CGI it doesnt work?
>
> So your first though should be that the reason will not be related to
> your choice of programming language.
>
> When it "doesn't work" does soemthing happen or does the univers
> simply end? Do you see errors in the log?
>
> > open(GRADES, "+<testfil") or die "can not open grades: $!\n";
>
> Random shot in the dark: Your web server s/w is running the script
> with a different current directory or with a user ID that lacks write
> permission to 'testfil'.
>
> > while ( defined( my $record = <GRADES>) ) {
> > ($sid,$fname,$lname) = split (" ", $record);
> > $grades{$sid} .= $fname . " ";
> > my @grades = split (" ", $grades{$sid});
> > my $name = "$fname, $lname";
> > }
> > close(GRADES);
>
> BTW: Why did you open the file read/write?
>
> --
> \\ ( )
> . _\\__[oo
> .__/ \\ /\@
> . l___\\
> # ll l\\
> ###LL LL\\
------------------------------
Date: Sat, 21 Apr 2001 03:59:54 -0000
From: Zenin <zenin@rhps.org>
Subject: Silly User Friendly module...any interest to put it on CPAN?
Message-Id: <te21dqd7vthq34@news.supernews.com>
Being a User Friendly fan (www.userfriendly.org for the uninitiated), I
hacked a quick module up to help me automate setting my desktop wallpaper to
the UF cartoon of the day. Would anyone else be interested in it? If so,
I'll upload it to CPAN. For now, Silly::UserFriendly can be found at:
ftp://thrush.omix.com/pub/perl/modules/Silly-UserFriendly-1.001.tar.gz
Enjoy...
--
-Zenin (zenin@rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Sat, 21 Apr 2001 01:58:26 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Things I'm just not getting in Perl
Message-Id: <slrn9e1qa2.tgm.abigail@tsathoggua.rlyeh.net>
Mark Jason Dominus (mjd@plover.com) wrote on MMDCCLXXXIX September
MCMXCIII in <URL:news:3ae067cc.2f86$2d6@news.op.net>:
.. In article <77o0etkuh5jo43fvaa3kueq30ieiujvac2@4ax.com>,
.. Lou Moran <lmoran@wtsg.com> wrote:
.. >--The first thing I can never seem to do with any regualrity is have a
.. >"loop" wherein a user is warned about a mistake and allowed to
.. >continue on. For instance:
.. >
.. >Enter a number:
.. > User enters "A"
..
.. I usually follow this pattern:
..
.. do {
.. print "Enter a number: ";
.. chomp($response = <>);
.. } while $response !~ /^\d+$/ ;
..
.. Sometimes:
..
.. while (1) {
.. print "Enter a number: ";
.. chomp($response = <>);
.. last if $response =~ /^\d+$/;
.. print "That isn't a number, stupid!\n";
.. }
I find this an excellent case for redo:
{ print "Enter a number: ";
chomp ($response = <>);
redo unless $response =~ /^\d+$/;
}
Or even a plain goto:
NUMBER:
print "Enter a number: ";
chomp ($response = <>);
goto NUMBER unless $response =~ /^\d+$/;
(cue the Dijk^WWirth chanters)
Abigail
------------------------------
Date: Fri, 20 Apr 2001 23:37:06 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: two associative arrays printed at the same time
Message-Id: <slrn9e2032.8ao.tadmc@tadmc26.august.net>
Just in <justin.devanandan.allegakoen@intel.com> wrote:
>> Why have the identical value in 2 places? (you said the hashes
>> have the same keys)
>
>Err, no the values are distinct,
Oh I see. I used "value" there as in "value of the variable",
not a "hash value". Probably shouldn't have done that...
>but the keys match.
You snipped my underlining:
>while(($key, $val, $key2, $val2) = each(%hash1, %hash2))
^^^^ ^^^^^
I underlined the 2 places I was referring to.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 20 Apr 2001 21:09:09 -0400
From: minorseventhSPAMBLOCK@earthlink.net (Jim Kroger)
Subject: Re: use of Perl, Was Re: Can't open file, dies
Message-Id: <minorseventhSPAMBLOCK-2004012109090001@tritone.csbmb.princeton.edu>
In article
<uy9svmn66.fsf_-_@SNOW.i-did-not-set--mail-host-address--so-shoot-me>,
gls@byu.edu wrote:
> minorseventhSPAMBLOCK@earthlink.net (Jim Kroger) writes:
>
> > Thanks everyone for the help....
> >
> > Can't help but wonder what a statistician uses Perl for....
>
> I first learned Perl when I was doing a bunch of simulations. I
> needed to run one program to generate a random dataset then analyze
> the dataset using 8 different programs. Each of those programs
> generated 10-100 pages of output, I only cared about 10 numbers in all
> of that output. Then I needed to repeat the whole process 100 times,
> then change some conditions and repeat another 100 times, ...
>
> (and all of this time my boss was modifying some of the programs so
> that the page the interesting output was on kept changing).
>
> Perl was a life saver for that job.
<snip>
Hm, very intersting! Thanks for the illustration.
This reminds me of doing analyses all night in a 4 x 4 room on a terminal
with a 300 baud modem, and then trudging across campus to pick up the
output from the dp center, and carrying all five or five or ten pounds of
it back to my advisor's office so he could look to see if a number on the
last page was < .05. Worst thing is, after two semesters of this, it was.
And he decided it wasn't ENOUGH < .05 so we ran another semester's worth
of subjects, and you guessed it: > .05. No pub....
Interestingly, he didn't get tenure....
Thanks again for the help,
Jim
------------------------------
Date: Sat, 21 Apr 2001 03:26:06 GMT
From: "Brian Duffy" <bduffy@nycap.nospam.please.rr.com>
Subject: Writing and retrieving tied hashes to a file?
Message-Id: <i57E6.13911$rk.1507024@typhoon.nyroc.rr.com>
Hello,
I need to create a hashed table of IP & Network addresses that can be dumped
into a binary formatted file. I ran across the NetAddr::IP module on CPAN,
and it appears to do exactly what I need.
Right now, I'm having a problem writing to and reading the tied hash to and
from the datafile. Could someone help point me in the right direction to get
this to work?
Brian Duffy
bduffy@nycap.rr.com
--------START---------
#!/usr/local/bin/perl
use Tie::NetAddr::IP;
use Storable;
my %Data;
tie %Data, Tie::NetAddr::IP;
#Load some sample data
$Data{"10.0.10.0/24"} = "nasgw1d";
$Data{"10.0.20.0/24"} = "nasgw3d";
foreach $host ("10.0.10.4", "10.0.10.5", "10.0.20.3", "10.0.20.4")
{
print "Host $host is in ", $Subnet{$host}, "\n";
}
foreach $subnet (keys %Data)
{
print "Network ", $subnet, " is used in ",
$Data{$subnet}, "\n";
}
store \%Data, 'testdata.bin';
untie %Data;
my %Subnet2;
tie %Subnet2, Tie::NetAddr::IP;
$Subnet2 = retrieve ('testdata.bin') or die "Cannot retrieve subnet!";
foreach $subnet (keys %Subnet2)
{
print "Network ", $subnet, " is used in ", $Subnet2{$subnet}, "\n";
}
untie %Subnet2;
----END----
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 733
**************************************