[17219] in Perl-Users-Digest
Perl-Users Digest, Issue: 4641 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 17 11:05:36 2000
Date: Tue, 17 Oct 2000 08:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <971795113-v9-i4641@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 17 Oct 2000 Volume: 9 Number: 4641
Today's topics:
Re: "Lite" Perl book required <james@NOSPAM.demon.co.uk>
CPAN.pm gripe <nospam@david-steuber.com>
Re: Difference between '=' and '.=' operators (M.J.T. Guy)
Re: Difference between '=' and '.=' operators (M.J.T. Guy)
Re: Finding Perl Modules installed on server (M.J.T. Guy)
Re: IO::Socket falls over under Perl 5.6.0 (Anno Siegel)
Re: Make this regex neater, anyone? <jeffp@crusoe.net>
Re: MS Access <hartleh1@westat.com>
Net::Telnet working randomly (timed-out waiting for pas <roche@serianet.com.NOSPAM.invalid>
only one instance of program <phil_xxx@my-deja.com>
Re: only one instance of program (Randal L. Schwartz)
Re: Passing arguments <nospam@david-steuber.com>
Re: Passwd Help?? (Clay Irving)
Re: Perl to .exe Converter <Juergen.Lind@iteratec.de>
Problems accessing a mysql DB using DBI <mantunes@sonae.pt>
Re: Problems accessing a mysql DB using DBI <latsharj@my-deja.com>
Re: Problems accessing a mysql DB using DBI mack_2@my-deja.com
Re: Problems accessing a mysql DB using DBI <mantunes@sonae.pt>
Re: Problems accessing a mysql DB using DBI <ubl@schaffhausen.de>
Re: question mexicanmeatballs@my-deja.com
Re: Regular Expression problem <Juergen.Lind@iteratec.de>
rename not working <mdorrel@fsnet.co.uk>
Re: rename not working (Clay Irving)
Re: rename not working <dwilgaREMOVE@mtholyoke.edu>
Re: rename not working <mdorrel@fsnet.co.uk>
sendmail and "cc:" <jalford12@yahoo.co.uk>
Re: Sort <peckert@epicrealm.com>
space <default@att.com>
Re: split problem <mjcarman@home.com>
Re: system() & ENV{PATH} Problem <RichardWagner@gmx.net>
Re: Telling difference between a package and a class? <jeffp@crusoe.net>
value exchange of two vars <gustino2001@hotmail.com>
Re: value exchange of two vars (Bernard El-Hagin)
Re: value exchange of two vars <jeffp@crusoe.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 17 Oct 2000 12:38:38 +0100
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: "Lite" Perl book required
Message-Id: <ant1711387dffNdQ@oakseed.demon.co.uk>
In article <m1lmvoyybc.fsf@halfdome.holdit.com>, Randal L. Schwartz
<URL:mailto:merlyn@stonehenge.com> wrote:
> >>>>> "James" == James Taylor <james@NOSPAM.demon.co.uk> writes:
>
> James> I don't believe Randal was an author of "Programming Perl" 3rd Ed:
> James> http://www.oreilly.com/catalog/pperl3/
>
> I can acknowledge that it's accurate that you *believe* that. :-) And
> that's it's accurate that I'm not *listed* as an author. But I'll
> stop there.
Aha! I thought as much, that's why I used "I don't believe".
I had a suspicion that you must have had some input to the 3rd Ed,
not least of all because there must be a lot it has in common with
the 1st and 2nd editions. I read the 2nd Ed cover to cover but have
not had time to do the same with the 3rd Ed. From the occasional
reference foray into the 3rd Ed I can see that it is packed with
the same kind of humour and that I'm going to enjoy reading it.
I ought to say thanks to everyone involved in the O'Reilly Perl
books, they have brought me a great deal of joy.
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Tue, 17 Oct 2000 14:48:42 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: CPAN.pm gripe
Message-Id: <m3og0jed6f.fsf@solo.david-steuber.com>
This is just a rant. If you don't like rants, please skip to the next
thread.
I find cpan (which does "perl -MCPAN -e shell") to be an incredibly
useful tool for installing modules. It may be a bit dangerous to run
it as root, but that is what I do. I suppose I could chown the Perl
tree to a user and run cpan that way. Maybe that would be a better
and wiser thing to do.
Some modules do not work with CPAN.pm. One module that I wanted the
other day, PDL (complete with TriD and OpenGLQ), would not install
with CPAN. I was finally able to get it by fetching it the old
fashioned way with FTP. I then found that there was a Perl file I had
to edit to allow it to build. It did not use the ./configure, make,
make test, make install mantra.
I guess my gripe isn't with CPAN.pm, its with module authors who
deviate from the norm. I guess I really have no right to complain
about free and usefull software. After all, jumping through these
hoops encouraged me to get fftw (World's Fastest Fourier Transform)
installed. (Hey, I may write my own DSP software one day.)
cpan> install module
is a wonderful thing when it works. When it doesn't, I get this pain
right behind my eyes.
Don't get me started on the people who don't use autoconf and automake
for their software packages (like the POV-Ray people).
Thanks for letting me vent, if I haven't been kill filed by this.
--
David Steuber | Perl apprentice. The axe did not stop the
NRA Member | mops and buckets from flooding my home.
ICQ# 91465842
*** http://www.david-steuber.com/ ***
------------------------------
Date: 17 Oct 2000 12:08:57 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Difference between '=' and '.=' operators
Message-Id: <8shfgp$2ii$1@pegasus.csx.cam.ac.uk>
Jeff Pinyan <japhy@pobox.com> wrote:
>
> #!/usr/bin/perl -w
> $hash{this} .= "foo";
> $hash{that} = $hash{that} . "foo";
>
>That warns me about an undef value in line 3. The OP= operators give
>their operand a non-undef value if necessary. Perl used to NOT do this,
>which would be very irritating in cases like:
>
> for (@list) {
> $hash{$_} += split //; # over and over again!
> }
>
>That's why the value is created. A "quirk" of all the OP= operators.
Nope - only of selected ones ( += -= .= |= ^= ).
And of course it's part of the definition of &&= and ||= that they don't
warn.
Mike Guy
------------------------------
Date: 17 Oct 2000 12:12:21 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Difference between '=' and '.=' operators
Message-Id: <8shfn5$2mc$1@pegasus.csx.cam.ac.uk>
Sean McAfee <mcafee@waits.facilities.med.umich.edu> wrote:
>
>I was surprised to find that this code didn't behave as I expected; the
>exists $hash{$key} expression always evaluated to true, so that after the
>loop completed every hash value had a "\n" prepended. Somehow the .=
>operator causes $hash{$key} to spring into existence before the right-hand
>side is evaluated. This doesn't happen with the = operator, though:
>
>perl -le '$a{foo} = exists $a{foo} && "bar"; print $a{foo}'
>
>...prints nothing, as expected. Even this prints nothing:
>
>perl -le '$a{foo} = $a{foo} . (exists $a{foo} && "bar"); print $a{foo}'
>
>So does anyone know why .= is so different?
This illustrates that Perl does not define the order of evaluation of
expressions except in special cases. And it's quite normal to
evaluate the left hand side of an operator before its right hand side.
Mike Guy
------------------------------
Date: 17 Oct 2000 12:16:36 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Finding Perl Modules installed on server
Message-Id: <8shfv4$2rr$1@pegasus.csx.cam.ac.uk>
In article <8s640g$4ej$1@plonk.apk.net>, Jody Fedor <Jodyman@usa.net> wrote:
>Can anyone help?
>
> I don't have telnet access to my unix server. If I did, I could run
>the following:
>
> find `perl -e 'print "@INC"'` -name '*.pm' -print
>
>and receive a list of installed modules. How can I do it from within
>a perl script?
If you can run a Perl script, you can always run an arbitrary shell
script:
system q{find `perl -e 'print "@INC"'` -name '*.pm' -print};
But a more Perlish way would be File::Find.
Mike Guy
------------------------------
Date: 17 Oct 2000 14:11:14 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: IO::Socket falls over under Perl 5.6.0
Message-Id: <8shmm2$1h9$1@lublin.zrz.tu-berlin.de>
Richard Lawrence <ralawrence@my-deja.com> wrote in comp.lang.perl.misc:
>In article <slrn8ulk60.4tc.trammell@nitz.hep.umn.edu>,
> trammell@nitz.hep.umn.edu (John J. Trammell) wrote:
>> On Mon, 16 Oct 2000 16:54:14 GMT, Richard Lawrence
>> <ralawrence@my-deja.com> wrote:
>> >Consider this line:
>> >
>> > $socket = IO::Socket::INET->new( PeerAddr => $site,
>> > PeerPort => $port,
>> > Proto => "tcp",
>> > Type => SOCK_STREAM
>> > Timeout => 5 );
>> >
>> >under Perl 5 it worked fine.
>>
>> Wow, Perl knows how to insert missing commas? Who'da thunk it?
>
>Actually, although no-one is going to believe me, this code has been
>working fine (without the comma!) since the 23rd May 2000 and has had
>over 5000 executions.
>
>I've not touched it in the slightest until today to add the comma!!
>
>Am i going mad?
If SOCK_STREAM is a sub that is defined when the statement above
is parsed, it will consume "Timeout, 5" as arguments.
Anno
------------------------------
Date: Tue, 17 Oct 2000 08:00:16 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Make this regex neater, anyone?
Message-Id: <Pine.GSO.4.21.0010170754270.25707-100000@crusoe.crusoe.net>
[posted & mailed]
On Oct 17, Philip Lees said:
>Hi. I have strings of the form
>
>IDT1PAT1ADM12ECG5
>
>and I need to extract the _last_ group of letters - ECG in the above
>example. The regex also needs to handle the simplest case, i.e. IDT4
>gives IDT.
You can do:
($last) = $string =~ /(\D+)\d*$/;
or you can use a sexeger[1] instead of a regex:
$last = scalar reverse (reverse($string) =~ /(\D+)/);
[1] http://www.pobox.com/~japhy/sexeger/sexeger.html
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/
CPAN - #1 Perl Resource (my id: PINYAN) http://search.cpan.org/
------------------------------
Date: Tue, 17 Oct 2000 10:33:23 -0400
From: hartley_h <hartleh1@westat.com>
Subject: Re: MS Access
Message-Id: <39EC6332.4F2C187D@westat.com>
c_glensmith@my-deja.com wrote:
>
> I am stuck with Access because that is what the company uses and
> database already exists.
It is definitely worth your while to learn the limitations anyway. You
should also seriously consider letting your boss know what those
limitations are (in as much detail as possible and in writing) so that
when it hits the fan, you aren't killed in the crossfire (to mix
metaphors).
--
Henry Hartley
------------------------------
Date: Tue, 17 Oct 2000 13:35:40 +0200
From: Xavier ROCHE <roche@serianet.com.NOSPAM.invalid>
Subject: Net::Telnet working randomly (timed-out waiting for password prompt) ?
Message-Id: <39EC398C.BE94AA49@serianet.com.NOSPAM.invalid>
Hello,
I have a VERY weird problem when using a very simple Net::Telnet
example. When logging on the localhost, sometimes it's working, and
sometimes not.
It seems that I can not execute twice the same script immediately :
$ ./execcmd.cgi
Content-type: text/html
pattern match read eof at ./execcmd.cgi line 35
$ ./execcmd.cgi
Content-type: text/html
timed-out waiting for password prompt at ./execcmd.cgi line 31
The log displays (when it doesn't work):
< 0x00000: ff fd 25 ÿý%
> 0x00000: ff fc 25 ÿü%
< 0x00000: ff fd 18 ff fd 20 ff fd 23 ff fd 27 ÿý.ÿý
ÿý#ÿý'
> 0x00000: ff fc 18 ff fc 20 ff fc 23 ff fc 27 ÿü.ÿü ÿü#ÿü'
< 0x00000: ff fb 03 ff fd 01 ff fd 1f ff fb 05 ff fd 21
ÿû.ÿý.ÿý.ÿû.ÿý!
> 0x00000: ff fd 03 ff fc 01 ff fc 1f ff fe 05 ff fc 21 ÿý.ÿü.ÿü.ÿþ.ÿü!
< 0x00000: ff fb 01 44 65 62 69 61 6e 20 47 4e 55 2f 4c 69 ÿû.Debian
GNU/Li
< 0x00010: 6e 75 78 20 77 6f 6f 64 79 20 73 65 72 76 0d 0a nux woody
serv..
> 0x00000: ff fd 01 ÿý.
< 0x00000: 73 65 72 76 20 6c 6f 67 69 6e 3a 20 serv
login:
> 0x00000: 74 65 73 74 31 0d 0a test1..
< 0x00000: 74 65 73 74 31 0d 0a test1..
.. and nothing more!
The script itself is really basic: (I use the latest Net::Telnet module
and Perl 5.005_03 on 2.2.17)
#!/usr/bin/perl -w
use Net::Telnet ();
print "Content-type: text/html\r\n\r\n";
$user="test1";
$pass="foobar";
$cmd="/usr/bin/finger";
$t = new Net::Telnet (
Dump_Log => "/tmp/exec-debug-log-dump"
);
$t->open("localhost");
$t->login($user,$pass);
@lines = $t->cmd($cmd);
$t->cmd("exit");
$t->close;
Did someone have this problem too?
------------------------------
Date: Tue, 17 Oct 2000 10:53:12 GMT
From: Phil xxx <phil_xxx@my-deja.com>
Subject: only one instance of program
Message-Id: <8shb2m$aoj$1@nnrp1.deja.com>
How can I make sure on Solaris that only one version of my perl program
is ever running. Ie. if someone else starts the program whilst I am
running it, it should fail.
Phil.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 17 Oct 2000 04:48:53 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: only one instance of program
Message-Id: <m1vgury9ga.fsf@halfdome.holdit.com>
>>>>> "Phil" == Phil xxx <phil_xxx@my-deja.com> writes:
Phil> How can I make sure on Solaris that only one version of my perl program
Phil> is ever running. Ie. if someone else starts the program whilst I am
Phil> running it, it should fail.
Use a sentinel of some kind. I did that in
http://www.stonehenge.com/merlyn/WebTechniques/col54.html
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Tue, 17 Oct 2000 14:51:49 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: Passing arguments
Message-Id: <m3k8b7ed17.fsf@solo.david-steuber.com>
tjla@guvfybir.qlaqaf.bet (Gwyn Judd) writes:
' Well smack me with a kipper.
Gwyn, there's a kipper sticking out your sweater.
--
David Steuber | Perl apprentice. The axe did not stop the
NRA Member | mops and buckets from flooding my home.
ICQ# 91465842
*** http://www.david-steuber.com/ ***
------------------------------
Date: 17 Oct 2000 10:06:47 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: Passwd Help??
Message-Id: <slrn8uo95n.ig0.clay@panix6.panix.com>
On Tue, 17 Oct 2000 13:27:52 +0800, Fraser <r.fraser@student.murdoch.edu.au>
ponders:
>In Perl, how do you use system information such as "passwd" and
>"getpwnam" and print the info to the screen (stdout)?
Start with the documentation provided with the Perl distribution:
perldoc -f getpwnam
result:
[...]
In scalar context, you get the name, unless the
function was a lookup by name, in which case you
get the other thing, whatever it is. (If the
entry doesn't exist you get the undefined value.)
For example:
$uid = getpwnam($name);
[...]
Write a test program:
#!/usr/local/bin/perl5.6.0
$uid = getpwnam("clay");
print "$uid\n";
result:
619
--
Clay Irving <clay@panix.com>
I wrote a few children's books...not on purpose.
- Steven Wright
------------------------------
Date: Tue, 17 Oct 2000 16:21:25 +0200
From: =?iso-8859-1?Q?J=FCrgen?= Lind <Juergen.Lind@iteratec.de>
Subject: Re: Perl to .exe Converter
Message-Id: <39EC6065.25267863@iteratec.de>
Rainer Matzke wrote:
> http://www.perl2exe.com
Or try www.activestate.com
Their developer studio contains the PerlApp Program that does the job...
Its more expensive then pelr2exe as far as I can tell, though...
Regards
Jürgen
------------------------------
Date: Tue, 17 Oct 2000 12:25:19 +0100
From: "MAntunes" <mantunes@sonae.pt>
Subject: Problems accessing a mysql DB using DBI
Message-Id: <971781928.87944@cachalote.ip.pt>
Hi.
I'm a begginer in Perl programming.
At the moment, I'm trying to access a mysql database using the DBI api, and
I got an error:
install_driver(mysql) failed: Can't locate loadable object for module
DBD::mysql in @INC (@INC contains: /usr/lib/perl5/5.00503/i386-linux
/usr/lib/perl5/5.00503 /usr/lib/perl5/site_perl/5.005/i386-linux
/usr/lib/perl5/site_perl/5.005 .) at (eval 1) line 3
Perhaps a module that DBD::mysql requires hasn't been fully installed
at ./teste4.pl line 7
My program is simply:#!/usr/bin/perl -w
use DBI;
#$dbh = DBI->connect( "DBI:mysql:test" , 'root' , 'teste' );# or die "erro -
$DBI::errstr";
$driver = "mysql";
$dsn = "DBI:$driver:mysql";
$dbh = DBI->connect($dsn, 'root', 'test' );
I already looked for this on Perl documentation and I didn't find a thing
!...
The installation process runs OK and the database is up and running...
Can someone help me on this issue ?
Thanks in advance.
Mário
( mantunes@novis.pt )
------------------------------
Date: Tue, 17 Oct 2000 12:33:11 GMT
From: Dick Latshaw <latsharj@my-deja.com>
Subject: Re: Problems accessing a mysql DB using DBI
Message-Id: <8shgu7$f4e$1@nnrp1.deja.com>
In article <971781928.87944@cachalote.ip.pt>,
"MAntunes" <mantunes@sonae.pt> wrote:
> At the moment, I'm trying to access a mysql database using the DBI
> api, and
> I got an error:
>
> install_driver(mysql) failed: Can't locate loadable object for module
> DBD::mysql in @INC (@INC contains: /usr/lib/perl5/5.00503/i386-linux
> /usr/lib/perl5/5.00503 /usr/lib/perl5/site_perl/5.005/i386-linux
> /usr/lib/perl5/site_perl/5.005 .) at (eval 1) line 3
> Perhaps a module that DBD::mysql requires hasn't been fully installed
> at ./teste4.pl line 7
Try the following to check for available drivers:
use DBI;
my @drivers = DBI->available_drivers;
print join "\n",@drivers;
If mysql is not listed, then the driver is not properly installed.
--
Regards,
Dick
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 17 Oct 2000 13:07:49 GMT
From: mack_2@my-deja.com
Subject: Re: Problems accessing a mysql DB using DBI
Message-Id: <8shiv1$gk9$1@nnrp1.deja.com>
> Try the following to check for available drivers:
>
> use DBI;
> my @drivers = DBI->available_drivers;
> print join "\n",@drivers;
>
> If mysql is not listed, then the driver is not properly installed.
> --
> Regards,
> Dick
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
so my script crushes with the same error and it happens right after
use DBI;
so i can't check whether mySQL module is poperly installed.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 17 Oct 2000 15:00:10 +0100
From: "MAntunes" <mantunes@sonae.pt>
Subject: Re: Problems accessing a mysql DB using DBI
Message-Id: <971791220.162670@cachalote.ip.pt>
>
> If mysql is not listed, then the driver is not properly installed.
> --
> Regards,
> Dick
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
--------------------------------
Many thanks for the reply !
In fact, running your script, the MySQL is not listed. But I installed the
rpm's ( DBI, MySQL e MySQL-Dbi-perl ... ) and apparently, everything is OK.
Is there some workaround here ?!
Thanks in advance !
Mário
------------------------------
Date: Tue, 17 Oct 2000 16:26:34 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Problems accessing a mysql DB using DBI
Message-Id: <39EC619A.21F56F64@schaffhausen.de>
Dies ist eine mehrteilige Nachricht im MIME-Format.
--------------F04F9EE49B980AC5D7590A31
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
mack_2@my-deja.com schrieb:
>
> > Try the following to check for available drivers:
> >
> > use DBI;
> > my @drivers = DBI->available_drivers;
> > print join "\n",@drivers;
> >
> > If mysql is not listed, then the driver is not properly installed.
> > --
> > Regards,
> > Dick
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
>
> so my script crushes with the same error and it happens right after
> use DBI;
> so i can't check whether mySQL module is poperly installed.
I once had the same problem. You probably made a mistake when you
installed DBI. Just try again. It worked for me on the second try.
malte
--------------F04F9EE49B980AC5D7590A31
Content-Type: text/x-vcard; charset=us-ascii;
name="ubl.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Visitenkarte fŸr Malte Ubl
Content-Disposition: attachment;
filename="ubl.vcf"
begin:vcard
n:Ubl;Malte
tel;cell:+49 173 9237521
tel;fax:+49 4121 472938
tel;home:+49 4121 438297
tel;work:+49 4121 472964
x-mozilla-html:FALSE
url:http://www.schaffhausen.de
org:Schaffhausen | Interactive
adr:;;Daimlerstrasse 17;Elmshorn;;25337;Germany
version:2.1
email;internet:ubl@schaffhausen.de
title:Developer for web-based applications
x-mozilla-cpt:;1
fn:Malte Ubl
end:vcard
--------------F04F9EE49B980AC5D7590A31--
------------------------------
Date: Tue, 17 Oct 2000 14:05:49 GMT
From: mexicanmeatballs@my-deja.com
Subject: Re: question
Message-Id: <8shmbm$jmv$1@nnrp1.deja.com>
In article <m37l78p8an.fsf@mumonkan.sunstarsys.com>,
Joe Schaefer <joe+usenet@sunstarsys.com> wrote:
> "Andrew N. McGuire " <anmcguire@ce.mediaone.net> writes:
>
> > On Mon, 16 Oct 2000, Jim Mauldin quoth:
> > JM> Perl's strength arises not from shortcuts that are useful, valid
but
> > JM> sometimes obscure (e.g. $.), but from
> >
> > I just cant agree that $. is obscure. That is like saying $?
> > is obscure. Both are well documented in perlvar and other places,
> > they behave as documented, so how can that be obscure? As I posted
> > before, the docs even say:
> >
> > (Mnemonic: many programs use "." to mean the current line number.)
Which programs though?
> Although my intent was not to imply that $. is "obscure",
> it is certainly fair to read my statement that way, and
> post a civil disagreement about such a claim. You would
> find in fact that I would fall on your side of that argument,
> since "." it's part of the heritage of both perl and Unix.
> And there's lots of good examples of it's use throughout
> the docs, all I was saying that I wasn't familiar with
> it (until a few days ago :)
"$." is however harder to read than $INPUT_LINE_NUMBER, surely
everyone agrees with that? I don't believe that anyone thinks it's
generally good practice to name variables with punctuation.
The other option is to use FileHandle and lexically scope your
file handles, thus $. becomes $fh->input_line_number, and you
can immediately see what it is and which file handle it's
referring to.
Harder on the fingers though.
--
Jon
perl -e 'print map {chr(ord($_)-3)} split //, "MrqEdunhuClqdph1frp";'
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 17 Oct 2000 15:43:04 +0200
From: =?iso-8859-1?Q?J=FCrgen?= Lind <Juergen.Lind@iteratec.de>
Subject: Re: Regular Expression problem
Message-Id: <39EC5768.82D29F3C@iteratec.de>
--------------BF5011EE3E425232525E6D0F
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Hi again,
> overkill. eval string is slow and can be very dangerous. just store the
> before and after parts in a data structure with the regex part
> optionally in qr() form. then interpolate them into a normal =~ s///
> expression.
>
> $w = 'foo' ;
> @re{ qw( before after ) } = qw( foo oof ) ;
> ( $r = $w ) =~ s/$re{before}/$re{after}/ ;
>
> by making %re a hash of hash, you can handle multiple versions of that.
>
> reserve string eval for when you REALLY REALLY need it. which is rare in
Probably I oversimplfied the problem when I tried to explain it in the
newsgroup...
What I would really like to have would be something like the following...
$w = 'foo' ;
@re{ qw( before after ) } = qw( (w+) \U$1 ) ;
( $r = $w ) =~ s/$re{before}/$re{after}/ ;
print $r, "\n";
Ie. I want to make use of special chars such as \U etc. and match variables...
This seems to complicate things at lot...
Regards
Jürgen
--------------BF5011EE3E425232525E6D0F
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi again,
<blockquote TYPE=CITE>overkill. eval string is slow and can be very dangerous.
just store the
<br>before and after parts in a data structure with the regex part
<br>optionally in qr() form. then interpolate them into a normal =~ s///
<br>expression.
<p> $w = 'foo' ;
<br> @re{ qw( before after )
} = qw( foo oof ) ;
<br> ( $r = $w ) =~ s/$re{before}/$re{after}/
;
<p>by making %re a hash of hash, you can handle multiple versions of that.
<p>reserve string eval for when you REALLY REALLY need it. which is rare
in</blockquote>
Probably I oversimplfied the problem when I tried to explain it in the
newsgroup...
<br>What I would really like to have would be something like the following...<tt></tt>
<p><tt>$w = 'foo' ;</tt><tt></tt>
<p><tt>@re{ qw( before after ) } = qw( (w+) \U$1 ) ;</tt>
<br><tt>( $r = $w ) =~ s/$re{before}/$re{after}/ ;</tt><tt></tt>
<p><tt>print $r, "\n";</tt>
<p>Ie. I want to make use of special chars such as \U etc. and match variables...
<br>This seems to complicate things at lot...
<p>Regards
<p> Jürgen
<br> </html>
--------------BF5011EE3E425232525E6D0F--
------------------------------
Date: Tue, 17 Oct 2000 14:47:47 +0100
From: "Mike Dorrel" <mdorrel@fsnet.co.uk>
Subject: rename not working
Message-Id: <39ec5fa2.0@energise.enta.net>
Hi everyone,
I'm trying to get the following code to work:
#!/usr/bin/perl5
print "Content-type: text/html\n\n";
rename('/usr/local/text.txt', '/usr/text.txt');
I'm getting no response when I try to execute the above?
What am I doing wrong?
Thanks for any replies recieved.
Mike
------------------------------
Date: 17 Oct 2000 14:05:23 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: rename not working
Message-Id: <slrn8uon53.fha.clay@panix2.panix.com>
On Tue, 17 Oct 2000 14:47:47 +0100, Mike Dorrel <mdorrel@fsnet.co.uk> wrote:
>I'm trying to get the following code to work:
>
>#!/usr/bin/perl5
>
>print "Content-type: text/html\n\n";
>rename('/usr/local/text.txt', '/usr/text.txt');
>
>I'm getting no response when I try to execute the above?
>What am I doing wrong?
perldoc -f rename
result:
rename OLDNAME,NEWNAME
Changes the name of a file; an existing file
NEWNAME will be clobbered. Returns true for
success, false otherwise.
-> Behavior of this function varies wildly depending
-> on your system implementation. For example, it
-> will usually not work across file system
-> boundaries, even though the system mv command
-> sometimes compensates for this. Other
-> restrictions include whether it works on
-> directories, open files, or pre-existing files.
Check the perlport manpage and either the
rename(2) manpage or equivalent system
documentation for details.
Are /usr/local and /usr different filesystems?
--
Clay Irving <clay@panix.com>
When you're cool, the world is pouring mud up your nose.
------------------------------
Date: Tue, 17 Oct 2000 14:30:59 GMT
From: Dan Wilga <dwilgaREMOVE@mtholyoke.edu>
Subject: Re: rename not working
Message-Id: <dwilgaREMOVE-F6A31B.10311617102000@news.mtholyoke.edu>
In article <39ec5fa2.0@energise.enta.net>, "Mike Dorrel"
<mdorrel@fsnet.co.uk> wrote:
> Hi everyone,
>
> I'm trying to get the following code to work:
>
> #!/usr/bin/perl5
>
> print "Content-type: text/html\n\n";
> rename('/usr/local/text.txt', '/usr/text.txt');
>
> I'm getting no response when I try to execute the above?
> What am I doing wrong?
If you want a response, you need to check the result and the error code. It
may even be that this function isn't supported in your OS.
Not only that, you shouldn't use a text/html header unless the thing you're
trying to send to the browser really is HTML:
#!/usr/bin/perl5
print "Content-type: text/plain\n\n";
if( rename('/usr/local/text.txt', '/usr/text.txt') ) {
print "It worked!";
}
else {
print "It failed: $!";
}
Dan Wilga dwilgaREMOVE@mtholyoke.edu
** Remove the REMOVE in my address address to reply reply **
------------------------------
Date: Tue, 17 Oct 2000 15:46:07 +0100
From: "Mike Dorrel" <mdorrel@fsnet.co.uk>
Subject: Re: rename not working
Message-Id: <39ec6d4e.0@energise.enta.net>
The script is running on FreeBSD.
I've tried the following (after searching Deja):
#!/usr/bin/perl5
print "Content-type: text/html\n\n";
use CGI::Carp 'fatalsToBrowser';
$old= 'text.txt';
$new= 'text2.txt';
rename($old, $new) || die("Cannot rename $old to $new : $!\n");
and get the following response:
Content-type: text/html
Software error:
Cannot rename text.txt to text2.txt : Permission denied
I've tried to chmod the script and text.txt files, but the
script is still not working.
#!/usr/bin/perl5
print "Content-type: text/html\n\n";
use CGI::Carp 'fatalsToBrowser';
$old= 'text.txt';
$new= 'text2.txt';
rename($old, $new) or system("mv", $old, $new);
and get no response from the browser (clear screen)
Any ideas anyone? I'll be trying to move the file as renaming it,
later. Will this have any effect on the script?
Thanks
"Clay Irving" <clay@panix.com> wrote in message
news:slrn8uon53.fha.clay@panix2.panix.com...
> On Tue, 17 Oct 2000 14:47:47 +0100, Mike Dorrel <mdorrel@fsnet.co.uk>
wrote:
>
> >I'm trying to get the following code to work:
> >
> >#!/usr/bin/perl5
> >
> >print "Content-type: text/html\n\n";
> >rename('/usr/local/text.txt', '/usr/text.txt');
> >
> >I'm getting no response when I try to execute the above?
> >What am I doing wrong?
>
>
> perldoc -f rename
>
> result:
>
> rename OLDNAME,NEWNAME
> Changes the name of a file; an existing file
> NEWNAME will be clobbered. Returns true for
> success, false otherwise.
>
> -> Behavior of this function varies wildly depending
> -> on your system implementation. For example, it
> -> will usually not work across file system
> -> boundaries, even though the system mv command
> -> sometimes compensates for this. Other
> -> restrictions include whether it works on
> -> directories, open files, or pre-existing files.
> Check the perlport manpage and either the
> rename(2) manpage or equivalent system
> documentation for details.
>
> Are /usr/local and /usr different filesystems?
>
> --
> Clay Irving <clay@panix.com>
> When you're cool, the world is pouring mud up your nose.
------------------------------
Date: Tue, 17 Oct 2000 15:38:24 +0100
From: "JA" <jalford12@yahoo.co.uk>
Subject: sendmail and "cc:"
Message-Id: <6xZG5.26793$Kx.2051431@e420r-sjo1.usenetserver.com>
I'm trying to use a CC: address with sendmail (Unix of course) from Perl.
I'm piping the mail header and body to sendmail and I cannot find the
correct syntax and/or case for the cc: mail header label.
Does anyone out there in the Unix world know what this should be ?
Any help would be appreciated.
J.
------------------------------
Date: Tue, 17 Oct 2000 13:44:24 GMT
From: Paul Eckert <peckert@epicrealm.com>
Subject: Re: Sort
Message-Id: <39EC57B4.F6247499@epicrealm.com>
jtjohnston wrote:
> foreach $key (sort keys %DB){
> ($db_contact_name, $db_email, $db_title, $db_url, $db_desc,
> $db_keywords, $db_hits, $db_flag, $db_date, $db_time)
> = split (/\t/, $DB{$key});
>
> #...etc here I print html code
> }
Sort by default sorts asciibetically. Try this sort line:
foreach $key (sort {$a <=> $b} keys %DB){
--
Paul Eckert
Sr. Software Engineer
Epicrealm Inc.
1651 N. Glenville Dr., Suite 212
Richardson, TX 75081
(972) 479-0135 x300
peckert@epicrealm.com
------------------------------
Date: Tue, 17 Oct 2000 07:57:40 -0400
From: default <default@att.com>
Subject: space
Message-Id: <39EC3EB4.C097F7A7@att.com>
How much space will 5.6.0 take up on a unix box?
------------------------------
Date: Tue, 17 Oct 2000 08:46:11 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: split problem
Message-Id: <39EC5823.BB2DF0C6@home.com>
[Apologies to the ng for feeding the troll.]
"Godzilla!" wrote:
> Why would I need to justify code which performs
> with absolute perfection? [...] it performs flawlessly.
What does it do with this line?
234,tree,"Smith,John",6834
Or this one?
234,tree,"©Smith, John",6834
These are not "changed parameters," they are perfectly reasonable values
to have in the source file.
> > By that line of reasoning I could submit that this is
> > a perfectly acceptable solution:
>
> > my $line = '234,tree,"Smith, John",6834';
> > my @split_line = (
> > 234,
> > 'tree',
> > 'Smith, John',
> > 6834,
> > );
>
> This is a reasonable solution?
>
> * laughs *
My point precisely. Or did you miss the "By that line of reasoning..."
part?
> > You're making two large assumptions about the formatting of the input
> > data: that quoted commas are always followed by a space and that the
> > source data does not already contain the © character.
>
> I have made no assumptions and have dealt with parameters
> precisely as stated.
You made two obvious ones (which I have already pointed out) in
implementing a point solution for what was stated as being only an
example. Hence my facetious counter-example.
> You are a functional illiterate,
> and are quite clearly incapable, to a measured degree,
> of reading simple sentences without becoming confused
> about what you read, or tried to read.
[Silly troll-bait ignored]
> > Furthermore, the quotes are not part of the data, they're
> > part of the formatting. A proper split should remove
> > them as such.
>
> This is not stated in the parameters.
On the contrary, the OP states that his data comes from a CSV file. You
are, apparently, unaware of the implementation of this file format. It's
a pretty standard format, so using a module to parse it is a good idea.
-mjc
------------------------------
Date: Tue, 17 Oct 2000 14:00:53 +0200
From: Richard Wagner <RichardWagner@gmx.net>
Subject: Re: system() & ENV{PATH} Problem
Message-Id: <39EC3F75.DEDD9DBD@gmx.net>
Per Kistler wrote:
> Richard Wagner wrote:
>
> > Code:
> > $ENV{PATH}=".;E:/jdk1.3/bin"
> > print $ENV{PATH},"\n";
> > system("java - version");
>
> It would be good to test the same thing but with:
>
> system "java","-version";
Sorry, this does not change anything.
But
system ("java.bat")
where
java.bat:
java -version
works.
Funny isn't it?
Any ideas else?
Richard
>
>
> This avoids, that a shell will be called, which might read
> your profiles first.
>
> Per.
------------------------------
Date: Tue, 17 Oct 2000 07:54:20 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Telling difference between a package and a class?
Message-Id: <Pine.GSO.4.21.0010170752000.25707-100000@crusoe.crusoe.net>
[posted & mailed]
On Oct 17, trollis@my-deja.com said:
>In article <Pine.GSO.4.21.0010162249020.25707-100000@crusoe.crusoe.net>,
> japhy@pobox.com wrote:
>> [posted & mailed]
>>
>> sub is_class {
>> my $pkg = shift;
>> my $IS_CLASS = 0;
>> local $@;
>>
>> eval {
>> $IS_CLASS = 0;
>> my $obj = $pkg->new;
>> $IS_CLASS = UNIVERSAL::isa($obj,$packagename);
>> };
>>
>> return $@ ? 0 : $IS_CLASS;
>> }
>
>Ok, this is on the border of my Perl knowledge, but I understand what
>the above code does. So if I receive the files to test on the command
>line, I'll just add their paths to the perl module search path and test
>all modules as above? If I catch most of them, then it's fine with me.
Basically, first you need to require or use the module. Then you send the
name of the module (assuming it's also the name of the package) to the
is_class() function.
use CGI;
is_class('CGI');
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/
CPAN - #1 Perl Resource (my id: PINYAN) http://search.cpan.org/
------------------------------
Date: Tue, 17 Oct 2000 14:55:11 +0200
From: "Paul" <gustino2001@hotmail.com>
Subject: value exchange of two vars
Message-Id: <39ec4c86@alijku02.edvz.uni-linz.ac.at>
hi
i have heart that there is the possibility to exchange the values of
variables in one step.
please can anybody tell me how this works?!
many tnx in advance
paul
------------------------------
Date: 17 Oct 2000 13:07:09 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: value exchange of two vars
Message-Id: <slrn8uojpn.28m.bernard.el-hagin@gdndev25.lido-tech>
On Tue, 17 Oct 2000 14:55:11 +0200, Paul <gustino2001@hotmail.com> wrote:
>hi
>
>i have heart that there is the possibility to exchange the values of
>variables in one step.
>please can anybody tell me how this works?!
($a, $b) = ($b, $a);
Cheers,
Bernard
--
perl -le'
($B,$e,$r,$n,$a,$r,$d)=q=$B$e$r$n$a$r$d==~m;
\$(.);xg;print$B.$e.$r.$n.$a.$r.$d;'
------------------------------
Date: Tue, 17 Oct 2000 09:07:16 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: value exchange of two vars
Message-Id: <Pine.GSO.4.21.0010170906340.25707-100000@crusoe.crusoe.net>
[posted & mailed]
On Oct 17, Paul said:
>i have heart that there is the possibility to exchange the values of
>variables in one step.
>please can anybody tell me how this works?!
($a,$b) = ($b,$a);
Perl evaluates the values of the variables on the RHS (right-hand side) of
the expression, and then assigns them IN PARALLEL to the variables on the
LHS.
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/
CPAN - #1 Perl Resource (my id: PINYAN) http://search.cpan.org/
------------------------------
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 4641
**************************************