[18109] in Perl-Users-Digest
Perl-Users Digest, Issue: 269 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 11 14:05:50 2001
Date: Sun, 11 Feb 2001 11:05:09 -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: <981918309-v10-i269@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 11 Feb 2001 Volume: 10 Number: 269
Today's topics:
[Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
ANNOUNCE: DDL::Oracle v1.01 <rvsutherland@yahoo.com>
Re: Array printing <aidounif@club-internet.fr>
Re: Builing INSERT-statement from hash (Mark Jason Dominus)
Re: Free Movie Ticket Give-away for solving the basic p <matthewl@uwm.edu>
Re: Free Movie Ticket Give-away for solving the basic p <callgirl@la.znet.com>
Full system path... <webmaster@reallyusefulcomputer.co.uk>
Re: Full system path... egwong@netcom.com
Re: Full system path... <tony_curtis32@yahoo.com>
Help with form code <jdthelen@worldnet.att.net>
Re: Help with form code egwong@netcom.com
Re: Help! Good Perl Training class recomendation in Sil <comdog@panix.com>
hiding source (was Re: perl in linux NEWBIE) egwong@netcom.com
How to retrieve local machine ip address <david.reynolds@fuse.net>
Re: How to retrieve local machine ip address (Clinton A. Pierce)
Re: How to retrieve local machine ip address <david.reynolds@fuse.net>
Re: How to retrieve local machine ip address <DNess@Home.Com>
Install PERL/PWS-InetPub on Millennium <johnwade@ethological.com>
LWP::Simple hangs? cgould@gate.net
MS Access Databses <dj@buybritishweb.co.uk>
perl in linux NEWBIE <odyssey@mercuryin.es>
Re: Processing form arrays in perl.. help !! <dave@dave.org.uk>
Re: sort of about sort (Mark Jason Dominus)
Re: split a path and keep the slashes? <bart.lateur@skynet.be>
Strange Perl Newbie Question bigrio@yahoo.com
Re: Strange Perl Newbie Question <carvdawg@patriot.net>
Re: Strange Perl Newbie Question (Garry Williams)
Re: Strange Perl Newbie Question (Lee Webb)
Re: XML: "Flattening" XML to dot notation - best module (Clinton A. Pierce)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 11 Feb 2001 11:21:08 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage981890640.22128@news.teleport.com>
Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 29 Apr 2000
[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last _major_ update of the Perl FAQ was in Summer
of 1998; of course, ongoing updates are made as needed. ]
For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).
http://www.cpan.org/doc/FAQs/
Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.
For an alternative way to get answers, check out the Perlfaq website.
http://www.perlfaq.com/
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.
perldoc perlfaq
man perlfaq
If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.
If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.
http://www.cpan.org/
http://www.perl.com/CPAN/
http://www.cpan.org/doc/FAQs/FAQ/html/
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/
You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)
California ftp://ftp.cdrom.com/pub/perl/CPAN/
Texas ftp://ftp.metronet.com/pub/perl/
South Africa ftp://ftp.is.co.za/programming/perl/CPAN/
Japan ftp://ftp.dti.ad.jp/pub/lang/CPAN/
Australia ftp://cpan.topend.com.au/pub/CPAN/
Netherlands ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
Switzerland ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
Chile ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/
If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.
Have fun with Perl!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 11 Feb 2001 12:07:50 -0500
From: "Richard Sutherland" <rvsutherland@yahoo.com>
Subject: ANNOUNCE: DDL::Oracle v1.01
Message-Id: <t8diihjff2n093@corp.supernews.com>
===========================================================================
Release of DDL::Oracle, Version 1.01
===========================================================================
CHANGES
Impemented Jan Pazdziora's (adelton@fi.muni.cz) support for Domain Indexes.
Thanks, Jan!
Jan also sent in a patch which fixed a null PCTINCREASE for some oddball
CREATE INDEX
statements.
Reported bugs in the following areas were fixed:
Connections from Oracle7x
Missing ON DELETE CASCADE in Referential Integrity constraints
Table and column COMMENTs containing quotes
DESCRIPTION
Designed for Oracle DBA's and users, for Oracle versions 7.3, 8.0
and 8i. Reverse engineers database objects (tables, indexes, users,
profiles, tablespaces, roles, constraints, etc.). Generates DDL to
*resize* tables and indexes to the provided standard or to a user
defined standard. Can reorganize/defragment tablespaces.
SYNOPSIS
use DBI;
use DDL::Oracle;
my $dbh = DBI->connect(
"dbi:Oracle:dbname",
"username",
"password",
{
PrintError => 0,
RaiseError => 1
}
);
# Use default resizing and schema options.
# query default DBA_xxx tables (could use USER_xxx for non-DBA types)
DDL::Oracle->configure(
dbh => $dbh,
);
# Create a list of one or more objects
my $sth = $dbh->prepare(
"SELECT
owner
, name
FROM
dba_tables
WHERE
tablespace_name = 'MY_TBLSP' -- your millage may vary
"
);
$sth->execute;
my $list = $sth->fetchall_arrayref;
my $obj = DDL::Oracle->new(
type => "table",
list => $list, );
);
my $ddl = $obj->
create; # or $obj->resize; or $obj->drop; etc.
print $ddl; # Use STDOUT so user can redirect to desired file.
AUTHOR
Richard V. Sutherland
rvsutherland@yahoo.com
COPYRIGHT
Copyright (c) 2000, 2001 Richard V. Sutherland. All rights reserved.
This module is free software. It may be used, redistributed, and/or
modified under the same terms as Perl itself. See:
http://www.perl.com/perl/misc/Artistic.html
===========================================================================
AVAILABILITY
===========================================================================
DDL::Oracle is available from the CPAN, and from:
http://sourceforge.net/projects/ddl-oracle/
------------------------------
Date: Sun, 11 Feb 2001 14:21:09 -0000
From: "Frédéric Aidouni" <aidounif@club-internet.fr>
Subject: Re: Array printing
Message-Id: <9663q1$oib$1@front2.grolier.fr>
> See the perlvar manual page. Look for the variable called $"
>
thanx a lot! :o)
------------------------------
Date: Sun, 11 Feb 2001 12:46:48 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Builing INSERT-statement from hash
Message-Id: <3a8689b8.57d3$58@news.op.net>
Keywords: confluent, desperate, indefensible, marina
In article <3A861049.8A3ECCB2@home.com>,
Rick Delaney <rick.delaney@home.com> wrote:
>Mark Jason Dominus wrote:
>>
>> my $sth = $dbh->prepare(qq|INSERT INTO tbl
>> ($FIELDS) VALUES ($QQQ)|);
>> for my $hash (@hashes) { # $hash is one hashref as in your example
>> $sth->execute(@{$hash}(@fields));
>> }
>>
>> This assumes that every $hash has all the fields; if not you have to
>> add some extra processing to turn the Perl 'undef' values into the
>> 'NULL' that SQL expects.
>
>DBI will do that processing for you,
Yeah, I wonder what I was thinking? Thanks for the correction.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Sun, 11 Feb 2001 05:00:41 -0600
From: Matthew Leonhardt <matthewl@uwm.edu>
Subject: Re: Free Movie Ticket Give-away for solving the basic problem on Time:HiRes.pm module
Message-Id: <3a8671c1$0$7170$272ea4a1@news.execpc.com>
"Godzilla!" wrote:
>
> Carmari wrote:
>
> > I am writing a TIMER program with HiResolution requirement. Basically, we
> > can get 4.34 double precision seconds from timeofday function ( from
> > TIME::HiRes) . However, I got problem on the very simple implementation.
>
> > Here is the detail:
>
> > Please read and let me know what is the problem. Thank you. I will send you
> > a free movie ticket as reward. Promise!!!
>
> Your problem is you forgot to include the details.
Hmmm....and to think you must have even highlighted the output he listed
from a perl -c of the program when you erased it before responding.
Matt
'I see stupid people. They're everywhere. They walk around like
everybody else. Most of them don't even know they're dumb.'
------------------------------
Date: Sun, 11 Feb 2001 08:37:33 -0800
From: Kira <callgirl@la.znet.com>
Subject: Re: Free Movie Ticket Give-away for solving the basic problem on Time:HiRes.pm module
Message-Id: <3A86BFCD.35609C17@la.znet.com>
Matthew Leonhardt wrote:
> "Godzilla!" wrote:
> > Carmari wrote:
> > > I am writing a TIMER program with HiResolution requirement. Basically, we
> > > can get 4.34 double precision seconds from timeofday function ( from
> > > TIME::HiRes) . However, I got problem on the very simple implementation.
> > > Here is the detail:
> > > Please read and let me know what is the problem. Thank you. I will send you
> > > a free movie ticket as reward. Promise!!!
> > Your problem is you forgot to include the details.
> Hmmm....and to think you must have even highlighted the output he listed
> from a perl -c of the program when you erased it before responding.
I will make a polite suggestion. Visit your local community
college and enroll in a Bonehead English class. Upon
successful completion of this class, perhaps your reading
comprehension skills will be moderately improved.
Godzilla!
------------------------------
Date: Sun, 11 Feb 2001 15:52:34 -0000
From: "Wildthing" <webmaster@reallyusefulcomputer.co.uk>
Subject: Full system path...
Message-Id: <Ltyh6.2229$I5.66089@stones>
I'm new to Perl and can't seem to figure out the sytax for a full system
path.
The File I'm adapting is a cgi banner rotator with the line
$datalocation="/www/w143031/docs/cgi-bin/advbanner/data";
#Change this line to the full system path to the location where you want the
script to store the data file.
The full sytem path is
http://reallyuseful.sitesource.co.uk/my-cgi/advbanner/data/
I've treid various combinations but can't get it to reference the data file.
How does the URL translate to the Perl syntax?
------------------------------
Date: Sun, 11 Feb 2001 18:55:29 GMT
From: egwong@netcom.com
Subject: Re: Full system path...
Message-Id: <BeBh6.5512$y03.351174@news.flash.net>
Wildthing <webmaster@reallyusefulcomputer.co.uk> wrote:
> I'm new to Perl and can't seem to figure out the sytax for a full system
> path.
> The File I'm adapting is a cgi banner rotator with the line
> $datalocation="/www/w143031/docs/cgi-bin/advbanner/data";
> #Change this line to the full system path to the location where you want the
> script to store the data file.
> The full sytem path is
> http://reallyuseful.sitesource.co.uk/my-cgi/advbanner/data/
> I've treid various combinations but can't get it to reference the data file.
> How does the URL translate to the Perl syntax?
As you have pointed out, there are two ways to refer to a file. The
first is what you call the "full system path". This is the path you
would enter on the command line of your computer in order to access
the file. The second is the url, which is what you would enter in your
browser. In your case, it looks like
full system path:
/www/w143031/docs/cgi-bin/advbanner/data
url:
http://reallyuseful.sitesource.co.uk/my-cgi/advbanner/data/
I'm not positive with respect to your particular application, but
typically a perl script will need the full system path and *not*
the url. A very common problem in these cases is that, because the
web server is run under a different uid than your own, you have to
make sure that the file the script wants is accessible to the web
server's uid. That means you need to make sure that the data file
is world-readable ("chmod 644") if it's a read-only application or
world-writable ("chmod 666") if it's read/write.
Also, I'd like to point out a possibly serious security flaw here.
Since your data file does not have to be seen by anyone other than
the script, it should *not* be placed in any directory that's
accessible to the web server. The danger is that someone will go
to their browser and enter
http://reallyuseful.sitesource.co.uk/my-cgi/advbanner/data/file.txt
and get some good, exploitable knowledge on how your site works.
It's always better to put your data/config files somewhere below
the public areas (e.g. /www/w143031/config).
HTH, ERic
------------------------------
Date: 11 Feb 2001 13:04:17 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Full system path...
Message-Id: <87ofw982j2.fsf@limey.hpcc.uh.edu>
>> On Sun, 11 Feb 2001 15:52:34 -0000,
>> "Wildthing" <webmaster@reallyusefulcomputer.co.uk> said:
> I'm new to Perl and can't seem to figure out the sytax
> for a full system path. The File I'm adapting is a cgi
> banner rotator with the line
> $datalocation="/www/w143031/docs/cgi-bin/advbanner/data";
> #Change this line to the full system path to the
> location where you want the script to store the data
> file.
> The full sytem path is
> http://reallyuseful.sitesource.co.uk/my-cgi/advbanner/data/
> I've treid various combinations but can't get it to
> reference the data file. How does the URL translate to
> the Perl syntax?
Depends on the server config. $datalocation is a location
in the filesystem. The URL is, well, a URL. It doesn't
translate into any underlying physical object outside of
the server it is located on.
/my-cgi/advbanner/data/ may translate into just about
anything, depending on the server's translation rules. If
you want to know what this corresponds to underneath you
need to know where the web server's files are actually
stored. This may or may not be available to CGI programs
in the environment (check server documentation).
Either way, it isn't really anything to do with perl
per(l) se, I would suggest moving to
comp.infosystenms.www.authoring.cgi
hth
t
--
The avalanche has already started.
It is too late for the pebbles to vote.
------------------------------
Date: Sun, 11 Feb 2001 17:07:44 GMT
From: "James Thelen" <jdthelen@worldnet.att.net>
Subject: Help with form code
Message-Id: <AFzh6.3864$Pg3.301214@bgtnsc06-news.ops.worldnet.att.net>
Looking for code or script that will return sequentially numbered invoices
or other numbers when used in a hidden field within an html form. It must
allow setting of the start number. Please help me. TIA
------------------------------
Date: Sun, 11 Feb 2001 18:40:08 GMT
From: egwong@netcom.com
Subject: Re: Help with form code
Message-Id: <c0Bh6.5488$y03.351174@news.flash.net>
James Thelen <jdthelen@worldnet.att.net> wrote:
> Looking for code or script that will return sequentially numbered invoices
> or other numbers when used in a hidden field within an html form. It must
> allow setting of the start number. Please help me. TIA
#!/usr/bin/perl -Tw
use strict;
use CGI qw/ :standard /;
print header,
ul( map { li($_) } sort { $a <=> $b } param('numbers') );
This uses the CGI.pm module (available at CPAN) and assumes your
hidden parameter is named "numbers". Note how, in list context,
param will return an array. The spaceship operator ('<=>') does
the comparison numerically, so 10 comes after 9, not before it
(as would happen with the default sort). map applies an operation
(in this case, putting the list inside of "<li></li>") to every
element of a list.
See CGI (:standard, header, ul, li, param), perlop (starship), perldata
(discussion of scalar/list context) and perlfunc (map, sort).
(When you mentioned invoices, my internal alarm bells go off :)
By the way, I don't know whether or not you're actually doing this,
but if you're relying on a "hidden" form field being secure, don't.
It's easy enough for anyone to spoof so they can send any arbitrary list
of invoices. If you need to pass around secure data, use a hashing
algorithm like MD5 (see Digest::MD5) so you can check your data's
integrity. Ideally, you won't ever have to pass around secure data.
HTH, ERic
------------------------------
Date: Sun, 11 Feb 2001 08:38:10 -0800
From: brian d foy <comdog@panix.com>
Subject: Re: Help! Good Perl Training class recomendation in Silicon Valley needed!
Message-Id: <comdog-621C98.08381011022001@news.panix.com>
In article <9628ne$8cm$2@216.155.32.222>, The WebDragon
<nospam@nospam.com> wrote:
> In article <3A831E11.8513C24D@oracle.com>, Terrence Monroe Brannon
> <terrence.brannon@oracle.com> wrote:
>
> | Maybe you should consult the Silicon Valley Perl mongers. I'm sure they
> | would know of some good resources.
>
> on a similar note, where would I look for similar resources here in
> Delaware, USA? Is there a website that lists such things by area?
www.pm.org
--
brian d foy <comdog@panix.com>
------------------------------
Date: Sun, 11 Feb 2001 19:01:48 GMT
From: egwong@netcom.com
Subject: hiding source (was Re: perl in linux NEWBIE)
Message-Id: <wkBh6.5517$y03.351174@news.flash.net>
triplex <odyssey@mercuryin.es> wrote:
> i did a perl program nothing fancy but just to start with..
> i just wanan know how you can make a perl program.. when you cat the
> program you dont see its source..
> for example if you "cat" an executable in linux you see gibirish but
> when i cat a program i do in linux in perl i see the srouce code.. how
> can i make it that you dont seee the srouce code when you make it into
> an executable
This is a faq. See the question "How can I hide the source for my Perl
program?" in perlfaq3 (look at "How can I compile my Perl program into
byte code or C?" while you're at it.)
If you choose a more descriptive subject heading, you're sure to
get better (more, at any rate) response.
FWIW, when you cat a binary executable, you *do* see the source, you
just need to know how to read it :)
HTH, Eric
------------------------------
Date: Sun, 11 Feb 2001 12:58:09 -0500
From: "David Reynolds" <david.reynolds@fuse.net>
Subject: How to retrieve local machine ip address
Message-Id: <t8dkmfjnmviu8e@corp.supernews.com>
Hi everyone,
I was wondering how to retreive an ip address to a local PC. I have client
that want to use local ip address to indentify machines over a network and I
was wondering how to accomplish that task in Perl. I can't find this
information in any of my Perl books. All help is greatly appreciated.
David
------------------------------
Date: Sun, 11 Feb 2001 18:05:55 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: How to retrieve local machine ip address
Message-Id: <7wAh6.299354$hD4.72050990@news1.rdc1.mi.home.com>
[Posted and mailed]
In article <t8dkmfjnmviu8e@corp.supernews.com>,
"David Reynolds" <david.reynolds@fuse.net> writes:
> I was wondering how to retreive an ip address to a local PC. I have client
> that want to use local ip address to indentify machines over a network and I
> was wondering how to accomplish that task in Perl. I can't find this
> information in any of my Perl books. All help is greatly appreciated.
A cheating way from the PDD:
# Solves a recurring question: How do I find
# my own IP address? It does this by establishing
# a foreign connection and then noticing what
# interface was used. This isn't foolproof and having
# multiple interfaces is one way to fool this.
use Socket;
# Where we connect to is not important...as long as it's
# not *here*.
socket(SOCK, AF_INET, SOCK_STREAM, getprotobyname('tcp'))
or die "Cannot create socket: $!";
$remoteport=getservbyname("www", "tcp");
# Won't work if you actually run this at Yahoo. Change as necessary.
connect(SOCK, sockaddr_in($remoteport, inet_aton("www.yahoo.com")))
or die "Cannot connect to server: $!";
# Find my half of the connection
$myaddr=(getsockname(SOCK))[0];
($port, $address)=sockaddr_in($myaddr);
print "My local IP address is ", inet_ntoa($address);
If you've got multiple interfaces, this one gives you the address of
the one that was used to connect externally -- normally the one you
want.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours!
clintp@geeksalad.org for details see http://www.geeksalad.org
"If you rush a Miracle Man,
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Sun, 11 Feb 2001 13:21:21 -0500
From: "David Reynolds" <david.reynolds@fuse.net>
Subject: Re: How to retrieve local machine ip address
Message-Id: <t8dm23f9ilefc1@corp.supernews.com>
Hi Clinton,
I tried using it on my machine, but I keep getting an error. I'm not sure
if I'm not following the instructions correctly. Is there something I
should modify to the code to make it work.
David
"Clinton A. Pierce" <clintp@geeksalad.org> wrote in message
news:7wAh6.299354$hD4.72050990@news1.rdc1.mi.home.com...
> [Posted and mailed]
>
> In article <t8dkmfjnmviu8e@corp.supernews.com>,
> "David Reynolds" <david.reynolds@fuse.net> writes:
> > I was wondering how to retreive an ip address to a local PC. I have
client
> > that want to use local ip address to indentify machines over a network
and I
> > was wondering how to accomplish that task in Perl. I can't find this
> > information in any of my Perl books. All help is greatly appreciated.
>
> A cheating way from the PDD:
>
> # Solves a recurring question: How do I find
> # my own IP address? It does this by establishing
> # a foreign connection and then noticing what
> # interface was used. This isn't foolproof and having
> # multiple interfaces is one way to fool this.
> use Socket;
>
> # Where we connect to is not important...as long as it's
> # not *here*.
> socket(SOCK, AF_INET, SOCK_STREAM, getprotobyname('tcp'))
> or die "Cannot create socket: $!";
> $remoteport=getservbyname("www", "tcp");
>
> # Won't work if you actually run this at Yahoo. Change as
necessary.
> connect(SOCK, sockaddr_in($remoteport,
inet_aton("www.yahoo.com")))
> or die "Cannot connect to server: $!";
>
> # Find my half of the connection
> $myaddr=(getsockname(SOCK))[0];
>
> ($port, $address)=sockaddr_in($myaddr);
> print "My local IP address is ", inet_ntoa($address);
>
> If you've got multiple interfaces, this one gives you the address of
> the one that was used to connect externally -- normally the one you
> want.
>
> --
> Clinton A. Pierce Teach Yourself Perl in 24 Hours!
> clintp@geeksalad.org for details see http://www.geeksalad.org
> "If you rush a Miracle Man,
> you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Sun, 11 Feb 2001 18:57:09 GMT
From: David Ness <DNess@Home.Com>
Subject: Re: How to retrieve local machine ip address
Message-Id: <3A86E089.9A004421@Home.Com>
David Reynolds wrote:
>
> Hi everyone,
>
> I was wondering how to retreive an ip address to a local PC. I have client
> that want to use local ip address to indentify machines over a network and I
> was wondering how to accomplish that task in Perl. I can't find this
> information in any of my Perl books. All help is greatly appreciated.
>
> David
It's not a perl problem. It's really an `OS' problem, as it depends on who
is really in charge of your TCP/IP stack. If you are a windows user, for
example you could easily use perl to run an `IPCONFIG >A.TMP' and then
read `A.TMP' and get the answer.
------------------------------
Date: Sun, 11 Feb 2001 18:59:55 GMT
From: "John Wade" <johnwade@ethological.com>
Subject: Install PERL/PWS-InetPub on Millennium
Message-Id: <LiBh6.98265$Pm2.1921166@news20.bellglobal.com>
I'm looking for instructions on how to install all of the above on
Millennium so I can learn PERL. I recently figured out where to find and how
to install the same on Win98SE, but nothing for Millennium.
jw
------------------------------
Date: Sun, 11 Feb 2001 18:42:49 GMT
From: cgould@gate.net
Subject: LWP::Simple hangs?
Message-Id: <966mf8$cdi$1@nnrp1.deja.com>
Simplified server-side web script for perl:
#!/usr/local/bin/perl -w
use CGI;
use strict;
use LWP::Simple;
# OOP for CGI
my $q = new CGI;
my $urlname = $q -> param ('url');
if ($urlname =~ /http\:/) { } else {die();}
print $q -> header or die();
my $content = get($urlname) or die("Net error!");
print $content or die("$!");
#END
On occasions, this script seems to hang without being killed off. This
leads to annoyingly large amounts of CPU time and memory usage. Can
anyone think of a reason for this?
Apologies for the newbieness of this...
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Sun, 11 Feb 2001 11:57:00 -0000
From: "GBs" <dj@buybritishweb.co.uk>
Subject: MS Access Databses
Message-Id: <J8vh6.8037$zz4.198566@news2-win.server.ntlworld.com>
Does any1 here know of a PERL script that will enable me to manipulate a
Microsoft Access Database online?
If u do, could you please give me some info on it
Cheerz
--
All the latest british sports news on the web, or delivered to your e-mail
inbox
http://gbsportz.virtualave.net/
football, tennis, rugby, cricket, golf, motorsport and more
------------------------------
Date: Sun, 11 Feb 2001 14:41:23 +0100
From: triplex <odyssey@mercuryin.es>
Subject: perl in linux NEWBIE
Message-Id: <3A869683.6040900@mercuryin.es>
i did a perl program nothing fancy but just to start with..
i just wanan know how you can make a perl program.. when you cat the
program you dont see its source..
for example if you "cat" an executable in linux you see gibirish but
when i cat a program i do in linux in perl i see the srouce code.. how
can i make it that you dont seee the srouce code when you make it into
an executable
------------------------------
Date: Sun, 11 Feb 2001 18:05:36 +0000
From: Dave Cross <dave@dave.org.uk>
Subject: Re: Processing form arrays in perl.. help !!
Message-Id: <7vkd8t0ooj91tmiv3n9s0497esk8bnsr63@4ax.com>
On Sat, 10 Feb 2001 17:10:36 -0000, "abu eesaa"
<totalmailer@yahoo.com> wrote:
>
>Hello one and all
>
>could anyone advise how to process an array in a form back to the perl
>script (in this case auction.cgi).
>
>eg
>
>have a form :
>
><form name="display" action="$ENV{'SCRIPT_NAME'}" method="POST">
>
>this is followed by a list of files :
>
><input type='CHECKBOX' name='items[]' value='computers_subi1954078514'>
>
><input type='CHECKBOX' name='items[]' value='computers_subi121211212'>
>
><input type='CHECKBOX' name='items[]' value='computers_subi1211212'>
>
>etc
>etc
>
>so when this is "actioned" how do I access the array that holds these items
>:
>
>I am trying this :
>
>@items = $form{'items[]'}
>
>this only seems to store the last ticked item.
>
>Can any of you perl experts help.
Sounds like a bug in whatever is filling in the contents of your %form
hash. This is a frequent source of errors in CGI scripts - maybe the
form parser was copied from one of Matt's scripts. It would have been
easier to help had you shown us the appropriate piece of code.
Use CGI.pm's param function to get your CGI arguments. Unlike just
about every other CGI parameter parser I've ever seen - it does it
right.
Dave...
--
<http://www.dave.org.uk> SMS: sms@dave.org.uk
------------------------------
Date: Sun, 11 Feb 2001 12:42:48 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: sort of about sort
Message-Id: <3a8688c7.57b6$3c1@news.op.net>
In article <960ltm$krd$1@bob.news.rcn.net>,
Eric Bohlman <ebohlman@omsdev.com> wrote:
>In this case, there really is, IMHO, justification for OMWTDI:
>default sorts are significantly faster than sorts using a comparison
>block
Yes, but the Right Thing To Do is to recognize those sorts at compile
time and optimize them. Greg Bacon contributed a patch some time ago
to do precisely that; the optimization is in 5.6.0. If you write
sort { $a cmp $b } ...
then it compiles as if you had written
sort ...;
and similarly, if you ask for
sort { $b <=> $a } ...
then it uses a special-purpose built-in comparison function analogous
to the one used by the default sort "sort @ar".
The relevant code is the function S_simplify_sort in the vicinity of
line 6052 of op.c in the 5.6.0 distribution.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Sun, 11 Feb 2001 11:53:26 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: split a path and keep the slashes?
Message-Id: <06vc8ts6u4arf3os6md5danq4h2gbaaum9@4ax.com>
tebrusca@my-deja.com wrote:
>Here's what I came up with:
>
>my $string = "/A/B///";
>my @list = map {"/$_"}( map {/^(.+)/}(split( /\//, $string )));
>
>Am I breaking the "Dont modify $_" rule with my first ( actually
>second) map?
You're not modifying $_. And this is shorter:
my @list = map "/$_", grep length, split /\//, $string ;
As for another approch:
my @list = $string =~ m#/[^/]+#g;
--
Bart.
------------------------------
Date: Sun, 11 Feb 2001 12:33:59 GMT
From: bigrio@yahoo.com
Subject: Strange Perl Newbie Question
Message-Id: <9660rn$skm$1@nnrp1.deja.com>
I have used perl in Windows platform for some years.
I want to use perl in linux environment with bash.
But when I run simple test perl file, there is some error.
My Perl source :
#!/usr/bin/perl
print "hello\n";
Perl path in my linux : /usr/bin/perl
when I tried to run the file by typing file name and hit enter
key, there is error like below.
Also the mode of file is 755 which can be executable.
#prompt>test.pl
bash: test.pl: command not found
I cannot figure out why this error happens!
Would you be so kind as to let me know the reason and
workaournd for this simple but strange problem?
Thanks in advance, bye.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Sun, 11 Feb 2001 07:57:37 -0500
From: H C <carvdawg@patriot.net>
Subject: Re: Strange Perl Newbie Question
Message-Id: <3A868C41.7F3FDD40@patriot.net>
./test.pl ???
bigrio@yahoo.com wrote:
> I have used perl in Windows platform for some years.
> I want to use perl in linux environment with bash.
>
> But when I run simple test perl file, there is some error.
>
> My Perl source :
> #!/usr/bin/perl
>
> print "hello\n";
>
> Perl path in my linux : /usr/bin/perl
>
> when I tried to run the file by typing file name and hit enter
> key, there is error like below.
> Also the mode of file is 755 which can be executable.
>
> #prompt>test.pl
> bash: test.pl: command not found
>
> I cannot figure out why this error happens!
> Would you be so kind as to let me know the reason and
> workaournd for this simple but strange problem?
>
> Thanks in advance, bye.
>
> Sent via Deja.com
> http://www.deja.com/
------------------------------
Date: Sun, 11 Feb 2001 13:12:14 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Strange Perl Newbie Question
Message-Id: <Ocwh6.1350$ZS3.2055@eagle.america.net>
On Sun, 11 Feb 2001 12:33:59 GMT, bigrio@yahoo.com <bigrio@yahoo.com>
wrote:
>I have used perl in Windows platform for some years.
>I want to use perl in linux environment with bash.
[snip]
>#prompt>test.pl
>bash: test.pl: command not found
This is not a Perl problem.
Unlike Windows, the PATH variable in Unix is the last word on the
search path for programs to execute. In Windows, the current
directory is searched no matter what the path is. You probably do not
have the current directory included in your PATH variable.
Change your command to:
./test.pl
It is unwise to include the current directory in your PATH variable.
If you must, place it at the end.
--
Garry Williams
------------------------------
Date: 11 Feb 2001 16:53:26 GMT
From: lee@localhost.localdomain (Lee Webb)
Subject: Re: Strange Perl Newbie Question
Message-Id: <slrn98dgtb.a89.lee@localhost.localdomain>
On Sun, 11 Feb 2001 12:33:59 GMT, bigrio@yahoo.com wrote:
>I want to use perl in linux environment with bash.
>But when I run simple test perl file, there is some error.
>
>My Perl source :
>#!/usr/bin/perl
>
>print "hello\n";
>
>Perl path in my linux : /usr/bin/perl
>
>when I tried to run the file by typing file name and hit enter
>key, there is error like below.
>Also the mode of file is 755 which can be executable.
>
>#prompt>test.pl
>bash: test.pl: command not found
>
It's not actually a "perl" path problem, rather a "test.pl" path problem:
You tried to run test.pl by typing its name at the prompt. However, you will
probably find that test.pl isn't in your path. Go get around this, you have to
call test.pl as:
$ ./test.pl
P.S. It's usually best to avoid name "test" programs as 'test'. Yes, I know
you're appending an extension onto it to tell you that it's a perl script, but
one of these days you may forget to put on a extension and end up calling
/usr/bin/test.
Lee.
------------------------------
Date: Sun, 11 Feb 2001 16:37:49 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: XML: "Flattening" XML to dot notation - best module?
Message-Id: <xdzh6.299052$hD4.72000551@news1.rdc1.mi.home.com>
In article <id698tsakcm68sqmk17vs295upqobav75i@4ax.com>,
Bart Lateur <bart.lateur@skynet.be> writes:
> Matt Kruse wrote:
>
>>I want to "flatten" XML into dot notation. For example:
>><foo><bar>X</bar><bar2>Y</bar2></foo>
>>
>>Becomes: foo.bar = X, foo.bar2 = Y
>>
> This doesn't quite work:
> [code trimmed]
> but mainly because XML::Parser doesn't ignore whitespace. So you must
> weed them out.
>
> Careful: text can be split over multiple calls to the Char handler. So,
> you ought to append the text to a string, and not print it out straight
> away.
This does quite work, well mostly.
use strict;
use warnings;
use XML::Parser;
my(@elem,$c);
my $p = new XML::Parser(Handlers => {
Start => sub { push(@elem, $_[1]) },
Char => sub { $c.=$_[1]; },
End => sub {
# Weed out yer leading/trailing whitespace
$c=~s/(^\s+|\s+$)//g;
print join('.', @elem), qq{="$c"\n};
pop(@elem); $c="";
},
});
$p->parse(<<'#EOT#');
<foo>
<bar>X</bar>
<bar2>Y</bar2>
<jerkcity>
<pants>HLAG</pants>
</jerkcity>
<narf/>
</foo>
#EOT#
The char-handler-being-called-multiple-times-for-a-single-bit-of-text
thing bit a co-worker a couple of weeks ago. Nasty bugs resulted. :)
foo.bar="X"
foo.bar2="Y"
foo.jerkcity.pants="HLAG"
foo.jerkcity=""
foo.narf=""
foo=""
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours!
clintp@geeksalad.org for details see http://www.geeksalad.org
"If you rush a Miracle Man,
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
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 V10 Issue 269
**************************************