[15849] in Perl-Users-Digest
Perl-Users Digest, Issue: 3262 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 6 06:05:28 2000
Date: Tue, 6 Jun 2000 03:05:12 -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: <960285912-v9-i3262@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 6 Jun 2000 Volume: 9 Number: 3262
Today's topics:
Re: "system" and output flush <abe@ztreet.demon.nl>
[Off-topic] Lincoln Stein on Morning Edition! (brian d foy)
Re: BerkeleyDB Installation (Bart Lateur)
Re: Can't Write Binary File <grichards@flashcom.net>
Re: Can't Write Binary File <bill.kemp@wire2.com>
Re: DBA looking for PERL script to show last modified d <elaine@chaos.wustl.edu>
Re: global chown ?? (Villy Kruse)
good perl coding style eastking@my-deja.com
Re: good perl coding style (brian d foy)
Re: good perl coding style <bill.kemp@wire2.com>
Re: Help: OOPS Inheritance... (Bart Lateur)
Re: Help: OOPS Inheritance... (Damian Conway)
Re: hidden field problem and multi-page CGI.pm script <prlawrence@lehigh.edu>
Re: How do I make perl flush? <gellyfish@gellyfish.com>
Re: How to use single quote in Perl/CGI script? <debjit@oyeindia.com>
Inverse video? (Xebeche)
Re: module for MsAccess database? <blah@nospam.com>
Re: need help with passing parameters to a script <abe@ztreet.demon.nl>
Re: Newbie needs help with search and replace <godzilla@stomp.stomp.tokyo>
Re: Newbie needs help with search and replace <abe@ztreet.demon.nl>
Re: Newbie: counter sometimes resets (Yan Bilik)
OT: Making Apache insecure (was Re: capturing password <gellyfish@gellyfish.com>
Re: Parsing Email from Europe (Bart Lateur)
Re: Peculiar? Re-entrant Subroutines? (Anno Siegel)
Re: Perl gurus: help a C++ programmer optimize his ways <michael.schlueter@philips.com>
Re: Perl unusable as a programming language (Greg Bacon)
Re: Perl unusable as a programming language <epa98@doc.ic.ac.uk>
Re: Problems with MakeMaker om Win32 (ActiveState) <thomasgd@omc.bt.co.uk>
Re: Quick Network Ping scarey_man@my-deja.com
Read Email on Unix with Perl ???? cwang9@yahoo.com
Re: Read Email on Unix with Perl ???? <blah@nospam.com>
Re: strict doesnt like array references <michael.schlueter@philips.com>
Re: strict doesnt like array references (Bart Lateur)
Re: Stupid Question: scripts won't recognize opening li <kkrieger@erols.com>
Re: Stupid Question: scripts won't recognize opening li (Villy Kruse)
Re: use strict <michael.schlueter@philips.com>
Re: Using a package identifier inside a package <gellyfish@gellyfish.com>
Wag de Ref <scott@salmon.ltd.uk>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 06 Jun 2000 09:16:13 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: "system" and output flush
Message-Id: <d98ojs8sfor3hcmiub6hk66q45h529tb25@4ax.com>
On 5 Jun 2000 17:31:04 GMT, mjtg@cus.cam.ac.uk (M.J.T. Guy) wrote:
> Abe Timmerman <abe@ztreet.demon.nl> wrote:
> >On 3 Jun 2000 15:25:36 GMT, feng chen <fchen@fas.harvard.edu> wrote:
> >> I have a perl script which uses several "system" calls
> >> to run other perl script such as:
> >> system "perl p1.pl ......";
> > ^^^^^^^^^^
> >now why would you want to do that? Isn't one perl enough?
> >just put:
> > require 'p1.pl';
> >and if you want to pass (commandline) arguments to it (mind the
> >curlies):
> > {
> > local @ARGV = qw(arg1 arg2); #set arguments;
> > require 'p1.pl';
> > }
>
> Make that "require" a "do". Else you'll be surprised the second time
> you run it.
That's what I came up with later, but didn't have the time to post.
'do' is the way to go in these cases.
thank you pointing that out.
--
Good luck,
Abe
------------------------------
Date: Tue, 06 Jun 2000 00:26:25 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: [Off-topic] Lincoln Stein on Morning Edition!
Message-Id: <brian-ya02408000R0606000026250001@news.panix.com>
i was catching up on my news when i ran across a radio interview
with Lincoln Stein (author of CGI.pm, GD.pm, and all sorts of other
good Perl things) from last week:
http://www.npr.org/ramfiles/me/20000530.me.11.rmm
It's about the Human Genome Project, not Perl. oh well.
the complete rundown is at
http://search.npr.org/cf/cmn/cmnpd01fm.cfm?PrgDate=5%2F30%2F2000&PrgID=3
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Tue, 06 Jun 2000 07:32:33 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: BerkeleyDB Installation
Message-Id: <393fa428.2431584@news.skynet.be>
Larry Kasoff wrote:
>ppm
>ppm>install DB_File
>ppm>quit
>
>This will install the module for use with ActiveState perl. Please note
>that 'ppm>' is the prompt that ppm gives you after starting it.
Ah, you mean something like:
PPM install DB_File
You know what? I've created a little BAT file, with contents
PPM install %1
and I've associated the .PPM files with it. All I need to do is
doubleclick on the PPM file to install it.
I find it a bit strange that I needed to code this little thing myself.
--
Bart.
------------------------------
Date: Tue, 6 Jun 2000 00:12:12 -0700
From: "Gabe" <grichards@flashcom.net>
Subject: Re: Can't Write Binary File
Message-Id: <sjp8te262t5153@corp.supernews.com>
No dice, file still has zero bytes. Ack! Help! My code now stands as:
sub uploadimg {
fileparse_set_fstype('MSWin32');
my $file = $cgi->param('image');
my $picname = basename($cgi->param('image'));
no strict;
open (PIC, ">/home/cremeco/www/images/$picname") or die &error;
binmode $file;
binmode PIC;
while (read($file,my $buffer,1024)) {
print PIC $buffer;
}
close PIC;
print $cgi->redirect('http://www.cremeco.com/admin/addimage.html');
}
The code that works in another program is:
$picname = "$picname.jpg";
my $filename = $cgi->param('pic');
no strict;
open (PIC, ">>/home/cremeco/www/images/catalog/$picname") or die &error;
binmode $filename;
binmode PIC;
while (my $bytesread = read($filename,my $buffer,1024)) {
print PIC $buffer;
}
close PIC;
I can't figure out the difference!
Thanks,
Gabe
Larry Rosler <lr@hpl.hp.com> wrote in message
news:MPG.13a5ee0c510f880098ab26@nntp.hpl.hp.com...
> In article <sjodstqs2t5137@corp.supernews.com> on Mon, 5 Jun 2000
> 16:31:12 -0700, Gabe <grichards@flashcom.net> says...
> > The following results in a file name $picname being created but with
zero
> > bytes, i.e. no data is written to it. I can't figure it out. I've used
this
> > algorithm in other programs and it's worked...I think. Please help.
> >
> > #This code doesn't work;
> > use CGI;
> > use File::Basename;
> > fileparse_set_fstype('MSWin32');
> > my $file = $cgi->param('image');
> > my $picname = basename($cgi->param('image'));
> > no strict;
>
> Why???
>
> > open (PIC, ">/home/cremeco/www/images/$picname") or die &error;\
>
> binmode $file;
> binmode PIC;
>
> > while (my $bytesread = read($file,my $buffer,1024)) {
>
> But $bytesread isn't being used. Why assign to it?
>
> > print PIC $buffer;
> > }
> > close PIC;
> >
> > The next snippet, from a different program, writes to the same server,
but
> > this one works, what's the difference! They're virtually the same
program
> > right?
>
> There may be a difference in the input data. For example, a "\cZ" would
> be considered as EOF, because you didn't binmode the input file.
>
> Try it again, with the two binmode's.
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com
------------------------------
Date: Tue, 6 Jun 2000 09:22:15 +0100
From: "W Kemp" <bill.kemp@wire2.com>
Subject: Re: Can't Write Binary File
Message-Id: <960279838.669.0.nnrp-07.c3ad6973@news.demon.co.uk>
Gabe wrote in message ...
>No dice, file still has zero bytes. Ack! Help!
<SNIP>
zero bytes on a file upload- check the HTML page that send the data.
Is the form multipart enctype ?
<FORM enctype="multipart/form-data" ........... >
Done this one. puzzled me for ages
------------------------------
Date: Tue, 06 Jun 2000 04:11:18 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: DBA looking for PERL script to show last modified date with seconds
Message-Id: <B561F223.58D2%elaine@chaos.wustl.edu>
in article slrn8jor89.a5i.sjs@john.sympatico.ca, Steven Smolinski at
sjs@yorku.ca quoth:
> Is it really true that hackers write more readable code as they mature?
Mature? LOL...surely we are doomed to obfuscation for eternity :)
e.
------------------------------
Date: 6 Jun 2000 09:16:18 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: global chown ??
Message-Id: <slrn8jpg79.sij.vek@pharmnl.ohout.pharmapartners.nl>
On 5 Jun 2000 16:22:45 GMT, Abigail <abigail@arena-i.com> wrote:
>On Sun, 04 Jun 2000 15:15:23 +0200, frank <frank@french-connexion.com> wrote:
>++ I (linux newbie) am trying to write a script that chowns all the files
>++ and directories belonging to "sam" in the current directory to "joe" ?
>
>No use for Perl here:
>
> find . -user sam | xargs chown joe
>
>
This will fail if there are any file names containing "funny" characters
such as spaces or shell metacharacters. No real unix user would ever
dream of creating such files, but if the unix systems acts as a file
server for win9x systems, then these file names are becomming quite
common.
find . -user sam -exec chown joe {} \;
would be safer, although slower.
Villy
------------------------------
Date: Tue, 06 Jun 2000 04:24:23 GMT
From: eastking@my-deja.com
Subject: good perl coding style
Message-Id: <8hhudb$85k$1@nnrp1.deja.com>
I am leading a team to develop a CGI application by perl. Because
almost every member of this team is C programer,I need a coding
sytle/rule. Although perl doc have some suggestion, I'd rather to
listen more advise here. Thank in advance.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 06 Jun 2000 02:23:11 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: good perl coding style
Message-Id: <brian-ya02408000R0606000223110001@news.panix.com>
In article <8hhudb$85k$1@nnrp1.deja.com>, eastking@my-deja.com posted:
> I am leading a team to develop a CGI application by perl. Because
> almost every member of this team is C programer,I need a coding
> sytle/rule. Although perl doc have some suggestion, I'd rather to
> listen more advise here. Thank in advance.
this has been discussed to death in comp.infosystems.www.authoring.cgi:
http://www.deja.com/=dnc/getdoc.xp?AN=604082828
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Tue, 6 Jun 2000 09:15:19 +0100
From: "W Kemp" <bill.kemp@wire2.com>
Subject: Re: good perl coding style
Message-Id: <960279422.516.0.nnrp-07.c3ad6973@news.demon.co.uk>
brian d foy wrote in message ...
>In article <8hhudb$85k$1@nnrp1.deja.com>, eastking@my-deja.com posted:
>
>> I am leading a team to develop a CGI application by perl. Because
>> almost every member of this team is C programer,I need a coding
>> sytle/rule. Although perl doc have some suggestion, I'd rather to
>> listen more advise here. Thank in advance.
>
>this has been discussed to death in comp.infosystems.www.authoring.cgi:
>
> http://www.deja.com/=dnc/getdoc.xp?AN=604082828
>
I think I read that thread, but an extra question comes to mind.
A C++ programmer commented that 'perl is all the wrong way round'.
Meaning he doesn't like this type of syntax:-
"do something" if "test condition"
rather than
if (test condition){
"do something";
}
I suppose the second looks more like what a C programmer would expect.
My question is - where did the first style come from? (is it in other
languages). does it have any real advantages?
------------------------------
Date: Tue, 06 Jun 2000 07:32:37 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Help: OOPS Inheritance...
Message-Id: <394ba652.2984899@news.skynet.be>
Ala Qumsieh wrote:
> Else, there is something fishy going on!
Duh... have you seen the Denizen's reply? Forehead smacking time!
That's the trouble with Perl's handcrafted OOP. You can easily forget
one of the several steps necessary. Maybe a combined keyword, e.g.
"inherit", would be nice.
inherit HTML::Parser;
which would simply, similar in spirit to "use", combine
require HTML::Parser;
push @ISA, HTML::Parser;
Oh, one final tip to the original poster: don't use one global variable
to store the data for your object. As soon as you try to do more than
parsing job at the same time, you'll be in trouble. Make it an extra
field ("instance variable") in your object.
--
Bart.
------------------------------
Date: 6 Jun 2000 09:58:18 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: Help: OOPS Inheritance...
Message-Id: <8hihvq$iik$1@towncrier.cc.monash.edu.au>
bart.lateur@skynet.be (Bart Lateur) writes:
>That's the trouble with Perl's handcrafted OOP. You can easily forget
>one of the several steps necessary. Maybe a combined keyword, e.g.
>"inherit", would be nice.
> inherit HTML::Parser;
>which would simply, similar in spirit to "use", combine
> require HTML::Parser;
> push @ISA, HTML::Parser;
Err, have you tried:
use base 'HTML::Parser'
???
Damian
------------------------------
Date: Mon, 5 Jun 2000 23:52:07 -0400
From: "Phil R Lawrence" <prlawrence@lehigh.edu>
Subject: Re: hidden field problem and multi-page CGI.pm script
Message-Id: <8hhsgf$j6m@fidoii.CC.Lehigh.EDU>
"David Efflandt" <efflandt@xnet.com> wrote:
> On Mon, 5 Jun 2000, Phil R Lawrence <prlawrence@lehigh.edu> wrote:
> >
> >I have succesfuly made a script that has a logon screen, and then uses
the
> >user and password params to set up and display the second screen. I
can't
> >go on to the third screen, though, because the user and pass aren't being
> >passed in again. So, I thought I'd use
> > $query->save(\*FILE)
> >and
> > $query = CGI->new(\*FILE)
>
> And how to you get rid of all those old files?
Heh. Didn't think that far ahead yet. :-) Guess I'll build an unlinker
into the script that will kill any of the files older than 90 seconds or
so... Maybe some flocking too.
> >open FILE, '>' . $query->param('.file') or die "Couldn't open " .
> >$query->param('.file');
>
> param('.file') is not only a hidden variable, but the dot prefix hides it
> from CGI.pm (like a hidden Unix filename) as well. Try giving it a name
> without a dot prefix. Not sure if this is in the docs, by I did notice if
> I use undef for a field name (like a submit button) it ends up with a
> generic name with a dot in front of it, but does not show up in params.
Interesting thought. I'll check it out tomorrow.
Thanks for your help,
Phil R Lawrence
------------------------------
Date: 5 Jun 2000 20:09:33 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How do I make perl flush?
Message-Id: <8hgttd$pn$1@orpheus.gellyfish.com>
On Thu, 01 Jun 2000 23:22:15 GMT Fearless wrote:
> I'd never
> heard of ARGVOUT until now.
>
For future reference ARGVOUT is discussed in the perlrun manpage.
/J\
--
Kill my boss? Do I dare live out the american dream?
--
fortune oscar homer
------------------------------
Date: Tue, 6 Jun 2000 11:41:11 +0530
From: "Debjit" <debjit@oyeindia.com>
Subject: Re: How to use single quote in Perl/CGI script?
Message-Id: <8hj9nm$3a4$1@news.vsnl.net.in>
#!/usr/bin/perl -w
print qq`content-type: text/html
I am trying to print a paragraph which contains a few single quotes
(not single quoted string) in Perl/CGI script. For example, student's,
user's, etc. I used student\'s, user\'s, but it does not seem to work
in the HTML response page.
`;
But this is working perfect :)
output in browser follows
I am trying to print a paragraph which contains a few single quotes (not
single quoted string) in Perl/CGI script. For example, student's, user's,
etc. I used student's, user's, but it does not seem to work in the HTML
response page.
------------------------------
Date: Mon, 05 Jun 2000 19:39:49 GMT
From: dont@want.spam.com (Xebeche)
Subject: Inverse video?
Message-Id: <8hgvp2$t63$1@news.luth.se>
Perhaps this is a dumb question, but I'm a newbie so I don't know any better:
how (if possible) do you write to STDOUT in reverse video? I need to highlight
some info in my listings...
Thanks for any input.
/X.
------------------------------
Date: Tue, 06 Jun 2000 10:31:38 +0200
From: Marco Natoni <blah@nospam.com>
Subject: Re: module for MsAccess database?
Message-Id: <393CB6EA.4FD96167@nospam.com>
Soetji,
Soetjianto wrote:
> Is there a PERL module for interfacing with MsAccess databases?
Win32::ODBC.
Best regards,
Marco
PS Of course, you have to register an ODBC DSN for the database.
------------------------------
Date: Tue, 06 Jun 2000 10:39:26 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: need help with passing parameters to a script
Message-Id: <4fdpjsgiv02065fno5aodujba3ngki9lvs@4ax.com>
On 5 Jun 2000 16:48:39 GMT, "D.W." <dpalmeNOSPAM@unitedtraffic.com>
wrote:
...
> however if I have a script that is being passed a parameter such as:
> http://www.myserver.com/cgi-bin/foo.pl?message
>
> How do I pick up the value of message using the CGI module?
my @message = param('keywords');
perldoc CGI
search for <ISINDEX>
--
Good luck,
Abe
------------------------------
Date: Mon, 05 Jun 2000 21:19:06 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Newbie needs help with search and replace
Message-Id: <393C7BBA.759140F@stomp.stomp.tokyo>
Rodney Engdahl wrote:
>"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
> > Neil Watson wrote:
(snipped here and there)
> > > I have a file that has lines similar to
> > > (each line is spaced the same):
> > > PSteel8804 A 10000000000000000A0
> > (snipped)
> > > P128814S A 10000000000000000A0
(challenge is to replace 0A0 with 0S0)
> > $element = substr ($element, 0, 35);
> > $element = join ("", $element, "0S0");
> if using substr anyway, could use:
> # tested under perl 5.00503 only . . .
> substr($element, length($element)-3, 3, '0S0');
Your code works perfect under Perl 5.003
as well. No problems at all during testing.
Godzilla!
------------------------------
Date: Tue, 06 Jun 2000 10:16:27 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Newbie needs help with search and replace
Message-Id: <0bcpjssm80378g0h5kbtsc52njjlsn09sl@4ax.com>
On Mon, 05 Jun 2000 15:43:32 GMT, neilwSPAMTHIS@idirect.com (Neil
Watson) wrote:
> I have a file that has lines similar to (each line is spaced the
> same):
>
> PSteel8804 A 10000000000000000A0
> PSteel8805 A 10000000000000000A0
> PSteel8812 A 10000000000000000A0
> PSteel8814S A 10000000000000000A0
> PSteel18814S A 10000000000000000A0
> Pl8812 A 10000000000000000A0
> Pl8814S A 10000000000000000A0
> P128814S A 10000000000000000A0
>
> I want to replace the 0A0 at the end of the line with 0S0 on any line
> that begins with PSteel.
>
> I wrote this script:
>
> perl -p -i rp AINVPIR
Assuming AINVPIR is the file that holds the above data, and you want the
original saved with the extension '.bak' added:
(on Win32)
perl -pi.bak -e "s/0A0$/0S0/ if /^PSteel/;" AINVPIR
Between the quotes is the Perl translation of your specs.
--
Good luck,
Abe
------------------------------
Date: Tue, 06 Jun 2000 09:47:49 GMT
From: fromng@pourpre.com (Yan Bilik)
Subject: Re: Newbie: counter sometimes resets
Message-Id: <393cc8a3.91440953@news.free.fr>
Thanks !
On Mon, 05 Jun 2000 15:47:16 GMT, bart.lateur@skynet.be (Bart Lateur)
wrote:
>You delete the contents of the file before locking it. Besides, the
>"28000 to 29000" is coincidence. It's a matter of simultanious accesses
>with a bad file lock.
>
>You can open the file in mode "+<", do the lock, read the file,
>increment the counter, seek back to the start of the file, write the new
>value (which has equal or larger length as the original value, so
>there's no need to truncate the file), and close the file which also
>unlocks it. So you open the file only once.
>
>--
> Bart.
----------------------------------------------
c h r o m a http://pourpre.com/chroma
16 millions de couleurs, oui mais lesquelles ?
----------------------------------------------
chroma@pourpre.com
------------------------------
Date: 5 Jun 2000 19:58:51 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: OT: Making Apache insecure (was Re: capturing password via Basic Auth)
Message-Id: <8hgt9b$ud7$1@orpheus.gellyfish.com>
In comp.lang.perl.misc Alan J. Flavell <flavell@mail.cern.ch> wrote:
> look for the build option
> SECURITY_HOLE_PASS_AUTHORIZATION (I think the name was chosen to
> discourage from using it, which is probably a wise move!).
>
My favourite is BIG_SECURITY_HOLE (not a preference through use you
understand - I just like the name.)
/J\
--
Most women are so artificial that they have no sense of Art. Most men
are so natural that they have no sense of Beauty.
--
fortune oscar homer
------------------------------
Date: Tue, 06 Jun 2000 08:17:33 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Parsing Email from Europe
Message-Id: <393dafa9.5376388@news.skynet.be>
Jimmy Lantz wrote:
>I'm working on a G4 MAc with MacPerl. (if someone has anyideas how to
>get a pora link or a tip.table module for charconvertions, for Mac
>please be my guest and post a link or a tip)
Then indeed you DO need to encode those accented chars. You may skip
encoding if the charset is ISO-Latin-1, which isn't the case on a Mac.
As for encoding... First, get the the conversion table for Mac on
ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/APPLE/ROMAN.TXT
It's a (textual) conversion table from Macintosh to Unicode, and the
lower 256 characters of Unicode are identical to the characters of
ISO-Latin-1 (i.e. same character code for same character). Besides, all
browsers are supposed to recognize entities like "€" as Unicode
characters numbers (in this case: Euro sign).
You can load the data into a hash simply like this:
open TABLE, "ROMAN.TXT"
or die "Cannot open conversion table file: $!";
while(<TABLE>) {
next unless /^\s*(0x\w+)\s+(0x\w+)/i;
$unicode{chr hex $1} = hex $2;
}
This will load the Mac character for hash key, and the Unicode character
number for value.
A simple HTML encoding scheme can thus be:
s/([\200-\377])/&#$unicode{$1};/g
but which doesn't deal with [&<>]. You also may want to combine this
with the named entity encoding for better readability.
--
Bart.
------------------------------
Date: 6 Jun 2000 08:53:58 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Peculiar? Re-entrant Subroutines?
Message-Id: <8hie76$dp0$1@lublin.zrz.tu-berlin.de>
Bart Lateur <bart.lateur@skynet.be> wrote in comp.lang.perl.misc:
>Paris wrote:
>>if ($search_in =~ /$search_for/oi){$slice_ok = 1}else{last}
>
>Note the //o modifier...
[...]
>The solution? Call the search function only wit hone pattern in your
>entire script. Hmmm... alright then, remove the //o modifier. But it
>will slow down quite a bit. Hmmm...
>
>There is no neat solution.
Oh, but there is. Use the qr/// operator to translate a new regex
from a run-time string each time one is needed. Most of the
translation effort happens when $pat = qr/// is executed; a subsequent
m/$pat/ doesn't cost (much) more than a fixed m/string/.
Since the introduction of qr to Perl the /o modifier is not really
needed any more, except as a shortcut when you really have only a
single pattern per regex and program run.
Anno
------------------------------
Date: Tue, 6 Jun 2000 21:41:42 +0200
From: "Michael Schlueter" <michael.schlueter@philips.com>
Subject: Re: Perl gurus: help a C++ programmer optimize his ways
Message-Id: <8hia0e$4mr$1@porthos.nl.uu.net>
Hi Greg,
Some reply to your reply.
* The right way to do it with use strict; is:
!#/usr/local/bin/perl -w
use strict;
my $global_var; # global in this namespace = this package-file
...
sub something {
...
my $a = $global_var; # as an example
}
* There are several ways to pass many variables. E.g. you could store their
references in a list or in a hash and pass that by reference, like:
my ($var, @list);
my @refs(\$var, \@list); # put their memory references
call_some_func(\@refs);
...
sub call_some_func {
my ($rl)=@_; # first element is the reference to a list
$$rl[0]++; # $($rl)[0] is \$var; so you actually manipulate $var
above
reverse $$rl[1]; # do a reverse sort on @list
}
With lists this looks quite ugly. It appears better with hashes, like
$$refs{_var}++. But still somewhat ugly. - Why do you really need so many
different global variables?
* The best access to CPAN I know so far is http://search.cpan.org . This
site offers some pre-classification, which I like more than the original
huge modulelist. You also have a nice search facility.
* I've seen that on CPAN there are a lot of HTML::... modules. Perhaps there
are already some problems solved for you.
* Quite recently there was a question from eastking@my-deja.com (6/6 6:24)
in this newsgroup. I think on http://wdvl.com/Authoring/Languages/Perl/ you
can find some style-guides for perl.
* From some earlier news I noticed that perhaps Uri Gut(s)mann may be worth
an email on your problem. You can find his email adress via CPAN's
who-is-who section. Or search for File::Backwards (his contribution).
* OOP in Perl is difficult to learn because it is implemented so simple
compared to other languages (at least I had this problem). There are several
ways to do it. Please refer to Demain Conways "Object Oriented Perl" (later
;-) .
* On CPAN you will find several approaches from the class:: modules. May I
draw your attention to my own script class::Classgen::Classgen-3.01 ? It
allows you to create a separate, editable package file, which is an object
with any amount and type of internal variables as you need. Accessor- and
manipulator-functions are created in parallel. So you can fully focus on
adding specific methods or inheritances. To further improve this script I'd
be interested in your feedback. Because you know OOP I'd like to know if
this approach makes your start with Perl-objects easier.
with_kind("perlish regards ") unless mesage_lost();
# Michael Schlueter ;-)
------------------------------
Date: Mon, 05 Jun 2000 13:32:15 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Perl unusable as a programming language
Message-Id: <sjnauv2p5ri48@corp.supernews.com>
In article <xn9snuvsnkg.fsf@pinga.doc.ic.ac.uk>,
Edward Avis <epa98@doc.ic.ac.uk> wrote:
: gbacon@HiWAAY.net (Greg Bacon) writes:
:
: >If a programmer is
: >tinkering with some code and comes up with something cool and unusual,
: >i.e., outside that implicit box of his experience, his first thought
: >should be, 'Cool! I wonder whether that's documented.' C, for example,
: >isn't all that different; consider Duff's Device. The advantage of
: >Perl, however, is that you can communicate directly with the language's
: >developers and users through many different channels and reasonably
: >expect to receive a good response.
:
: But do you really want to put up with hordes of beginning Perl
: programmers asking 'what should this do?' on clpm for the next twenty
: years? :-)
No, but you've proposed a false dilemma.
Greg
------------------------------
Date: 03 Jun 2000 16:43:52 +0100
From: Edward Avis <epa98@doc.ic.ac.uk>
Subject: Re: Perl unusable as a programming language
Message-Id: <xn9ya4m7osn.fsf@pinga.doc.ic.ac.uk>
Russell Bornschlegel <kaleja@estarcion.com> writes:
>Does Perl have DWIMmery that depends on
>particular literal-constant integers?
I don't know, I haven't seen any mention of such things, but then
there are other DWIM features that aren't clearly mentioned either.
There is the wacky 'zero but true' value.
--
Ed Avis
epa98@doc.ic.ac.uk
------------------------------
Date: Tue, 06 Jun 2000 09:34:18 +0100
From: Greg Thomas <thomasgd@omc.bt.co.uk>
Subject: Re: Problems with MakeMaker om Win32 (ActiveState)
Message-Id: <iqdpjs48csqoea671776v68k9la1g34ff4@4ax.com>
On Mon, 05 Jun 2000 02:34:30 GMT, an400@freenet.carleton.ca (Steve A.
Taylor) wrote in article <393b0fe6.11859058@news.ncf.carleton.ca>:
>I traced that to ExtUtils\MM_Win32.pm
>It's a portability issue of system versus backtick. I changed line 163
>
># $val = `$abs -e "require $ver;" 2>&1`; #old
> $val = system('$abs -e "require $ver;" 2>&1'); # new
Thanks for the pointers; I'll try that.
>Now a later error arises.
Oh good. Something else to look forward to!
Thanks for your help,
Greg
--
This post represents the views of the author and does
not necessarily accurately represent the views of BT.
------------------------------
Date: Tue, 06 Jun 2000 09:02:24 GMT
From: scarey_man@my-deja.com
Subject: Re: Quick Network Ping
Message-Id: <8hiemq$jkk$1@nnrp1.deja.com>
Thanks to all who replied and all your comments.
I am using Net::Ping which satisfies my needs.
I should have mentioned exactly what I was doing to remove any
confusion.
I am checking the status of print servers which are sometimes switched
off. When switched off, the ping would normally take a while to
timeout.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 06 Jun 2000 08:42:25 GMT
From: cwang9@yahoo.com
Subject: Read Email on Unix with Perl ????
Message-Id: <8hidhf$it8$1@nnrp1.deja.com>
Hello:
I searched over 4 hr for this topic but only got
some help on send email on Unix(Sendmail) with perl.
Anyone have a sample code to READ email(with Sendmail)
using Perl? Basiclly I need to monitor my mail box
on Solaris for certain subject.
JavaMail API could do that for sure, but how about using Perl???
Regards,
Jack Wang
Tampa, FL
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 06 Jun 2000 10:54:02 +0200
From: Marco Natoni <blah@nospam.com>
Subject: Re: Read Email on Unix with Perl ????
Message-Id: <393CBC2A.103A66A8@nospam.com>
Jack,
cwang9@yahoo.com wrote:
> I searched over 4 hr for this topic but only got some help on
> send email on Unix(Sendmail) with perl. Anyone have a sample code
> to READ email(with Sendmail) using Perl?
sendmail is a mail router that can be used to send mail messages, with
it is almost impossible to read them.
> Basiclly I need to monitor my mail box on Solaris for certain
> subject. JavaMail API could do that for sure, but how about
> using Perl???
There are some modules that allow you to access your (remote|local)
mailbox. For network-based cases you can obtain benefits using
Net::POP3.pm, for example.
Best regards,
Marco
------------------------------
Date: Tue, 6 Jun 2000 21:48:25 +0200
From: "Michael Schlueter" <michael.schlueter@philips.com>
Subject: Re: strict doesnt like array references
Message-Id: <8hiad0$4tp$1@porthos.nl.uu.net>
Better use:
#!/usr/bin/perl -w
use strict;
my @array = qw( this is a test );
my $rl= \@array; # \ means taking the memory address of @array,
# hence a reference
print @array;
print @$rl; # to print the array
print $$rl[2]; # to print the 3. element
@$rl is the same as @($rl). $rl is the memory address of @array, so this
evaluates to the correct listinterpretation. - $$rl[2] is the same as
$($rl)[2] which has the same effect as $array[2].
Run your script with the perl debugger perl -d your_script . Use n
<return> to step over the next line of code; x @array to output this
variable; h for a lenghty help menue. See the difference with the other
porposals.
------------------------------
Date: Tue, 06 Jun 2000 07:58:31 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: strict doesnt like array references
Message-Id: <393cad61.4792371@news.skynet.be>
MC wrote:
>given the code below, which works perfectly w/o the use strict, but crashes with
>the error:
>
>Can't use string ("array") as an ARRAY ref while "strict refs" in use at test.pl
>line 10.
>
>use strict;
>
>my @array = qw( this is a test );
>my $test = "array";
>
>print @array;
>print @{$test};
Of course it complains. You're using symbolic references, i.e.
addressing a variable by name (as string).
You can do:
my @array = qw( this is a test );
my $test = \@array;
print @array;
print @$test;
>in the actual script, i have two arrays which i need to
>select between arbitrarily based on another variable. is there some way i can do
>this and still keep strict? other than using an if/then/else structure?
You can make an array or a hash of array references. For example:
@anarray = qw(this is the first array);
@anotherarray = qw(this is the second array);
@ref = (\@anarray, \@anotherarray);
for my $i (0, 1) {
local($\, $,) = ("\n", " ");
print @{$ref[$i]};
}
Now, as you may recall, boolean tests return 0 for false and 1 for true.
So it's safe to use
print @{$ref[$myvar ne 'one']};
which will use the first array (index 0) is $myvar is 'one', and the
second array otherwise.
--
Bart.
------------------------------
Date: Tue, 06 Jun 2000 00:25:51 -0400
From: Kurt Krieger <kkrieger@erols.com>
Subject: Re: Stupid Question: scripts won't recognize opening line
Message-Id: <393C7D4D.20056D75@erols.com>
I've had a problem with perl scripts that were uploaded (ftp'd) to the
server in binary mode, leaving the ^M character at the end of each line.
This trashes the shebang line so that the shell can't determine what file
to execute. This would explain why your script works fine when you
explicitly tell the shell what file to execute using "perl test.pl".
In your case, if the file was actually called test.pl, and the error
message actually said something like "can't find test.pl", then open the
file in vi and see if ^M is at the end of all the lines. If so, either
re-upload the file in ascii mode, or issue these commands:
% dos2unix test.pl newfile.pl
% mv newfile.pl test.pl
This strips off the ^M chars and spools the results to newfile.pl. Then
rename it back to your original file name.
Kurt
Charles Petersen wrote:
> Ok, there is probably a very simple solution to this, but I can't seem
> to solve it.
>
> I'm running perl on Redhat 6..2. I have one script that works just
> fine, it's debugged and I start it by simply typing
>
> ./simulation.pl
>
> it then executes and works fine.
>
> I have another script which works fine when i type "perl test.pl" but
> doesn't work when i type
>
> ./test.pl
>
> the permissions are chmod 755 and the permissions are the same as the
> previous. the opening line is:
>
> #!/usr/bin/perl -w
>
> the error it gives me is:
>
> bash: ./index.pl: No such file or directory
>
> suggestions?
>
> Charles Petersen
------------------------------
Date: 6 Jun 2000 08:54:09 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Stupid Question: scripts won't recognize opening line
Message-Id: <slrn8jpf1g.sij.vek@pharmnl.ohout.pharmapartners.nl>
On Tue, 06 Jun 2000 00:25:51 -0400, Kurt Krieger <kkrieger@erols.com> wrote:
>
>In your case, if the file was actually called test.pl, and the error
>message actually said something like "can't find test.pl", then open the
>file in vi and see if ^M is at the end of all the lines. If so, either
>re-upload the file in ascii mode, or issue these commands:
>% dos2unix test.pl newfile.pl
>% mv newfile.pl test.pl
>This strips off the ^M chars and spools the results to newfile.pl. Then
>rename it back to your original file name.
>
This would be a good suggestion, were it not for redhat using vim
as the vi editor. The vim editor has a feature? where it autodetects
if the file is in dos or unix format, and will display the file without
^M in both case. The only clue you would get is the vim displays the
text format briefly on the last line, or you can ussie the command
:set fileformat?
and you can fix it with this command
:set fileformat=unix
and save the file.
BTW. dos2unix cannot be expected to be present on every unix system.
--
Villy
------------------------------
Date: Tue, 6 Jun 2000 21:49:58 +0200
From: "Michael Schlueter" <michael.schlueter@philips.com>
Subject: Re: use strict
Message-Id: <8hiafs$4vi$1@porthos.nl.uu.net>
Put
#!/usr/bin/perl -w
to get some more warnings. I benefitted from this tiny -w flag many many
times.
------------------------------
Date: 5 Jun 2000 19:49:17 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Using a package identifier inside a package
Message-Id: <8hgsnd$shi$1@orpheus.gellyfish.com>
On Wed, 31 May 2000 02:45:05 GMT Bob Walton wrote:
> Drew Connery wrote:
>>
>> Hope someone can help me understand a piece of code that I've been
>> looking over. I'm a new PERL programmer so I'm sure it's a simple issue.
>>
>> If I create a package:
>>
>> package temp
> ;-----------------^
>>
>> and create a hash inside of the package:
>>
>> $temp::info = {...};
> Actually, that is a hash reference, not a hash.
>>
>> then why do I need to use the package identifier when creating the new
>> hash? Since it's being defined inside of the temp package shouldn't it
>> be associated anyway?
> You don't need to use the full name inside a package.
>
Of course within the constraints imposed by "use strict 'vars'".
/J\
--
Whenever Marge turns on one of her non-violent programs, I take a walk. I
go to a bar, I pound a few, then I stumble home in the mood for looooove.
--
fortune oscar homer
------------------------------
Date: Tue, 6 Jun 2000 09:27:58 +0100
From: "Scott Pritchett" <scott@salmon.ltd.uk>
Subject: Wag de Ref
Message-Id: <8hicnt$64h$1@lure.pipex.net>
Now don't laugh. I'm not having any problem with the code below, but I have
been unable to find an example in my Perl books. Does anyone see any
potential problems with using dereferencing in this way?
use strict;
no strict 'refs';
use diagnostics -verbose;
use vars qw($Wag $red $dog);
$::red="Wag";
$::dog="red";
$$$::dog="dog";
print "$$::dog the $::Wag\n";
Scott
------------------------------
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 3262
**************************************