[25420] in Perl-Users-Digest
Perl-Users Digest, Issue: 7665 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 18 03:05:58 2005
Date: Tue, 18 Jan 2005 00:05:19 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 18 Jan 2005 Volume: 10 Number: 7665
Today's topics:
"Found Perl" <comdog@panix.com>
Re: "Found Perl" <bigiain@mightymedia.com.au>
Re: [newbie] chomp acting weird (or me not understandin <bik.mido@tiscalinet.it>
Re: [perl-python] 20050116 defining a function <tadmc@augustmail.com>
Re: [perl-python] 20050116 defining a function <dave@dave.org.uk>
Re: [perl-python] 20050117, filter, map <tadmc@augustmail.com>
[perl-python] 20050118 keyed list <xah@xahlee.org>
Re: alternative to MS word doc <matthew.garrish@sympatico.ca>
Re: alternative to MS word doc <bik.mido@tiscalinet.it>
Re: creating socket on specific IP address <alex_the_hart@yahoo.com>
Re: creating socket on specific IP address <bik.mido@tiscalinet.it>
Re: How to compare files? <bik.mido@tiscalinet.it>
Re: How to compare files? <josef.moellers@fujitsu-siemens.com>
Re: How to compare files? <josef.moellers@fujitsu-siemens.com>
Re: how to skip to a certain loop with debugging option <see_sig@invalid>
Re: HTTP Get with Proxy authentication <matthew.garrish@sympatico.ca>
Re: HTTP Get with Proxy authentication <aprz43@yahoo.com.au>
Re: HTTP Get with Proxy authentication <aprz43@yahoo.com.au>
Re: looking for constructive criticism on this script.. <perl@lennychallis.co.uk>
Re: MAP Question <bik.mido@tiscalinet.it>
Re: Multi-dim hash slices <tadmc@augustmail.com>
Re: Need help with Perl and MySQL database data load <toreau@gmail.com>
Re: Perl CGI script to emulate a shell command line win (David Efflandt)
Re: Rearrange graphically a perl module: my poorman sol <bik.mido@tiscalinet.it>
Re: Taint problem with ActiveState <bik.mido@tiscalinet.it>
Re: validate XML file content sa_ravenone@yahoo.com
Re: Where do you report perl bugs? <tadmc@augustmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 17 Jan 2005 21:10:46 -0600
From: brian d foy <comdog@panix.com>
Subject: "Found Perl"
Message-Id: <170120052110468477%comdog@panix.com>
I'm creating "Found Perl"[0], a little, virtual Perl memorabilia museum.
I've got a lot of stuff to include, and I bet the community has orders
of magnitude more.
I've been looking at Found Magazine[1] since I heard about it on
This American Life[2]. They publish pictures things that people find
lying about: mostly flat things like scraps of paper. I'd like to do
that for Perl.
For instance, I have on display:
* Pictures of a couple of versions of the Perl Monger t-shirt
* The temporary camel tattoo I was giving out at one of the Perl
conferences
* My original receipt for my first copy of Programming perl
* Mark Jason's card announcing "Perl Advanced Techniques Handbook"
(now "Higher Order Perl")
* and some other things
There is a lot of stuff I'd like to find, and even more stuff I probably
don't know about. If you have something, please send me an image or scan
at found@theperlreview.com[3].
* a picture of Amelia, the camel mascot of London.pm
* Nat's "Perl is my bitch" sticker set (What were the other slogans?
* An original blow-in card for The Perl Journal
* Pictures of other Perl t-shirts, especially the one given out at
the first couple of Perl conferences
* The O'Reilly beret given out at one of the Perl conferences
* Scans of signatures from various Perl people (I don't have
any myself)
* Tim Bunce's handwriting on a bar napkin saying "Generic database
interface: use GDI or something" :)
* Images of swag (keychains, water bottles, pens) that Perl
vendors gave out.
* Instances of the string "Perl" in everyday life. I remember seeing
an image of a European road sign pointing to "Perl". I think it
was German, but I can't find it.
* and lots of other stuff that might be out there.
Thanks, and enjoy (and contribute!)
[0] http://www.theperlreview.com/Found/
[1] http://www.foundmagazine.com/
[2] http://www.thislife.org
[3] mailto:found@theperlreview.com
--
brian d foy, comdog@panix.com
Subscribe to The Perl Review: http://www.theperlreview.com
------------------------------
Date: Tue, 18 Jan 2005 18:37:04 +1100
From: Iain Chalmers <bigiain@mightymedia.com.au>
Subject: Re: "Found Perl"
Message-Id: <bigiain-07093F.18370418012005@individual.net>
In article <170120052110468477%comdog@panix.com>,
brian d foy <comdog@panix.com> wrote:
> * Images of swag (keychains, water bottles, pens) that Perl
> vendors gave out.
I _think_ I've still got my Stonehenge branded mini swiss army knife
around somewhere... If I find it I'll send you a photo...
> * and lots of other stuff that might be out there.
How about the Perl fridge magnets? And one of those Perl Certifications
that you were handing out many years ago at The Perl Conference? A big
version of the map showing where Perl Mongers groups are?
big (I wonder if anyone saved any fragments of Jon Orwants coffee cup?)
--
"I say we take off and nuke the entire site from orbit.
That's the only way to be sure." - Ellen Ripley
------------------------------
Date: Tue, 18 Jan 2005 08:50:06 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: [newbie] chomp acting weird (or me not understanding how it works??)
Message-Id: <juhou0tv8vqiqn596qv84okk0vgn2bk8uc@4ax.com>
On Mon, 17 Jan 2005 16:53:03 +0100, Hendrik Maryns
<hendrik_maryns@despammed.com> wrote:
>> Please note that just as much as the similar code pasted in my
>> previous post, this is meant to be a minimal working example. Unless
>> you need only a quick hack in a realistic app you'd probably
>> explicitly write the loop and add bells and whistles...
>
>I think I will, as I don't think my professor will believe I wrote this
>myself...
So this was homework... while generally hackers and experienced users
spot it at a glance, I don't think it's so bad to post questions about
it, provided that you point out so in order to allow people to reply
taking it into account.
Also, this depends on your professor's point of view, but I see
nothing wrong a priori in asking for help say here. Just make sure you
understand all of the suggestions you've been given and use this
knowledge, and anything else you may learn in the meantime to cook up
your own solution.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Mon, 17 Jan 2005 22:52:32 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: [perl-python] 20050116 defining a function
Message-Id: <slrncup5gg.1gu.tadmc@magna.augustmail.com>
Ala Qumsieh <notvalid@email.com> wrote:
> Xah Lee wrote:
> *plonk*
Man, you are way behind the curve.
I did that over 3 years ago! [1]
[1] Message-ID: <7fe97cc4.0111080051.71a0c6f3@posting.google.com>
I followed the link in that post on a hunch, and found
he says himself that he is a troll. Go figure...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 18 Jan 2005 07:06:05 +0000
From: Dave Cross <dave@dave.org.uk>
Subject: Re: [perl-python] 20050116 defining a function
Message-Id: <pan.2005.01.18.07.06.05.23776@dave.org.uk>
On Mon, 17 Jan 2005 14:26:13 -0500, Chris Mattern wrote:
> Xah Lee wrote:
>
>> errata:
>>
>> * the variables in the perl section should be declared inside the
>> subroutine.
>> * the @_[0] should've been $_[0]
>>
>> thanks for Dave Cross for pointing them out.
>>
>> * the Mathematica Apply should be Select...
>
> Here's a thought: don't post code you haven't tested!
Testing wouldn't have helped. The code works as originally posted - it
doesn't doesn't work in quite the way expected.
Dave...
------------------------------
Date: Mon, 17 Jan 2005 22:53:14 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: [perl-python] 20050117, filter, map
Message-Id: <slrncup5hq.1gu.tadmc@magna.augustmail.com>
Erik Max Francis <max@alcyone.com> wrote:
> Steven Bethard wrote:
>
>> Is there any chance you could post these all as part of the same thread?
>> That would be really nice for those of us who aren't interested --
>> then we could just ignore the thread...
>
> Or, better yet, not posting it at all. He's got his mailing list, what
> does he need to post it here for?
There isn't much point in trolling if you don't have an audience.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 17 Jan 2005 21:49:20 -0800
From: "Xah Lee" <xah@xahlee.org>
Subject: [perl-python] 20050118 keyed list
Message-Id: <1106027360.920787.321590@z14g2000cwz.googlegroups.com>
=A9 # -*- coding: utf-8 -*-
=A9
=A9 # in Python, there's a special type of
=A9 # data structure called keyed list. it
=A9 # is a unordered list of pairs, each
=A9 # consists of a key and a value. It is
=A9 # also known as dictionary.
=A9
=A9 # define a keyed list
=A9 aa =3D {'john':3, 'mary':4, 'jane':5, 'vicky':7}
=A9 print aa
=A9
=A9 # getting value from a key
=A9 print 'mary is', aa['mary']
=A9
=A9 # delete an entry
=A9 del aa['vicky']
=A9 print aa
=A9
=A9 # get just the keys
=A9 print aa.keys()
=A9
=A9 # check if a key exists
=A9 print aa.has_key('mary')
=A9
=A9 # to learn more,
=A9 # type help() and DICTIONARIES
=A9 # or see
=A9 # http://python.org/doc/2.3.4/tut/node7.html
=A9
=A9 -------------------------------------------
=A9 # in perl, keyed-list is done like this:
=A9
=A9 %a =3D ('john',3, 'mary', 4, 'jane', 5, 'vicky',7);
=A9 use Data::Dumper qw(Dumper);
=A9 print Dumper \%a;
=A9
=A9 # the syntax of keyed list in Perl is too complex
=A9 # to be covered in a short message.
=A9 # see "perldoc perldata" for an unix-styled course.
=A9
=A9 Xah
=A9 xah@xahlee.org
=A9 http://xahlee.org/PageTwo_dir/more.html
------------------------------
Date: Mon, 17 Jan 2005 20:54:28 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: alternative to MS word doc
Message-Id: <o%ZGd.17189$W33.598152@news20.bellglobal.com>
"mike" <s99999999s2003@yahoo.com> wrote in message
news:dfd17ef4.0501171715.d5281e@posting.google.com...
> hi
>
> i wish to create a doc using perl and i am using the Win32:OLE module
> to do that. The thing is , i will need to have the MSword application
> installed. Is there
> any oher modules/ways i can create a text file from scratch and also
> has the ability to include some gifs/jpeg images?
>
That's a contradiction. Text files, by their very nature, are text files.
RTF files are usually a better option than proprietary MS Word files, if
only for portability. See www.cpan.org for modules.
Matt
------------------------------
Date: Tue, 18 Jan 2005 08:54:41 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: alternative to MS word doc
Message-Id: <b2gpu0lg8mqvei07nufdontm0mpt2ag25j@4ax.com>
On 17 Jan 2005 17:15:56 -0800, s99999999s2003@yahoo.com (mike) wrote:
>i wish to create a doc using perl and i am using the Win32:OLE module
>to do that. The thing is , i will need to have the MSword application
>installed. Is there
Nothing to do _a priori_ with Perl, but do a favour to yourself and
use LaTeX[1] (or if you really prefer plain TeX or ConTeXt).
[1] The goodness of this answer _may_ depend on what kind of document
you really need to write.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 17 Jan 2005 21:43:05 -0800
From: "Al the Pal" <alex_the_hart@yahoo.com>
Subject: Re: creating socket on specific IP address
Message-Id: <1106026985.085273.308110@c13g2000cwb.googlegroups.com>
I understand now. I always thought of bind as a server only command,
related somehow to listen. I never saw it used in a client, so I just
didn't think it would work for that. I guess it's obvious, now that you
tell me.
Thanks.
------------------------------
Date: Tue, 18 Jan 2005 08:50:10 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: creating socket on specific IP address
Message-Id: <fgfou0pn6e7cqdnbcuhubp2tug2ar1rbhq@4ax.com>
On 17 Jan 2005 10:44:01 -0800, "Al the Pal" <alex_the_hart@yahoo.com>
wrote:
>I'm sorry if this is a repost. I thought I posted this, but don't see
>it on the board, so I'll try again.
This is not a "board".
>Hi Geniuses,
This is not likely to increase your chances of getting a helpful
answer.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Tue, 18 Jan 2005 08:50:09 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: How to compare files?
Message-Id: <gbfou0lrmaudfco08dq8da9bmn4mli5th2@4ax.com>
On Mon, 17 Jan 2005 18:46:02 +0100, Case <no@no.no> wrote:
>What is a good (readable) way of comparing two
>files. I just need to know if they match, or not.
If with "if they match" you mean "if they are _exactly_ the same",
then I'd just take a cheksum (e.g. MD5) of both and compare them.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Tue, 18 Jan 2005 08:56:12 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: How to compare files?
Message-Id: <csifb1$60p$2@nntp.fujitsu-siemens.com>
Case wrote:
> What is a good (readable) way of comparing two
> files. I just need to know if they match, or not.
It depends upon the level of confidence you place upon the result.
You might be satisfied if the md5sums of both files are equal. In that=20
case have a look at Digest::MD5. If you must do this regularly, you can=20
save the md5sum in some file and retrieve it, saving some work the next=20
time.
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Tue, 18 Jan 2005 09:06:08 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: How to compare files?
Message-Id: <csiftj$bee$1@nntp.fujitsu-siemens.com>
Michele Dondi wrote:
> On Mon, 17 Jan 2005 18:46:02 +0100, Case <no@no.no> wrote:
>=20
>=20
>>What is a good (readable) way of comparing two
>>files. I just need to know if they match, or not.
>=20
>=20
> If with "if they match" you mean "if they are _exactly_ the same",
> then I'd just take a cheksum (e.g. MD5) of both and compare them.
Since an MD5 checksum is often shorter than the file it is taken of (it=20
would be pointless to use if it weren't), the statement "two files are=20
exactly the same iff the MD5 checksums are equal" is wrong. After all,=20
there are 2^1048576 different 1MB files (do we still use these small=20
files? B-{) but only 2^128 different MD5 checksums, so, on average,=20
2^1048448 1MB-files share the same MD5 checksum.
There is a high chance that two files are _exactly_ the same if both=20
files have some additional restrictions as to their contents, e.g. both=20
are valid JPEG files, but there still exist pathological situations=20
where the MD5 checksums are equal even if the files differ.
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Mon, 17 Jan 2005 21:09:14 -0500
From: Bob Walton <see_sig@invalid>
Subject: Re: how to skip to a certain loop with debugging option perl -d
Message-Id: <41ec704e$1_1@127.0.0.1>
Hendrik Maryns wrote:
> Hi,
>
> i've been reading perldebut and it already helped me solving that
> annoying warning that kept occurring, but not on the most efficient way:
> I had to skip through 61 executions of a loop before reaching it!
>
> So I was wondering: is there something like the c option that skips
> through /N/ iterations of a loop, before stopping at the breakpoint
> again (which is inside the loop, obviously). I didn't find anything
> like that described in perldebug, so this time I thought I'd dare asking
> (I started to read the guidelines indeed:-p)
>
> Cheers, H.
Well, the "b" (break) debugger command has an optional third
argument which is a condition that must be true for the break to
occur. So, for example:
for(0..50){
print "$_\n";
}
can be broken on the iteration when $_ is 10 with:
b 2 $_==10
c
For example:
D:\junk>type junk513.pl
for(0..50){
print "$_\n";
}
D:\junk>perl -d junk513.pl
Loading DB routines from perl5db.pl version 1.25
Editor support available.
Enter h or `h h' for help, or `perldoc perldebug' for more help.
main::(junk513.pl:1): for(0..50){
DB<1> b 2 $_==10
DB<2> c
0
1
2
3
4
5
6
7
8
9
main::(junk513.pl:2): print "$_\n";
DB<2> x $_
0 10
DB<3> q
D:\junk>
Does that help?
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
------------------------------
Date: Mon, 17 Jan 2005 20:59:55 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: HTTP Get with Proxy authentication
Message-Id: <v4_Gd.17310$W33.599922@news20.bellglobal.com>
"Adrian" <aprz43@yahoo.com.au> wrote in message
news:1106001756.336790.325530@f14g2000cwb.googlegroups.com...
> Hi Guys,
>
What about the women?
>
> I am a total Perl newbie and I need some help with a simple script.
>
If the script is so simple, why haven't you made any effort to write it
yourself?
>
> I need a script to download a file via HTTP. The tricky bit is that I
> am behind a proxy server which requires authentication and the website
> where the file resides also requires authentication.
>
That is tricky. Even if someone were to write an example for you, and don't
hold your breath, you give no information about how your supposed to
authenticate.
>
> Can you please post an example of a script that authenticates through a
> proxy and then authenticates against a remote website and downloads a
> file.
>
No, but if you run into a problem you can't solve through the docs or by
googling you're free to post here again for help.
Matt
------------------------------
Date: 17 Jan 2005 21:29:45 -0800
From: "Adrian" <aprz43@yahoo.com.au>
Subject: Re: HTTP Get with Proxy authentication
Message-Id: <1106026185.264915.270300@z14g2000cwz.googlegroups.com>
Matt Garrish wrote:
> "Adrian" <aprz43@yahoo.com.au> wrote in message
> news:1106001756.336790.325530@f14g2000cwb.googlegroups.com...
> > Hi Guys,
> >
>
> What about the women?
>
> >
> > I am a total Perl newbie and I need some help with a simple script.
> >
>
> If the script is so simple, why haven't you made any effort to write
it
> yourself?
>
> >
> > I need a script to download a file via HTTP. The tricky bit is that
I
> > am behind a proxy server which requires authentication and the
website
> > where the file resides also requires authentication.
> >
>
> That is tricky. Even if someone were to write an example for you, and
don't
> hold your breath, you give no information about how your supposed to
> authenticate.
>
> >
> > Can you please post an example of a script that authenticates
through a
> > proxy and then authenticates against a remote website and downloads
a
> > file.
> >
>
> No, but if you run into a problem you can't solve through the docs or
by
> googling you're free to post here again for help.
>
> Matt
Here is my solution.
Hopefully it helps the next person with a similar problem.
#! /usr/bin/perl -w
# client1.pl - a simple client
#----------------
use strict;
use Socket;
use FileHandle;
my $server = 'NAME OF PROXY GOES HERE';
my $portNumber = 8080;
my $proxyUserPassBase64 = 'BASE 64 ENNCODED ProxyUser:ProxyPassword
GOES HERE';
my $path = 'http://NAME OF EXTERNAL SITE GOES HERE:80/';
my $websiteUserPassBase64 = 'BASE 64 ENNCODED User:Password GOES
HERE';
# initialize host and port
my $host = shift || $server;
my $port = shift || $portNumber;
# get the port address
my $iaddr = inet_aton($host);
my $paddr = sockaddr_in($port, $iaddr);
# create the socket, connect to the port
socket(SOCKET, PF_INET, SOCK_STREAM, 0) or die "socket: $!";
connect(SOCKET, $paddr) or die "connect: $!";
autoflush SOCKET (1);
######### Send HTTP GET request
print SOCKET "GET $path HTTP/1.1\n";
print SOCKET "Host: $host\n";
print SOCKET "Connection: close\n";
print SOCKET "Authorization: Basic\n ";
print SOCKET "$websiteUserPassBase64\n";
print SOCKET "Proxy-Authorization: Basic\n ";
print SOCKET "$proxyUserPassBase64\n";
print SOCKET "Accept: text/html; */*\n";
print SOCKET "\n";
######### Receive HTTP response via SOCKET
my $data;
while ( <SOCKET> ) {
chomp;
$data .= "$_\n";
}
######### SOCKET (close); take down the session
close(SOCKET);
open OUTPUT, ">output.txt";
print OUTPUT $data;
close OUTPUT;
Cheers,
Adrian
------------------------------
Date: 17 Jan 2005 22:18:44 -0800
From: "Adrian" <aprz43@yahoo.com.au>
Subject: Re: HTTP Get with Proxy authentication
Message-Id: <1106029124.635163.315610@f14g2000cwb.googlegroups.com>
According to The American Heritage Dictionary of the English Language:
"guys: Informal. Persons of either sex."
------------------------------
Date: Tue, 18 Jan 2005 03:26:06 -0000
From: "Leonard Challis" <perl@lennychallis.co.uk>
Subject: Re: looking for constructive criticism on this script....
Message-Id: <cshvk7$9dm$1@newsg2.svr.pol.co.uk>
That was a great reply. Lots of clever tips heh.
It just shows how great Perl can be (when we code it right :P)
Just a thought,
Lenny
--
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrncuopde.2cr.tadmc@magna.augustmail.com...
> John Smith <jsmith@macroshaft.com> wrote:
>
>> #!/usr/bin/perl -w
>
>
> The modern (and more complete) way is:
>
> #!/usr/bin/perl
> use warnings;
> use strict;
>
>
> You should ask for all the help you can get.
>
>
>> if ($cdrom eq "\n")
>> {
>> $cdrom = '/dev/acd0';
>> }
>> else
>> {
>> chomp($cdrom);
>> }
>
>
> chomp $cdrom;
> $cdrom = '/dev/acd0' unless length $cdrom;
>
>
>> $config{CD_DEVICE}="$cdrom";
>
>
> perldoc -q vars
>
> What's wrong with always quoting "$vars"?
>
>
> so that should be:
>
> $config{CD_DEVICE} = $cdrom;
>
>
> (whitespace is not a scarce resource, feel free to use as much as
> you want to help make your code easier to read. Have you seen
> perlstyle.pod yet?
> )
>
>
>> my $whereArtist = index($cd{artist}, "&");
>> if ($whereArtist ne -1)
>
>
> You should use the string comparison operators on strings, and
> the numeric comparison operators on numbers, so that should be either
>
> if ($whereArtist != -1)
>
> or
>
> if ($whereArtist ne '-1')
>
>
>> {
>> substr($cd{artist}, $whereArtist, 1) = "and";
>> }
>
>
> But you can replace all of that code with just this:
>
> $cd{artist} =~ s/&/and/;
>
>
>> print "Artist: $cd{artist}\n";
>> print "Title: $cd{title}\n";
>> print "Category: $cd{cat}\n";
>> print "CDDD-ID: $cd{id}\n";
>> print "Tracks: $cd{tno}\n\n";
>
>
> Consider using a "here-doc" in place of a bazillion print statements.
>
>
>> print "\nShall I create \"$path\/$cd{artist}\/$cd{title}\" for you, y or
>> n?\n";
>
>
> Slashes are not special in a string, there is no need to backslash them.
>
> If you use an alternate form of quoting you can avoid backslashing
> the double quotes too:
>
> print qq(\nShall I create "$path/$cd{artist}/$cd{title}" for you, y or
> n?\n);
>
>
>> system "mkdir -p \"$path\"";
>
>
> No need to shell out to do that, use Perl's own builtin function:
>
> perldoc -f mkdir
>
>
>
>> if ($i == 1)
>
>
> Here you _do_ use the right type of comparison...
>
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Tue, 18 Jan 2005 08:50:08 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: MAP Question
Message-Id: <pthou0h1ql7c1g0vjldlg7qlhrn8v3e4k2@4ax.com>
On Mon, 17 Jan 2005 17:19:26 GMT, "George" <georgekinley@hotmail.com>
wrote:
>I needed to run regular exression(RE) for all the elements of an array
Yes...
>so I thought of using MAP(one liner) insted foreach.
Not such a thing as MAP...
>Following line
>@Rfolder=map {/#(.*?)(?=:)/,$_} @getlistF;
...as your correct use of map() shows.
>gave me all the existing elements plus what is extracted by RE
is this what you want? Is this _not_ what you want? What do you want?
>but
>following line
>@Rfolder=map {/#(.*?)(?=:)/} @getlistF;
>gave me just what RE returned,
Yes...
>Definetly it means that I do not understand MAP correctly,
Perhaps... are you missing a list context here?
Definitely you do _not_ understand that there's not such a thing as
MAP. And I can't really understand why you spell it so.
>can somebody please explain what is the difference between two
>statement , cause what I understood that $_ needs to be set before ,
>for RE to work.
What does make you suppose it's not set?
However I can't explain you the difference, but hopefully
perldoc -f map
can.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Mon, 17 Jan 2005 22:41:07 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Multi-dim hash slices
Message-Id: <slrncup4r3.1gu.tadmc@magna.augustmail.com>
Dinko Korunic <kreator@esa.fer.hr> wrote:
> Is it possible to use hash slices with multi-dimensional hashes
Yes.
> (and
> how)?
The way it says to in perlreftut.pod.
I like to apply "Use Rule 1" in 3 steps:
@slice_me{ 'foo', 'bar' } # pretend it is a plain hash
@{ }{ 'foo', 'bar' } # replace the name with a block ...
@{ $inner{baz} }{ 'foo', 'bar' } # ... that returns the
# proper kind of reference
> If yes, would hash slices be in any way faster
use Benchmark;
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 18 Jan 2005 07:03:43 +0100
From: Tore Aursand <toreau@gmail.com>
Subject: Re: Need help with Perl and MySQL database data load
Message-Id: <XE1Hd.4928$Sl3.116451@news4.e.nsc.no>
Oscar wrote:
> When I remove the line
> use DBI; I get the error message "Can't locate object method "connect"
> via packge "DBI" (perhaps you forgot to load "DBI"?) at sqltst2.pl line
> 12."
Of course; my fault. You need 'use DBI' of course. :)
> When I put that line, use DBI;, back in I then get an authentication
> procotol error message:
> "DBI connect
> ('database=sds_tst;host=localhost;port=3306,'root',....)failed: Client
> does not support authentication protocol requested by server;consider
> upgrading MYSQL client at sqltst2.pl line 13."
> I have the latest MySQL client installed.
Hmm. Have you upgraded from an older MySQL version that uses another
authentication protocol? Log in to the MySQL shell and try the following;
SET PASSWORD FOR 'username'@'host' = OLD_PASSWORD('password');
--
Tore Aursand <tore@aursand.no>
"To cease smoking is the easiset thing I ever did. I ought to know,
I've done it a thousand times." (Mark Twain)
------------------------------
Date: Tue, 18 Jan 2005 04:40:42 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Perl CGI script to emulate a shell command line window
Message-Id: <slrncup4qa.7m4.efflandt@typhoon.xnet.com>
On Mon, 17 Jan 2005 23:03:34 +0100, Alain Star <2005+newstest@foobox.com> wrote:
> You have a Windows machine with a Perl interpreter (ActivePerl from
> ActiveState for example).
> You have FTP access to a Linux box with a Perl CGI script engine (typically,
> the box where your website is hosted)
> But you are very frustrated because you do not have a TELNET or a SSH access
> to this box, it would be much more easy to zip or untar your files...
> The solution we suggest you is to create two scripts, a CGI wich will run on
> the server and a Perl script that will run locally in a command line
> window...
I wrote a webshell.cgi that I used on such a site. But the CGI ran suexec
as me with 700 permission, the password within the script was crypted
(yours is not, so anyone with read access to your script could discover
it), and it would only work if REMOTE_ADDR was my static IP.
The CGI generated and processed a form that could just run a single
non-interactive command line from any browser where it duped stderr to
stdout. I primarily used it to find binaries and Perl modules on the
system and help others troubleshoot their CGI.
At one point when it refused me and displayed REMOTE_ADDR that was not
mine, it made me aware of an internet router (NOT associated with my ISP)
that was proxying (and probably caching) even dynamic web traffic without
our knowledge or permission (for unknown purposes). We questioned their
motives and put a stop to it. It makes you wonder who may be snooping
your internet traffic without your knowledge.
------------------------------
Date: Tue, 18 Jan 2005 08:50:07 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Rearrange graphically a perl module: my poorman solution
Message-Id: <prhou094u1jnrspk2l4eq0rs00koc1phvc@4ax.com>
On 17 Jan 2005 08:46:05 -0800, s_p_a_m_mob@hotmail.com wrote:
>The aim is to rearrange graphically a perl module, to move down a
>method, move up some pod, etc.
>
>My solution is to add structure to the perl/pod code with html and use
>the navigator feature of OpenOffice to graphically move the blocks.
Ouch! Why not using a Real Editor(TM) instead? It is enough that it
supports folding...
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Tue, 18 Jan 2005 08:50:11 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Taint problem with ActiveState
Message-Id: <tkfou0llrpnd9hn3vf6m1a1ljrfk9g7sfe@4ax.com>
On 17 Jan 2005 21:23:50 GMT, "A. Sinan Unur"
<1usa@llenroc.ude.invalid> wrote:
>There is nothing preventing you from downloading
>
>http://search.cpan.org/~kwilliams/PathTools-3.02/
>
>and installing it in a private directory.
>
>If the fact that it is an XS module is a problem for you, a ppd for 5.6
>seems to be available from
>
>http://www.bribes.org/perl/ppmdir.html
In reply to which
On 17 Jan 2005 13:59:15 -0800, "bxb7668" <brian.bygland@boeing.com>
wrote:
>(Sorry for not including the context of previous posts. I don't know
>how to make Google do that)
>I could download and install Perl 5.8.6 if 1) I had administrator
>privilege and 2) I wanted to be fired. It is a terminatable offence to
>download without permission from the wild web. Besides which my scripts
>will be deployed to lots of PCs that would also need the upgrade. I
>don't control that.
Please note that this is now what has been suggested to you. See
above!
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 17 Jan 2005 21:31:54 -0800
From: sa_ravenone@yahoo.com
Subject: Re: validate XML file content
Message-Id: <1106026314.371095.280050@c13g2000cwb.googlegroups.com>
Hi,
Thanks for the reply, Peroli. And sorry for not making things clear.
>Peroli wrote:
>Since you are a starter with XML, XML::* modules are pure perl
I am not a starter in XML and not a starter in Perl either, but surely
a newbie in using modules for processing XML.
>foreach ($xmlDom->documentElement->findnodes('/root/image')) {
>if($_->findvalue('name') =~ /^IMG_/) {
>#dosomething
>}
>}
Thanks again for the clearly-understandable example, that almost
matched what I had in mind, but don't we have to repeat the same loop
for all the elements that need to be validated?
Is there a shorter way to do this, by associating each XML element with
its corresponding validation subroutine.
>Doing this thing in SAX would require a new strategy. I think if you
>are a newbie start with DOM, because its a lot easy to visualize the
>whole problem.
I need to check for IDs, IDREFs and IDREF content also. For that I need
to process IDs before I check IDREFs. Because the order is not
sequential will this work with SAX?
Thanks for all the clarifications.
Sara.
------------------------------
Date: Mon, 17 Jan 2005 22:43:16 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Where do you report perl bugs?
Message-Id: <slrncup4v4.1gu.tadmc@magna.augustmail.com>
Wes Groleau <groleau+news@freeshell.org> wrote:
> Subject: Where do you report perl bugs?
You are expected to check the Perl FAQ *before* posting
to the Perl newsgroup you know.
perldoc -q bug
Where do I send bug reports?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 7665
***************************************