[13963] in Perl-Users-Digest
Perl-Users Digest, Issue: 1373 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 14 06:05:38 1999
Date: Sun, 14 Nov 1999 03:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <942577513-v9-i1373@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 14 Nov 1999 Volume: 9 Number: 1373
Today's topics:
Re: Build Perl <no@spam.com>
Re: Data Access <slanning@bu.edu>
Easy pattern matching for an apostrophe tasher1234@my-deja.com
Re: Help needed please, simple hash slice question! <uri@sysarch.com>
how can i ask outlook express to download the email? <geofox@softhome.net>
How quote a scalar name in another scalar name? <Benjamin_Gu@email.mot.com>
Re: How quote a scalar name in another scalar name? (Simon Cozens)
Re: How quote a scalar name in another scalar name? <slanning@bu.edu>
Re: How quote a scalar name in another scalar name? (Tad McClellan)
Re: Is there a way to find the size of a jpg file from (Martien Verbruggen)
Re: Is there a way to find the size of a jpg file from <rhear@cs.winthrop.edu>
Re: Is there a way to find the size of a jpg file from <slanning@bu.edu>
more bad header <chris@chrismail.connectfree.co.uk>
Re: more bad header (Michel Dalle)
Re: Newbee needs some date functions . . . (Martien Verbruggen)
parsing <marcus@a-net.co.uk>
Re: Perl and commonsense part 2 <uri@sysarch.com>
Re: Perl and commonsense part 2 (Bart Lateur)
redirect() / exec() <marcus@a-net.co.uk>
Re: regular expression riddle (Eric Bohlman)
Re: return height and width of jpeg, gif accessed via u (BLUESRIFT)
Re: Running shell commands via CGI script <bolek@techie.com>
Search & Replace Question... (Kazz)
Re: searching flatfile with a hash <lr@hpl.hp.com>
Re: Show me a better way! <r28629@email.sps.mot.com>
Re: Show me a better way! <JFedor@datacom-css.com>
Re: Show me a better way! <JFedor@datacom-css.com>
sort lists together <ab@cd.com>
Re: sort lists together <moseley@best.com>
System Command <kastrovinic@hotmail.com>
Re: System Command <slanning@bu.edu>
Re: System Command (Martien Verbruggen)
Trying to use a variable as an operator jradford@my-deja.com
Re: Trying to use a variable as an operator <slanning@bu.edu>
Re: Trying to use a variable as an operator <dgarstan@nsw.bigpond.net.au>
Re: unique search and replace problem <slanning@bu.edu>
Re: Weekday in perl <lr@hpl.hp.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 14 Nov 1999 11:08:49 -0000
From: "Simon Brook" <no@spam.com>
Subject: Re: Build Perl
Message-Id: <80m4pi$h9$1@supernews.com>
Yep thanks, I have now switched the whole thing to Date::Manip - (which
would you believe my ISP also didn't have installed, but the package worked
in itself, so there was no problem)
Thankyou ever so much.
New one on the way too I'm afraid.
. . . .
>
> Well, actually, Abigail says Date::Manip (a) does what you want and (b)
> doesn't require dynamic loading. So you might try that.
>
> Otherwise,
> 1. download the perl source package (5.005_03 or whatever is stable) from
CPAN;
> 2. unpack it;
> 3. read the INSTALL file.
> 4. follow the instructions.
>
> It might take you as long as an hour.
> --
> <kragen@pobox.com> Kragen Sitaker
<http://www.pobox.com/~kragen/>
> The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
> <URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 14 Nov 1999 00:43:45 -0500
From: Scott Lanning <slanning@bu.edu>
Subject: Re: Data Access
Message-Id: <kusbt8xpqzy.fsf@strange.bu.edu>
shaique8@hotmail.com writes:
> I am having a problem with my DBI with perl 5 i need to know how exectly
> i can acces mySQL(Linux Red Hat 6) with Perl 5 (DBI) .if anyone could
> send me with syntax it would be of great help
http://www.perl.com/pub/1999/10/DBI.html
http://torresoft.netmegs.com/intro.html
--
"If there were gods, how could I bear to be no god?
Consequently there are no gods." --Nietzsche
------------------------------
Date: Sun, 14 Nov 1999 03:35:38 GMT
From: tasher1234@my-deja.com
Subject: Easy pattern matching for an apostrophe
Message-Id: <80lama$he7$1@nnrp1.deja.com>
What is the syntax for accepting an apostrophe in a last name?
I have 3 fields: First M. Last.
I had this before:
@profiles=grep
{/Name:(?:(\w+)[\W]+)?(?:(\w+)[\W]+)?.*(?:\b([A-D])\w*)\n/} @profiles;
I tried this:
@profiles=grep
{/Name:(?:([\w']+)[^\w']+)?(?:([\w']+)[^\w']+)?.*(?:\b([A-D])[\w']*)\n/}
@profiles;
Thanks.
Newbie Perl Person,
Terry Asher
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 14 Nov 1999 00:37:37 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Help needed please, simple hash slice question!
Message-Id: <x7ln81y6ou.fsf@home.sysarch.com>
for more on hash slices see my tutorial (posted a couple of times and
now on my site) at:
http://www.sysarch.com/perl/tutorials/hash_slices.txt
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Sun, 14 Nov 1999 05:43:04 +0800
From: "geofox" <geofox@softhome.net>
Subject: how can i ask outlook express to download the email?
Message-Id: <80m05e$mcu$1@newso.ctimail.com>
Hi,
I have moved the email in /var/spool/mail
to $HOME/mailbox by procmail but
i can't download the email from RedHat 6 now????
How can I ask outlook express to download the email
in $HOME/mailbox?
Other setting i need to setup in .procmailrc?!
Any idea is wellcome!
Thanks,
geofox
------------------------------
Date: Sun, 14 Nov 1999 11:35:32 +0800
From: Benjamin Gu <Benjamin_Gu@email.mot.com>
Subject: How quote a scalar name in another scalar name?
Message-Id: <382E2E04.DE4CF86B@email.mot.com>
I have a very stupid question, i
wanna quote a scalar name in another
scalar name, like below,
$i = 1;
$xyz$i = 100;
But it didn't work, pls. tell me how
to acheieve this. Thanks!
------------------------------
Date: 14 Nov 1999 04:23:09 GMT
From: simon@brecon.co.uk (Simon Cozens)
Subject: Re: How quote a scalar name in another scalar name?
Message-Id: <slrn82se9d.p54.simon@othersideofthe.earth.li>
Benjamin Gu (comp.lang.perl.misc):
>I have a very stupid question, i
>wanna quote a scalar name in another
>scalar name, like below,
>
>$i = 1;
>$xyz$i = 100;
You can do this with symbolic references, but I'm not going to tell you
how to, because they're bad and nasty and wrong. Random pollution of the
namespace isn't a good habit to get into, and there are lots of other
reasons besides.
Instead, consider using either
a) in this example, an array: $xyz[$i]=100;
b) More generally, a hash: $stuff{$nonsense}=100;
--
A year spent in artificial intelligence is enough to make one believe in God.
------------------------------
Date: 13 Nov 1999 23:38:12 -0500
From: Scott Lanning <slanning@bu.edu>
Subject: Re: How quote a scalar name in another scalar name?
Message-Id: <kushfippu17.fsf@strange.bu.edu>
Benjamin Gu <Benjamin_Gu@email.mot.com> writes:
> $i = 1;
> $xyz$i = 100;
#!/usr/local/bin/perl -w
# scalar.pl -- test scalar references
use strict;
my $xyz = 'a';
my $i = '1';
my $xyzi = $xyz.$i;
{
no strict 'refs';
$$xyzi = 3;
print "$xyzi\n";
print "$$xyzi\n";
}
__END__
bash$ scalar.pl
a1
3
--
"Sarcasm: the last refuge of modest and chaste-souled people when the
privacy of their soul is coarsely and intrusively invaded."
--Dostoyevsky
------------------------------
Date: Sat, 13 Nov 1999 21:40:40 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How quote a scalar name in another scalar name?
Message-Id: <slrn82s898.3qj.tadmc@magna.metronet.com>
On Sun, 14 Nov 1999 11:35:32 +0800, Benjamin Gu
<Benjamin_Gu@email.mot.com> wrote:
>I have a very stupid question, i
^
^
>wanna quote a scalar name in another
^^^^^
^^^^^
No you don't!
What you want _can_ be done in Perl ("Symbolic references"
in perlref.pod), but it is nearly always a Very Bad Idea
to use them (they were useful in Perl 4, but aren't needed
much with modern Perl).
See:
http://www.plover.com/~mjd/perl/varvarname.html
>scalar name, like below,
>
>$i = 1;
>$xyz$i = 100;
>
>But it didn't work, pls. tell me how
>to acheieve this.
Use a hash instead and "build up" hash keys instead of variable names.
$some_hash{"$xyz$i"} = 100;
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 14 Nov 1999 02:07:55 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: Is there a way to find the size of a jpg file from Perl?
Message-Id: <slrn82s6dd.jb7.mgjv@wobbie.heliotrope.home>
On Sun, 14 Nov 1999 01:21:09 GMT,
tony_123@my-deja.com <tony_123@my-deja.com> wrote:
> Hi
>
> Is there anyway to find the dimensions of a jpg file in perl??
Yes. And someone posted that question here not that long ago, and it was
answered. And someone posts this question here about almost every week.
You posted this from deja. Did you realise that deja keeps an archive of
almost everything that happens on Usenet, and that you can actually
search their archives? If not, learn to use it.
As for your question:
Use the Image::Size module. Get it from CPAN: http://www.cpan.org/
Martien
--
Martien Verbruggen |
Interactive Media Division | Failure is not an option. It comes
Commercial Dynamics Pty. Ltd. | bundled with your Microsoft product.
NSW, Australia |
------------------------------
Date: Sun, 14 Nov 1999 03:53:44 +0000
From: "Ryan T. Rhea" <rhear@cs.winthrop.edu>
Subject: Re: Is there a way to find the size of a jpg file from Perl?
Message-Id: <382E3247.4CCE0FB1@cs.winthrop.edu>
tony_123@my-deja.com wrote:
> Hi
>
> Is there anyway to find the dimensions of a jpg file in perl??
>
> Cheers
>
> Tony
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
What do you mean by dimensions? I assume you mean filesize? You can
use the '-s' switch with the filehandle of the file. Here is an
example:
#!/usr/bin/perl -w
while ($filename = <*.jpg>) {
open(WORDSLIST, $filename);
print -s WORDSLIST;
}
close(WORDSLIST);
There are 20+ of these filehandle switches you could use for different
properties of the files. Most are meant to be used as file tests.
Sincerely,
Ryan T. Rhea
Winthrop University
rhear@cs.winthrop.edu
------------------------------
Date: 13 Nov 1999 23:46:05 -0500
From: Scott Lanning <slanning@bu.edu>
Subject: Re: Is there a way to find the size of a jpg file from Perl?
Message-Id: <kusemdtpto2.fsf@strange.bu.edu>
"Ryan T. Rhea" <rhear@cs.winthrop.edu> writes:
> tony_123@my-deja.com wrote:
> > Is there anyway to find the dimensions of a jpg file in perl??
>
> What do you mean by dimensions? I assume you mean filesize?
Sigh.. apparently you don't download much porn, do you Ryan? :)
Presumably he meant like 320x200.
--
"I'm going to have fun telling you about this absurdity, because I
find it delightful." --Richard Feynman
------------------------------
Date: Sun, 14 Nov 1999 09:03:22 -0000
From: "Chris" <chris@chrismail.connectfree.co.uk>
Subject: more bad header
Message-Id: <382e88ff.0@news2.cluster1.telinco.net>
I'm still getting told bad header = :
http://blsoftpart.hypermart.net/sign_up.pl/forward.pl (depending on which
file I open and I've checked with hypermart and the #!usr/local/bin/perl is
the right path)
My files are below
sign_up.pl -
#!usr/local/bin/perl - wT
print "Content-type: text/html\n\n";
use strict;
use CGI qw(:standard);
use Fcntl qw(:flock);
@ENV{qw(PATH IFS)}=("")x2;
my $url = param('url');
my $forward = param('forward');
my $email = param('email');
my $success;
if(open(SUCCESS,"success.fil"))
{
flock(SUCCESS,LOCK_SH) || die "Can't lock 'success.fil - $!\n"; #
$success = do { local $/; <SUCCESS> }; # and putting in to $success
close(SUCCESS);
}
my $unavailible;
if(open(TAKEN,"taken.fil"))
{
flock(TAKEN,LOCK_SH) || die "Can't lock 'taken.fil - $!\n"; # same but
$unavailible= do { local $/; <TAKEN> }; # file and putting into
close(TAKEN);
}
my $message;
if(open(MESSAGE,"message.fil"))
{
flock(MESSAGE,LOCK_SH) || die "Can't lock 'fils/$url.fil - $!\n"; # same
$message= do { local $/; <MESSAGE> };
close(MESSAGE);
}
if ( open(UINFO,"fils/$url.fil") )
{
flock(UINFO,LOCK_SH) || die "Can't lock 'fils/$url.fil - $!\n";
my $test= do { local $/; <UINFO> };
close(UINFO);
if ($test eq "")
{
open(URLS,">fils/$url.fil") || die "Can't open 'fils/$url.fil - $!\n";
flock(URLS,LOCK_EX) || die "Can't flock 'fils/$url.fil - $!\n";
print URLS "$forward";
close(URLS);
my $from = 'kieran@bl-soft.com';
my $sub = 'Your Exclamation website is up and running';
email($email,$from,$sub,$message);
print "$success";
}
}
else
{
print"$unavailible";
}
sub email
{
my ($to,$from,$sub,$message) = @_;
open(MAIL, "|/var/qmail/bin/qmail-inject -t") || die
"Content-type: text/plain\n\nCan't open
qmail-inject -$!\n";
print MAIL <<EOMAIL;
To: $to
From: $from
Subject: $sub
$message
EOMAIL
return close(MAIL);
};
forward.pl -
#!/usr/local/bin/perl
use strict;
use CGI qw(:standard);
use Fcntl qw(:flock);
@ENV{qw(PATH IFS)} = ("") x 2;
my $forsite = param('url');
if(open(BOOK,"/fils/$forsite.fil"))
flock(BOOK,LOCK_SH) || die "Can't flock $forsite.fil - $\n";
my $redir=<BOOK>;
close(BOOK);
print redirect($redir);
}
else
{
print <<EOMESS;
<HTML>
<HEAD>
<TITLE>EXCLAMATION!</TITLE>
</HEAD>
<BODY BGCOLOR="BLACK">
<center>
<FONT COLOR="ORANGE">
EXCLAMATION!<p>
<H1>Sorry page not found</H1><p>
To register this domain with EXCLAMATION <A
HREF="http://blsoftpart.hypermart.net/sign_up.html">Click Here</A><p>
<A HREF="exclamation.html">Click Here</A> to go to exclamations main
site.<p>
<A HREF="http://www.bl-soft.com/">Click Here</A> to visit Bl-Soft (The
company who made this).<p>
<A HREF="http://www.free-address.com/">Click Here</A> to visit free-address
(Another part of the company).
</FONT>
</BODY>
</HTML>
EOMESS
};
--
Chris
chris@chrismail.connectfree.co.uk
www.bl-soft.com/chrissite
------------------------------
Date: Sun, 14 Nov 1999 10:12:44 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: more bad header
Message-Id: <80m20o$nbq$1@xenon.inbe.net>
In article <382e88ff.0@news2.cluster1.telinco.net>, "Chris" <chris@chrismail.connectfree.co.uk> wrote:
>I'm still getting told bad header = :
>http://blsoftpart.hypermart.net/sign_up.pl/forward.pl (depending on which
>file I open and I've checked with hypermart and the #!usr/local/bin/perl is
>the right path)
[snip]
Have you tried adding
use CGI::Carp qw(fatalsToBrowser);
in your script ?
Your script is probably dying somewhere...
Of course, your forward.pl script doesn't seem to generate HTTP headers at
all, so that may be a problem too. Why don't you try them out locally before
posting them to your remote website ?
And you don't need to flock EVERY file you open - only the ones that you
want to update.
Michel.
------------------------------
Date: 14 Nov 1999 02:05:50 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: Newbee needs some date functions . . .
Message-Id: <slrn82s69g.jb7.mgjv@wobbie.heliotrope.home>
On Sun, 14 Nov 1999 01:03:44 -0000,
Simon Brook <no@spam.com> wrote:
> (On another slightly embarassing note, I see from reading some of the
> postings that certain things are generally frowned upon. I really don't know
> any netiquette about news groups etc, and I'm afraid that I don't even know
> where the much referred to Perl FAQ is - ok now I have really shown my
> ignorance I can just shy away into the corner . . . )
Sorry, I missed this on first read.
The Perl FAQ, and a large amount of documentation, all come with every
installation of Perl. On unix machines, it's customary to access all
this with man, on windows machines, with the ActiveState distribution,
it's all installed as HTML, and you should have one of those shortcuts
in your start menu. Most platforms share a utility called perldoc:
# perldoc perl
# perldoc perldoc
# perldoc perlfunc
# perldoc perltoc
# perldoc perlfaq
# perldoc perlfaq3
To look at a function's documentation:
# perldoc -f open
# perldoc -f select
To search the FAQ headers:
# perldoc -q keyword
The complete documentation, I believe, is also avalable via
www.perl.com, but it's much easier to just install Perl locally. How
else are you going to do any development anyway? :)
Martien
--
Martien Verbruggen |
Interactive Media Division | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd. | again. Then quit; there's no use
NSW, Australia | being a damn fool about it.
------------------------------
Date: Sun, 14 Nov 1999 10:24:51 -0000
From: "marcus armand" <marcus@a-net.co.uk>
Subject: parsing
Message-Id: <80m2r6$g65$1@news1.cableinet.co.uk>
have a script that queries a database on a remote server.
The results are returned as text names and addresses (a long and useless
list) followed by a list of hyperlinks. These are currently displayed on the
screen in a very unuserfriendly manner.
I need build my own hmtl document from this automaticaaly on-line.
I need to attach the first name and address to the first URL etc.
Also how do I make the initail request. At the moment it is just a URL
attached to a form action?
Does the form action need to go to another script use OPEN and then the URL
to the search script?
Many thanks
MArcus
------------------------------
Date: 14 Nov 1999 00:23:22 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl and commonsense part 2
Message-Id: <x7puxdy7cl.fsf@home.sysarch.com>
>>>>> "KS" == Kragen Sitaker <kragen@dnaco.net> writes:
KS> An idiom I use frequently to turn a list (usually an array) into a hash
KS> is %hash = map { $_ => 1 } (list). This is useful because it is
KS> clearer to write a test for membership in the set of the keys of a hash
KS> than in the set of members of an array, and because it eliminates
KS> duplicates.
JAWTDI:
@hash{ @array } = (1) x @array ;
the map does a clean assignment to %hash though and the above doesn't
touch elements outside of @array. but since i typically use this idiom
in initializtion it usually doesn't matter. for more on hash slices see
my tutorial (just put on my site) at
http://www.sysarch.com/perl/tutorials/hash_slices.txt
if all you will do is test for existance of the key then this is even
simpler:
@hash{ @array } = () ;
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Sun, 14 Nov 1999 10:04:32 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Perl and commonsense part 2
Message-Id: <382e882c.241065@news.skynet.be>
Uri Guttman wrote:
>if all you will do is test for existance of the key then this is even
>simpler:
>
> @hash{ @array } = () ;
Which is very fast compared to any other method. However, *who* in is
right mind would test only for existence of a key, if you're free to
choose whatever hash value you like?
Any other way of initializing a hash is more cumbersome, and/or more
slow (up to by a factor of 3). Which is a shame.
@hash{@array} = (1) x @array;
@hash{@array} = 1 .. @array;
%hash = map { $_ => 1 } @array;
$hash{$_}++ foreach @array;
--
Bart.
------------------------------
Date: Sun, 14 Nov 1999 09:31:05 -0000
From: "marcus armand" <marcus@a-net.co.uk>
Subject: redirect() / exec()
Message-Id: <80lvmb$d7o$1@news1.cableinet.co.uk>
Hello,
I am new to perl so any help would be appreciated.
I have a password script that validates and then redirects to another web
site.
That bit works fine. I have use the CGI.pm module Redirect to achieve this.
However I want to run another script after the redirect with:
exec("/cgi-bin/script arguments");
Nothing happens after the redirect.
If I leave out the redirect the script crashes:
premature end of script headers.
Please help
Thanks
Marcus
------------------------------
Date: 14 Nov 1999 03:05:35 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: regular expression riddle
Message-Id: <80l8tv$n0k$2@nntp9.atl.mindspring.net>
Kragen Sitaker (kragen@dnaco.net) wrote:
: perldoc is included with ActivePerl, and the full Perl documentation --
: which includes the FAQ entry below -- is on your Start menu.
Note that the most recent versions of ActivePerl have fixed the paging
problems that previous verstions of perldoc had on Win32 systems.
------------------------------
Date: 14 Nov 1999 08:39:55 GMT
From: bluesrift@aol.com (BLUESRIFT)
Subject: Re: return height and width of jpeg, gif accessed via url
Message-Id: <19991114033955.07434.00001126@ng-cf1.aol.com>
To all who have suggested that use of modules is preferable, I could not agree
more. I even mentioned the likelihood that LWP could be of service. I
sincerely apologize if I came off differently in my request for help. Of
course I do not want the focus of this thread to be on my ineptness or the
inadequacy of my host but the truth is that I do not control my host server nor
can I Telnet which I believe prevents me from being able to install Perl
modules properly or at least the Image::Size module via execution of
Makefile.pl. I did expand the archive manually on my local drive and then FTP
uploaded to my space on the server. Execution produced errors I will not
pretend to understand.
I am not bragging about how stupid I am but I do know my limitations. It had
also, indeed, occurred to me to attempt to extract the meat from the module but
I am not even close to being that good. I suspect that code written for
modules is probably as tight as it gets and probably also includes clever but
complicating routines to help allow for most, if not all, possible
eventualities at execution. For all I know there may also be module specific
code intertwined with the "meat".
So, alhtough somewhat clouded now, my original request for help still stands
-or- we can further discuss the reasons why I am asking for this help.
------------------------------
Date: Sun, 14 Nov 1999 05:14:36 GMT
From: "--==[bolMyn]==--" <bolek@techie.com>
Subject: Re: Running shell commands via CGI script
Message-Id: <382E45A2.AF097166@techie.com>
I looked into it but if I am reading it correctly, doing net::ping will also
going to give me the end result. The example I was looing at is from
"Programming PERL" and this is an excerpt:
use Net::Ping;
$hostname = 'whatever'
$timeout = 10;
print "whatever is alive\n"
I don't want the final result (I mean, yes I do but not only that). What I
want is a line by line dispaly in the browser of the ping process (Usually,
I set it to three pings) I could do it easly using BASH script but as
I mentioned, I got stuck on passing a form input value to the script. That's
why I turned to PERL.
Thanks again.. :-)
David Cassell wrote:
> --==[bolMyn]==-- wrote:
> >
> > Before someone starts yelling at me about a security risk, I want to
> > mention that what I want to accomplish is only for internal networks so
> > no outsider will ever see it. [snip]
>
> But.. but.. we *like* to yell at visitors. And regulars too. :-)
>
> [snip]
> > returned by my BASH script. However, now I would like to take it a step
> > further and I'd rather have now a user input the location for pinging.
> > That's when I ran into a road block. I'm not sure how I can pass a
> > value from a form input field into my BASH script. So I turned to
> > PERL (as a matter of fact, I just started it so I'm sure there is plenty
> > I don't know about it).
>
> Rather than use Perl as an intermediary, go ahead and use Perl
> modules to do it all. Use CGI.pm to get the params from the
> form, and use Net::Ping to do the ping. Might even be faster.
> The modules which are not part of your install are available
> at CPAN [www.cpan.org].
>
> David
> --
> David Cassell, OAO cassell@mail.cor.epa.gov
> Senior computing specialist
> mathematical statistician
--
Bolek,
URL: http://www.bolek.com
e-mail: crash_abort@bolek.com
ICQ: 4086197
Address: 402905326
------------------------------
Date: Sun, 14 Nov 1999 10:41:25 GMT
From: kazz@ashernet.net (Kazz)
Subject: Search & Replace Question...
Message-Id: <382e90b1.291977841@news.pajo.com>
Say I have a tag to replace that I know begins with "<body" and I want
to replace everything to the ">" end of that tag. Actually, I want to
prepend a scalar to it but want to make sure what I'm adding isn't
added until the end of the tag... what's the best way?
$line =~ s/<body .. >/<body .. >$morestuff/gi; ??
------------------------------
Date: Sat, 13 Nov 1999 23:32:36 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: searching flatfile with a hash
Message-Id: <MPG.1298057235993f4198a1f4@nntp.hpl.hp.com>
In article <slrn82rat1.31n.tadmc@magna.metronet.com> on Sat, 13 Nov 1999
13:19:13 -0500, Tad McClellan <tadmc@metronet.com> says...
...
> my $keyRE = join '|' reverse sort keys %somehash; # key1|key2|key3|...
I'm not sure why you want to 'reverse sort' those keys, which seems very
application-specific. But I am sure you need a comma after the '|',
tiny or fat at your pleasure.
> while (<>) {
> print "found $1\n" if /($keyRE)/;
> }
And you probably want /o on that regex, so it isn't recompiled for every
line. (If the loop is intended to be reentered with a different regex,
wrap the whole thing in an eval STRING.)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 13 Nov 1999 08:46:24 -0600
From: TK Soh <r28629@email.sps.mot.com>
Subject: Re: Show me a better way!
Message-Id: <382D79C0.A274F7F9@email.sps.mot.com>
Jody Fedor wrote:
>
> I know this isn't bad when only doing a few comparisons
> but if there were 10 or 20 the code would be functional
> but a nitemare. How could it be written simpler?
>
> if ($cookies{'state'} eq "OH") {$tax = ($tcost * .055) + .005}
> elsif ($in{'fstate'} eq "OH") {$tax = ($tcost * .055) + .005}
> else {$tax = 0.00};
not sure what you mean by better, but your code will probably _look_
slightly better this way:
$tax = $cookies{'state'} eq "OH" ? ($tcost * .055) + .005 :
$in{'fstate'} eq "OH" ? ($tcost * .055) + .005 :
0.00 ;
HTH.
-TK
------------------------------
Date: Sun, 14 Nov 1999 00:55:43 -0500
From: "Jody Fedor" <JFedor@datacom-css.com>
Subject: Re: Show me a better way!
Message-Id: <80lhli$pck$1@plonk.apk.net>
Kragen Sitaker wrote in message ...
>Are you talking about 10 or 20 different states, 10 or 20 different
>hashes you might have to check to see if somebody is in Ohio, or 10 or
>20 different factors (city, county, neighborhood) to decide what tax
>rate to charge?
forgetting about tax rates, just a general programming in perl when you
want to check if else then if else then multiple times. In this example
there
are two different places to check to see if the customer is taxable, what if
there are 10 different places or comparisons to be made to see if the
customer is taxable?
Hope I didn't make this muddier than it already is.
Jody
------------------------------
Date: Sun, 14 Nov 1999 01:06:44 -0500
From: "Jody Fedor" <JFedor@datacom-css.com>
Subject: Re: Show me a better way!
Message-Id: <80lia5$pri$1@plonk.apk.net>
Jeff Zucker wrote in message <382DCE76.C684F558@vpservices.com>...
>
>I'd lose the ifs and use hashes and ors.
>
>my $state = $cookies{state} || $in{fstate} || '';
if $in{fstate} is null or "" and $cookies{state} = "OH" would $state="OH"?
What if both where "OH" if there were three comparisons or 4 if there
were multiple "OH"'s would $state="OH"? (Assuming of course one contained
OH)
such as:
my $state = $cookies{state} || $in{fstate} || $in{state} || $input{st} || ''
TIA
Jody
------------------------------
Date: Sat, 13 Nov 1999 20:00:07 -0600
From: "Blair Heuer" <ab@cd.com>
Subject: sort lists together
Message-Id: <80l59f$7i$1@oak.prod.itd.earthlink.net>
Is there a way to make a list move its items around in the same manner as
another?
What I mean, is say I have two lists ('jon','bob','tom') and
('21','15','18'). The first being the names, @name, and the second being the
ages, @age. I need a way that if I were to sort @age to make it
('15','18','21') then @name would become ('bob','tom','jon').
I simplified what I needed to do into name and age, but it is to be used for
sorting messages in a message board script. One list is the message id,
others being originator, modified date, replies, etc.
Thanks for any help,
Blair Heuer
------------------------------
Date: Sat, 13 Nov 1999 20:32:15 -0800
From: Bill Moseley <moseley@best.com>
Subject: Re: sort lists together
Message-Id: <MPG.1297db2976e739c4989871@nntp1.ba.best.com>
Blair Heuer (ab@cd.com) seems to say...
> Is there a way to make a list move its items around in the same manner as
> another?
>
> What I mean, is say I have two lists ('jon','bob','tom') and
> ('21','15','18'). The first being the names, @name, and the second being the
> ages, @age. I need a way that if I were to sort @age to make it
> ('15','18','21') then @name would become ('bob','tom','jon').
If you are really doing such a thing often enough then maybe you need to
reconsider how your data is stored. If, like in your example, you have
two lists that are related, then maybe you should make a data structure
that is related. Have a list of people where each entry points to a
data structure that contains both name and age. Then sorting by one
item (such as name) will sort all the associated data alone with it.
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: Sun, 14 Nov 1999 11:13:14 +0100
From: "Kastro Vinic" <kastrovinic@hotmail.com>
Subject: System Command
Message-Id: <80luqp$h3v$2@nnrp01.ops.uunet.co.za>
What is the ` doing.
eg. $out = `dir`;
is this like a system() command?
Thanx for prompt reply
------------------------------
Date: 14 Nov 1999 04:52:08 -0500
From: Scott Lanning <slanning@bu.edu>
Subject: Re: System Command
Message-Id: <kusbt8x5rjr.fsf@buphy.bu.edu>
"Kastro Vinic" <kastrovinic@hotmail.com> writes:
> What is the ` doing.
> eg. $out = `dir`;
> is this like a system() command?
The two differences as far I'm concerned are:
1) you can pass a list of more than one element to system()
like
system("sleep", "5");
as opposed to
system("sleep $foo");
and the first way prevents a malicious person from
breaking out a subshell (I think I read that on Lincoln
Stein's Web Programming Security page). The reason for
that is the list version passes the arguments directly
to exec(), while the second way passes the string to
be evaluated by the shell which processes metacharacters
which means a not-nice person might substitute naughty
commands in for $foo.
2) backticks return the output of the command, whereas
system() returns the exit status. So, if you got delerious
for a moment, you could write $foo = `awk -e 'print $1'`
to print the first record of a file, while system() would
probably return 0.
--
"I'm going to have fun telling you about this absurdity, because I
find it delightful." --Richard Feynman
------------------------------
Date: 14 Nov 1999 10:11:40 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: System Command
Message-Id: <slrn82t2oo.k89.mgjv@wobbie.heliotrope.home>
On 14 Nov 1999 04:52:08 -0500,
Scott Lanning <slanning@bu.edu> wrote:
> "Kastro Vinic" <kastrovinic@hotmail.com> writes:
> > What is the ` doing.
> > eg. $out = `dir`;
> > is this like a system() command?
The best answer to this of course would be: Check the manual page for
the system() function:
# perldoc -f system
> The two differences as far I'm concerned are:
>
> 1) you can pass a list of more than one element to system()
> like
>
> system("sleep", "5");
>
> as opposed to
>
> system("sleep $foo");
>
> and the first way prevents a malicious person from
> breaking out a subshell (I think I read that on Lincoln
> Stein's Web Programming Security page). The reason for
> that is the list version passes the arguments directly
> to exec(), while the second way passes the string to
> be evaluated by the shell which processes metacharacters
> which means a not-nice person might substitute naughty
> commands in for $foo.
Almost right. It passes the arguments directly to execvp(2). It's
indeed more efficient and safe, because it avoids calling a shell.
However, if the single string does not contain any shell
metacharacters, the string is split into words and passed off to
execvp as well.
It is almost always better to pass a list to exec() and system(),
unless you need the shell to intervene. It is almost always better,
for security reasons, to avoid backticks, and instead to fork and exec
explicitly. If security isn't as much an issue, backticks are fine.
Of course, sleep is a silly example, because we have that as a
builtin.
Martien
--
Martien Verbruggen |
Interactive Media Division | Make it idiot proof and someone will
Commercial Dynamics Pty. Ltd. | make a better idiot.
NSW, Australia |
------------------------------
Date: Sun, 14 Nov 1999 02:44:49 GMT
From: jradford@my-deja.com
Subject: Trying to use a variable as an operator
Message-Id: <80l7n1$ffg$1@nnrp1.deja.com>
I am wondering how to make the following code
work, I would like to be able to change the
"$operator" variable to other operators on the
fly, and still have it work:
$operator = 'eq';
if("text" $operator "text") {
do_something;
}
Best Regards,
Jim
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 13 Nov 1999 23:03:15 -0500
From: Scott Lanning <slanning@bu.edu>
Subject: Re: Trying to use a variable as an operator
Message-Id: <kusk8nlpvng.fsf@strange.bu.edu>
jradford@my-deja.com writes:
> I would like to be able to change the "$operator" variable
> to other operators on the fly, and still have it work:
>
> $operator = 'eq';
>
> if("text" $operator "text") {
> do_something;
> }
You can use eval().
#!/usr/local/bin/perl -w
use strict;
my @text = qw('foo' 'bar');
my $op = 'eq';
$_ = "$text[0] $op $text[0]";
print "text1=$text[0], text2=$text[0]: ";
if(eval){
print "matched\n";
}else {
print "didn't match\n";
}
$_ = "$text[0] $op $text[1]";
print "text1=$text[0], text2=$text[1]: ";
if(eval){
print "matched\n";
}else {
print "didn't match\n";
}
__END__
Alternatively, you can make a command hash like
#!/usr/local/bin/perl -w
use strict;
my @text = qw('foo' 'bar');
my $op = 'eq';
my %op = (
"eq" => \&is_equal,
etc...
);
print "1\n";
print "matched\n" if $op{$op}->($text[0], $text[1]);
print "2\n";
print "matched\n" if $op{$op}->($text[0], $text[0]);
sub is_equal {
return shift eq shift;
}
etc...
__END__
--
"One should not confuse this craving for change and novelty with the
indifference of play which is in its greatest levity at the same time
the most sublime and indeed the only true seriousness." --Georg Hegel
------------------------------
Date: Sun, 14 Nov 1999 05:41:36 GMT
From: "Douglas Garstang" <dgarstan@nsw.bigpond.net.au>
Subject: Re: Trying to use a variable as an operator
Message-Id: <kYrX3.3452$Xo.18732@news-server.bigpond.net.au>
Now THAT is nifty....
Scott Lanning wrote in message ...
>jradford@my-deja.com writes:
>> I would like to be able to change the "$operator" variable
>> to other operators on the fly, and still have it work:
>>
>> $operator = 'eq';
>>
>> if("text" $operator "text") {
>> do_something;
>> }
>
>You can use eval().
>
>#!/usr/local/bin/perl -w
>use strict;
>my @text = qw('foo' 'bar');
>my $op = 'eq';
>
>$_ = "$text[0] $op $text[0]";
>print "text1=$text[0], text2=$text[0]: ";
>if(eval){
> print "matched\n";
>}else {
> print "didn't match\n";
>}
>
>$_ = "$text[0] $op $text[1]";
>print "text1=$text[0], text2=$text[1]: ";
>if(eval){
> print "matched\n";
>}else {
> print "didn't match\n";
>}
>
>__END__
>
>
>Alternatively, you can make a command hash like
>
>#!/usr/local/bin/perl -w
>use strict;
>my @text = qw('foo' 'bar');
>my $op = 'eq';
>
>my %op = (
> "eq" => \&is_equal,
> etc...
>);
>
>print "1\n";
>print "matched\n" if $op{$op}->($text[0], $text[1]);
>print "2\n";
>print "matched\n" if $op{$op}->($text[0], $text[0]);
>
>sub is_equal {
> return shift eq shift;
>}
>
>etc...
>
>__END__
>
>--
>"One should not confuse this craving for change and novelty with the
>indifference of play which is in its greatest levity at the same time
>the most sublime and indeed the only true seriousness." --Georg Hegel
------------------------------
Date: 13 Nov 1999 22:19:18 -0500
From: Scott Lanning <slanning@bu.edu>
Subject: Re: unique search and replace problem
Message-Id: <kusn1shpxop.fsf@strange.bu.edu>
rancorr@hotmail.com writes:
> <option value="232">Bain & Company
>
> I want to create a Perl script that will replace the numbers with the
> name of the company that follows it three characters later. Thus, the
> above snipet will become:
>
> <option value="Bain & Company">Bain & Company
In what sense is this a "unique" problem? This is a trivial problem.
I'm wondering if I have ever seen a more trivial problem than the one
you just stated. Ever.
Everyone knows you didn't put *ANY* effort into solving this problem.
Who were you trying to fool?
No doubt you copied your homework assignments from one of the smart
kids in high school, didn't you? No, I'm not bitter, but now I think
it's payback time...
mwuuuhuuhaahhaahaaahahaaha.......
Come everyone, let us laugh and be condescending, for we are
Perl hackers!
--
"Every word is like an unnecessary stain on silence and nothingness."
--Samuel Beckett
------------------------------
Date: Sat, 13 Nov 1999 22:55:32 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Weekday in perl
Message-Id: <MPG.1297fcc0e9bed2b298a1f3@nntp.hpl.hp.com>
In article <382df959.15549087@news.idt.net> on Sat, 13 Nov 1999 23:51:34
GMT, Viscano <kc@disinfo.net> says...
> lol, sorry about the typo.
Typos come from typing code into your newsreader,
^^^^^ ^^^^^^
instead of copying and pasting code from a program that you have tested.
So posting a typo implies posting untested code, which is not a laughing
matter (at least in this newsgroup).
Grumble, grumble...
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
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 1373
**************************************