[15455] in Perl-Users-Digest
Perl-Users Digest, Issue: 2865 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 26 03:05:23 2000
Date: Wed, 26 Apr 2000 00:05:10 -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: <956732710-v9-i2865@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 26 Apr 2000 Volume: 9 Number: 2865
Today's topics:
[New O'Reilly book ?!?] Has anybody seen it? mitiste@charlie.iit.edu
\ in @ARGV <anthony@alphageo.com>
Re: Any Free Web Site That Allows Running Perl CGI? 0wn3d@my-deja.com
Re: Confusion between bitwise and stringwise & ? <tye@metronet.com>
Re: Converting HTML hex characters to characters mongoose@wpi.edu
Re: Date standardization without Date::Manip (Leslie Mikesell)
DBI:Pg not generic <danny@lennon.postino.com>
Re: DBI:Pg not generic <jeff@vpservices.com>
Re: help with matching.... (Tad McClellan)
Re: How to replace these strings in a html file (2nd p <huyv@usa.net>
Re: How to replace these strings in a html file (2nd p <lr@hpl.hp.com>
how to send a mail attache a file without modules <ya_hsiung@ms2.url.com.tw>
Re: how to send a mail attache a file without modules <rootbeer@redcat.com>
Re: I'm about to lose a client!!! SOMEBODY HELP ME!!! <phill@modulus.com.au>
Re: I'm about to lose a client!!! SOMEBODY HELP ME!!! <helphand@pacbell.net>
Re: Is there a way to create a Perl executable. (Sam Holden)
Re: Is there a way to create a Perl executable. <krasi77@yahoo.com>
Newbie question <maciek@treko.net.au>
Re: Newbie question <Frederic.Aussedat@Alcatel.fr>
Re: Newbie question <maciek@treko.net.au>
Re: NT perl script <talexb@tabsoft.on.ca>
overloading & 'constant' subroutines (Brian Keck)
Re: overloading & 'constant' subroutines <rootbeer@redcat.com>
Re: overloading & 'constant' subroutines (Brian Keck)
Re: PERL Interpreter <rootbeer@redcat.com>
Q: RegExp to parse lastname, first (middle) (jr/sr) - n <nospam@goaway.com>
Re: Q: RegExp to parse lastname, first (middle) (jr/sr) <elaine@chaos.wustl.edu>
Question on operator overload <Frederic.Aussedat@Alcatel.fr>
Re: Redirection with Perl and NT <grassdan@hotmail.com>
Re: system return code problem (Charles DeRykus)
Re: The final release? <jamesrfr@home.com>
uploading files with cgi-lib.pl <dzapped@theramp.net>
Re: Variable Caching <rootbeer@redcat.com>
Re: win32 ftp module... <helphand@pacbell.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 25 Apr 2000 22:58:13 -0500
From: mitiste@charlie.iit.edu
Subject: [New O'Reilly book ?!?] Has anybody seen it?
Message-Id: <jaqcgs81869jsm9hi2ntopdf5a148pfmu9@4ax.com>
Just stumbled across an ad in Linux magazine: a new
Perl/O'Reilly book seems to be out (?!?): "Perl for System
Administration" - has anybody had the chance to get their hands/eyes
on it? How is it? What about the author (David N. Blank-Edelman)? I
tried both B&N and Borders, to no avail ... and neither
www.oreilly.com has it ... :-( ... though Amazon advertise it to be
available in April (which is almost ended).?!?
TIA,
Stef
------------------------------
Date: Tue, 25 Apr 2000 21:09:38 -0700
From: Anthony Argyriou <anthony@alphageo.com>
Subject: \ in @ARGV
Message-Id: <u7qcgs41d7nr7k030o2am1rjn2p4i8rfu4@4ax.com>
How can I preserve a '\' in a command line?
I am writing a script to call an image viewer from a windows program running
under Wine (on Linux). The program generates a call of
"program.exe c:\path\to\file". program.exe is planned to be a perl script
which parses the remainder of the command line, then calls an appropriate
program with the proper unix parameters/filenames. The backslashes in the
filepath don't show up in @ARGV, making it difficult to parse the path.
Anthony Argyriou
Unix _is_ user-friendly. It's just selective about its friends.
------------------------------
Date: Wed, 26 Apr 2000 01:22:39 GMT
From: 0wn3d@my-deja.com
Subject: Re: Any Free Web Site That Allows Running Perl CGI?
Message-Id: <8e5gci$h3j$1@nnrp1.deja.com>
In article <8e49p3$t2e$1@hecate.umd.edu>,
billtj@Glue.umd.edu (William Djaja Tjokroaminata) wrote:
> Hi,
>
> Does anybody know any free web site where we can have our own web
page and
> where we also can run CGI scripts, especially Perl CGI scripts?
>
> I just got my free web site at www.geocities.com, but apparently I can
> only create static HTML pages.
>
> Thanks.
>
> Regards,
>
> Bill
>
www.hypermart.net is a pretty good one, although they say that you have
to be a business. Personally I just pretend I'm a business and
everything runs fine. =)
0wn3d
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 25 Apr 2000 18:01:20 -0500
From: Tye McQueen <tye@metronet.com>
Subject: Re: Confusion between bitwise and stringwise & ?
Message-Id: <8e5840$8tf@beanix.metronet.com>
[Posted and e-mailed.]
Larry Rosler <lr@hpl.hp.com> writes:
) I isolated the problem to a strange confusion between bitwise and
) stringwise &. If the confusion is in my mind, perhaps someone can clear
) it up. If it is perl, I want to submit a perlbug report.
Both! perlop.pod notes that simply using either argument in a numeric
context will force non-string bitwise operations. And a numeric C<&>
can induce a numeric context [at least in 5.6 but apparently not for
5.004].
But here is the bug you want to report:
% perl5.6.0 -e "my $z=10;$z='2'.$z;print 0+$z"
10
The C<$z='2'.$z> isn't clearing the now-invalid integer value of C<$z>!
--
Tye McQueen Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
------------------------------
Date: Tue, 25 Apr 2000 23:17:01 -0500
From: mongoose@wpi.edu
Subject: Re: Converting HTML hex characters to characters
Message-Id: <39066DBD.2E87B7B7@wpi.edu>
Nelson Asinowski wrote:
>
> mongoose@wpi.edu wrote:
> >
> > Well I just create html files I call templates, then I put special
> > characters designating where I want my perl script to put in generated
> > words. I don't have to type in lots of printfs for my html inside my
> > perl script. And I can change the webpage without having to edit the
> > perl script. Its a nice seperation. The perl script just takes care of
> > filling in the special words on the page and other file management on
> > the server. There really doesn't seem to be much to cgi other than
> > getting data from the web browser. Other than that its just alot of
> > parsing of data, database management...
> Consider HTML::Templates . Check out www.perlmonth.com for an article
> on this.
> It does exactly what you are coding yourself and can work with CGI.pm or
> other modules when needed.
>
> http://www.perlmonth.com/features/template/template.html?issue=11
>
> Second time today that I have made this recomendation.
Hmm well whatever works for you, I pretty much did all this on my own
in the same number of lines of code it seems. Besides, I have more fun
writing it all myself. =)
------------------------------
Date: 25 Apr 2000 22:05:53 -0500
From: les@Venus.mcs.net (Leslie Mikesell)
Subject: Re: Date standardization without Date::Manip
Message-Id: <8e5meh$11u0$1@Venus.mcs.net>
In article <8dt0av$nkq$1@nnrp1.deja.com>, <danrode@my-deja.com> wrote:
>I need to filter dates and store them in a comon format (likely epoch time).
>The input could be one of several date formats. MM/DD/YY, MM/DD/YY HH:MM,
>WDAY MON MDAY HH:MM:SS YYYY, and a few others. For dates that lack HH:MM:SS,
>I would like to use the current time or some standard time like "00:00:00" as
>a "filler".
>
>Date::Manip seems to be capable of dealing with much of the work, but it's
>large size would cause performance problems. Has anyone done something
>similar? Any suggestions?
It depends on what you are doing with them. I've thrown a lot
of 'strings that look like dates' at postgreSQL via DBI and
it automatically digested most of them into a datetime type
field. MySQL is a lot less forgiving.
Les Mikesell
les@mcs.com
------------------------------
Date: 26 Apr 2000 03:40:45 GMT
From: Danny Aldham <danny@lennon.postino.com>
Subject: DBI:Pg not generic
Message-Id: <8e5oft$n49$1@lennon.postino.com>
User-Agent: tin/pre-1.4-19990517 ("Psychonaut") (UNIX) (Linux/2.2.12-20 (i486))
I am having some trouble with DBI and Postgres. The standard syntax for
a DBI connect is :
use DBI;
$dbh = DBI->connect("dbi:$driver:$database","$user","$passwd") ;
but Postgres seems to insist on :
use DBI;
$dbh = DBI->connect("dbi:$driver:dbname=$database","$user","$passwd");
That dbname=$database is killing my portability. Has anyone hacked the
Pg driver to be more standard/generic?
--
Danny Aldham Providing Certified Internetworking Solutions to Business
www.postino.com E-Mail, Web Servers, Web Databases, SQL PHP & Perl
------------------------------
Date: Tue, 25 Apr 2000 23:44:04 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: DBI:Pg not generic
Message-Id: <39069034.E8F9DA33@vpservices.com>
Danny Aldham wrote:
>
> User-Agent: tin/pre-1.4-19990517 ("Psychonaut") (UNIX) (Linux/2.2.12-20 (i486))
>
> I am having some trouble with DBI and Postgres. The standard syntax for
> a DBI connect is :
> use DBI;
> $dbh = DBI->connect("dbi:$driver:$database","$user","$passwd") ;
No, the standard syntax is
$dbh->DBI->connect("dbi:$DSN",$user,$passwd,$atttributes);
The $DSN includes the driver name and some additional information that
is specific to the driver, usually a database name and sometimes a host,
port, filetype, or other information. Other than the driver name
itself, it is totally up to the driver how and what goes there.
> but Postgres seems to insist on :
> use DBI;
> $dbh = DBI->connect("dbi:$driver:dbname=$database","$user","$passwd");
>
> That dbname=$database is killing my portability. Has anyone hacked the
> Pg driver to be more standard/generic?
It is not any less standard or generic than any of the others. The
DBIx:AnyDB module addresses some of the portablity concerns you are
talking about.
--
Jeff
------------------------------
Date: Tue, 25 Apr 2000 20:50:50 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: help with matching....
Message-Id: <slrn8gcfba.69i.tadmc@magna.metronet.com>
On Tue, 25 Apr 2000 22:26:28 GMT, Chovy <johndoyle33@hotmail.com> wrote:
>I want to parse a file and extract the contents between a beginning and
>ending identifier.
>
>ie -
>
><!-- LIBRARY_SECT: test -->
Is that the "beginning identifier" or the "ending identifier"?
Or is part of that the beginning, and some other part the ending?
You haven't specified the problem very clearly...
>I'm opening a filehandle for this file, which has comment tags...here
>is my perl matching line:
>
> if (m/[^\n]*<!-- LIBRARY_SECT:(.*)<*-->/) {
^^
^^
What is that meant to match?
I don't see a second '<' in your sample string.
And "[^\n]" is more commonly written "." :-)
But you don't need that part of the regex at all anyway...
> $library_sect = $1;
> }
>
>This works if the comment tag in my text file is on it's own line...but
>if there is stuff after the ending comment tag "-->" it grabs that as
>well.
You should _show_ us a sample string with the "stuff after" then.
>How can I use "<!-- LIBRARY_SECT:" as the beginning identifier and the
>very next "-->" as the ending identifier,
Ah ha! Now we know what the 2 "ends" are.
>grabbing everything
>inbetween, resulting with $library_sect = " test " ??
Use non-greedy matching:
------------------------
#!/usr/bin/perl -w
use strict;
$_ = "before stuff<!-- LIBRARY_SECT: test -->after stuff<!-- ignore me -->\n";
print "'$1'\n" if m/<!-- LIBRARY_SECT:(.*?)-->/;
------------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 26 Apr 2000 00:41:42 -0400
From: "Huy Vu" <huyv@usa.net>
Subject: Re: How to replace these strings in a html file (2nd post)
Message-Id: <WmuN4.560$d73.7519@newscontent-01.sprint.ca>
I did a batch file which contents:
perl -e 's/>·</FONT><FONT size=2 style="font-family:'Arial';
font-size:10pt; " > />·</FONT><FONT size=2 style="font-family:'Arial';
font-size:9pt;" </FONT><FONT size=2
style="font-family:'Arial'; font-size:10pt; " >/g' file.htm
There are many '/' in the line below (one long line in the batch file)
I'm afraid of confusing the people so I didn't put it.
Thanks again.
"Tad McClellan" <tadmc@metronet.com> wrote in message
news:slrn8gb2l4.56q.tadmc@magna.metronet.com...
> On Tue, 25 Apr 2000 01:32:08 -0400, Huy Vu <huyv@usa.net> wrote:
>
> >I'm newbie in perl and have difficulty in trying to replace the string1
> >below:
> >
> >>·</FONT><FONT size=2 style="font-family:'Arial'; font-size:10pt; "
>
> >
> >with string2=
> >
> >>·</FONT><FONT size=2 style="font-family:'Arial'; font-size:9pt; "
> >> </FONT><FONT size=2
> >style="font-family:'Arial'; font-size:10pt; " >
>
> >I have difficulty in escaping the metacharacters in these strings.
>
>
> I don't think your difficulty is related to metachars.
>
> There are no regex metacharacters in either of those strings!
>
>
> Show us the code that you tried, and we will try and help you fix it.
>
>
> --
> Tad McClellan SGML Consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Tue, 25 Apr 2000 22:49:56 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: How to replace these strings in a html file (2nd post)
Message-Id: <MPG.1370235bbac5c798a983@nntp.hpl.hp.com>
In article <WmuN4.560$d73.7519@newscontent-01.sprint.ca> on Wed, 26 Apr
2000 00:41:42 -0400, Huy Vu <huyv@usa.net> says...
> I did a batch file which contents:
>
> perl -e 's/>·</FONT><FONT size=2 style="font-family:'Arial';
> font-size:10pt; " > />·</FONT><FONT size=2 style="font-family:'Arial';
> font-size:9pt;" </FONT><FONT size=2
> style="font-family:'Arial'; font-size:10pt; " >/g' file.htm
>
> There are many '/' in the line below (one long line in the batch file)
Use alternate delimiters, for example any character that isn't in the
regex or substitution:
s!...!...!g
<Jeopardectomy>
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 26 Apr 2000 12:31:03 +0800
From: "netnews" <ya_hsiung@ms2.url.com.tw>
Subject: how to send a mail attache a file without modules
Message-Id: <8e5rab$5s1@netnews.hinet.net>
How could I send a mail attache a file just using sendmail and perl,and
without using modules?
------------------------------
Date: Tue, 25 Apr 2000 23:15:04 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: how to send a mail attache a file without modules
Message-Id: <Pine.GSO.4.10.10004252312250.25963-100000@user2.teleport.com>
On Wed, 26 Apr 2000, netnews wrote:
> How could I send a mail attache a file just using sendmail and
> perl,and without using modules?
If you need information on sendmail, you should search for the docs, FAQs,
and newsgroups about sendmail. Information on talking to other programs
using Perl is covered in the Perl docs, of course, which you saw before
you posted.
Tell me, why do you not want to use modules? They're probably the best way
to do what you want. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 26 Apr 2000 11:03:20 +1000
From: Peter Hill <phill@modulus.com.au>
Subject: Re: I'm about to lose a client!!! SOMEBODY HELP ME!!!
Message-Id: <39064058.1F1E@modulus.com.au>
Larry Rosler wrote:
>
> In article <3904F507.5204@modulus.com.au> on Tue, 25 Apr 2000 11:29:43
> +1000, Peter Hill <phill@modulus.com.au> says...
>
> ...
>
> > my @array = <TXT>;
> > foreach (@array) {
>
> For line-at-a-time processing, it is wasteful of memory to slurp the
> entire file into an array before processing each element of the array.
> People may take what you wrote here as an acceptable Perl idiom. It
> isn't!
Good point. My bad. Deducts points from self.
>
> while (<TXT>) {
>
> > tr/|/ /;
> > print "$_<BR>\n";
>
> Leaving newlines in HTML output to a browser is a good, humane idea.
> But adding a newline when there already is one is overkill. :-)
Just *my* way of writing HTML for readability when I'm writing HTML by
hand, e.g.
I'm going to break this line here
<BR>
and continue it here.
--
Peter Hill,
Modulus Pty. Ltd.,
http://www.modulus.com.au/
------------------------------
Date: Tue, 25 Apr 2000 20:06:56 -0700
From: Helphand <helphand@pacbell.net>
Subject: Re: I'm about to lose a client!!! SOMEBODY HELP ME!!!
Message-Id: <09ncgsc10ec0ebkcacr0i6kg8sqbidv144@4ax.com>
On Tue, 25 Apr 2000 00:49:57 GMT, in comp.lang.perl.misc
er@matrix.com.br (Lobo) wrote:
>Please, it can't be THAT hard...
>
>I'm trying to display the contents of a Pipe Separeted Values TXT file
>to a page, but I keep receiving Internal Server Errors!!!!
>
>Here's my COMPLETE code:
>
>#!/usr/bin/perl
>
#!/usr/bin/perl -w
Try it , it's your friend.
Scott
--
http://www.geocities.com/helphand1/
Helphand's Not So FAQ's for the Palm
http://www.geocities.com/helphand1/palmprobs.htm
------------------------------
Date: 26 Apr 2000 01:09:20 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Is there a way to create a Perl executable.
Message-Id: <slrn8gcge0.71b.sholden@pgrad.cs.usyd.edu.au>
On Tue, 25 Apr 2000 17:57:24 -0700,
Alan Hopper <aahopper@mailbox.ucdavis.edu> wrote:
>
>As I understand it Perl gets compiled just before each execution. Is there
>a way to create Perl object code (i.e. an .exe ) program that does not
>need to be compiled every time it is run?
Is there anything preventing you from reading the FAQ that answers this
question?
perldoc perlfaq3
--
Sam
why can't newbies use hash slices in their hello world programs? :-)
-- Uri Guttman in <x74skxhve5.fsf@home.sysarch.com>
------------------------------
Date: Wed, 26 Apr 2000 04:30:12 GMT
From: Krasimir Christozov <krasi77@yahoo.com>
Subject: Re: Is there a way to create a Perl executable.
Message-Id: <sgcs6k72cdo103@corp.supernews.com>
Yes but the executable won't be portable. The strength of Perl is that the
scripts run without any changes (well almost) on Windows, Unix or Mac
servers. If you need better performance, use C
Alan Hopper wrote:
>
>
> As I understand it Perl gets compiled just before each execution. Is
there
> a way to create Perl object code (i.e. an .exe ) program that does not
> need to be compiled every time it is run?
>
>
>
--
Posted via CNET Help.com
http://www.help.com/
------------------------------
Date: Wed, 26 Apr 2000 14:17:17 +0800
From: Maciej Mastalarczuk <maciek@treko.net.au>
Subject: Newbie question
Message-Id: <390689ED.8BF07096@treko.net.au>
Hello,
Sorry if lame, I am quite new to perl.
I've got a question (Perl5 on RedHat6):
It possible to substitute user within perl script? Say script is
executed by nobody, but has to perform root action. Can I put encrypted
root password inside the script and revoke root rigths when the action
is finished?
Thanks and regards
--
Maciej Mastalarczuk
------------------------------
Date: Wed, 26 Apr 2000 08:32:56 +0200
From: Frederic Aussedat <Frederic.Aussedat@Alcatel.fr>
Subject: Re: Newbie question
Message-Id: <39068D98.1D9CC726@Alcatel.fr>
For security reason, never put a password in a script.
Hackers may access to it and get root password.
Very dangerous.
Better to run it from root user or use synchronize processes.
regards
Frederic Aussedat
Maciej Mastalarczuk a écrit:
>
> Hello,
>
> Sorry if lame, I am quite new to perl.
> I've got a question (Perl5 on RedHat6):
>
> It possible to substitute user within perl script? Say script is
> executed by nobody, but has to perform root action. Can I put encrypted
> root password inside the script and revoke root rigths when the action
> is finished?
>
> Thanks and regards
>
> --
> Maciej Mastalarczuk
------------------------------
Date: Wed, 26 Apr 2000 15:05:22 +0800
From: Maciej Mastalarczuk <maciek@treko.net.au>
Subject: Re: Newbie question
Message-Id: <39069532.BD180893@treko.net.au>
> For security reason, never put a password in a script.
> Hackers may access to it and get root password.
> Very dangerous.
>
> Better to run it from root user or use synchronize processes.
>
> regards
> Frederic Aussedat
Thanks for the reply.
The problem is that I need to run this script from a webpage. That means I
would have to run Apache as root. This is dangerous too.
Regards,
Maciej Mastalarczuk
------------------------------
Date: Wed, 26 Apr 2000 01:52:47 GMT
From: T. Alex Beamish <talexb@tabsoft.on.ca>
Subject: Re: NT perl script
Message-Id: <bsicgskb2ppknl0j41a1e5ng2jlchaqnib@4ax.com>
On Sun, 23 Apr 2000 16:00:28 -0400, Lydia Wrobel <wrobelly@msu.edu>
wrote:
>Hi, I found this message from a guy who posted in in 1995:
>
>>>>>
>Subject: ntPERL script
>Date: 06/22/1995
>Author: Dale Ross <dale@edison.nmhu.edu>
> << previous in search · next in search >>
>
>I am trying to submit a FORM and using PERL to extract the
>info, can't even get the data to write to a file or to be
>sent as mail. I can get the script to compile with no errors,
>but I am just not sure of the proper (NT?) syntex or command
>I should be using for $mailprog or $recipient that I should be
>using on my ver. 3.5 NT box. Any help would be appreciated.
>Many Thanks...
>>>>>>
>
>I am now having the same problem. I have a form on my Web site that uses
>a perl script to send the info people fill in the form to my email
>address. But, the script has default directory paths for Unix servers,
>not NT servers, which is what my site's hosted on. Does anyone know how
>sendmail works on NT servers? Like what the directory paths should be?
>Right now, the script is set for /usr/bin/perl and /usr/lib/sendmail
>
>I've also heard you need to use a totally different mail program on NT
>servers... is this true?
Lydia,
I don't know if you have all the answers you need yet, but here goes.
I did an eCommerce web site a few months back, and part of the deal
involved E-Mailing customer and store with information about the
order. Because this was UUNet's Windows NT box (never again!) I had to
use the external freeware blat. It worked worked fine (not MS software
obviously) .. BUT .. you do have to specify the entire path when you
want to refer to a file.
Good luck.
------------------------------
Date: 26 Apr 2000 04:36:26 GMT
From: c603273@castor.trl.OZ.AU (Brian Keck)
Subject: overloading & 'constant' subroutines
Message-Id: <8e5roa$6u7$1@news.cdn.telstra.com.au>
Keywords: overloading & 'constant' subroutines
I'm writing a module that overloads +-*/ and defines lots of constant
subroutines. But it seems (example below) that if x & y are such, you
can't say 'x * y'.
Rather, you have to tell perl that x & y are going to return things for
which multiplication is overloaded, by saying '&x * &y' or such. This
is a bit ugly.
Is there some way I can use the 'x * y' style?
Thanks for any help,
Brian Keck
------------------------------------------------------------------------
Example:
perl -MMath::BigInt -e '
sub x { new Math::BigInt "1000000"; }
print(x * x); print "\n";
print(&x * &x); print "\n";
'
This prints
+1000000
+1000000000000
(perl-5.005_02)
------------------------------
Date: Tue, 25 Apr 2000 23:25:08 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: overloading & 'constant' subroutines
Message-Id: <Pine.GSO.4.10.10004252317510.25963-100000@user2.teleport.com>
On 26 Apr 2000, Brian Keck wrote:
> I'm writing a module that overloads +-*/ and defines lots of constant
> subroutines. But it seems (example below) that if x & y are such, you
> can't say 'x * y'.
> sub x { new Math::BigInt "1000000"; }
That's not a constant subroutine; it's a subroutine whose code returns a
new Math::BigInt every time it's called.
use constant x => new Math::BigInt "1000000";
Now _that_'s a constant subroutine! (Perl can in-line that value nearly
every time it's used, doing constant folding as necessary.)
Still, I'm not sure why your original code didn't work; it looks to me as
if it's a bug in the overloading, or in Math::BigInt. Good luck with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 26 Apr 2000 06:25:15 GMT
From: c603273@castor.trl.OZ.AU (Brian Keck)
Subject: Re: overloading & 'constant' subroutines
Message-Id: <8e624b$8rp$1@news.cdn.telstra.com.au>
Keywords: Re: overloading & 'constant' subroutines
Answering my own question ...
>I'm writing a module that overloads +-*/ and defines lots of constant
>subroutines. But it seems (example below) that if x & y are such, you
>can't say 'x * y'.
>
>Rather, you have to tell perl that x & y are going to return things for
>which multiplication is overloaded, by saying '&x * &y' or such. This
>is a bit ugly.
>
>Is there some way I can use the 'x * y' style?
It works if you use prototypes, as in
sub x () { new Math::BigInt "1000000"; }
Pardon the noise,
Brian Keck
------------------------------
Date: Tue, 25 Apr 2000 20:47:21 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: PERL Interpreter
Message-Id: <Pine.GSO.4.10.10004252045590.25963-100000@user2.teleport.com>
On Tue, 25 Apr 2000, Mike Ayers wrote:
> I'm looking for a PERL interpreter. I'm aware of `perl -de 42`, but
> that is a little too limited. I'm looking for a little more
> sophistication in the command line editing and history department.
Have you installed Term::ReadLine? Well, there's your command-line editing
and history. :-)
But besides that, you have seen what the FAQ says about "Is there a Perl
shell?"
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 26 Apr 2000 01:50:56 GMT
From: "mnip" <nospam@goaway.com>
Subject: Q: RegExp to parse lastname, first (middle) (jr/sr) - need optional matches without overlap - how?
Message-Id: <4YrN4.190$1%5.13232065@news2.news.adelphia.net>
Question on Regular Expression use to parse names:
I have a large series of names, which will appear in cases from simple to
complex:
Simple: Lastname, First
Comples: Van Der Lastname, Firstname J Bob Jr.
I'm trying to write a pattern that will match
- everything before the comma,
- the first word after the comma,
- everything to the end of the line
- Jr, Sr, possibly III, but I don't see any of those.
as a variable number of submatches, two to four depending on the existence
of a middle name or jr/sr. I want at most four submatches, with the match
for "middlename" being the most inclusive of any anomolous text.
This works for the first two matches:
"(^\w+)+\,\s(\w+)"
but I'm confused on how to make the last part optional, without making an
overlap of matches with the multiple words that can appear after the comma.
Any Ideas?
------------------------------
Date: Wed, 26 Apr 2000 02:35:49 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: Q: RegExp to parse lastname, first (middle) (jr/sr) - need optional matches without overlap - how?
Message-Id: <B52BCE82.3073%elaine@chaos.wustl.edu>
in article 4YrN4.190$1%5.13232065@news2.news.adelphia.net, mnip at
nospam@goaway.com quoth:
> This works for the first two matches:
> "(^\w+)+\,\s(\w+)"
> but I'm confused on how to make the last part optional, without making an
> overlap of matches with the multiple words that can appear after the comma.
Tough problem as names aren't really standardised and McHenry and MacHenry,
etc. may or may not be the same thing. Careful with the \w as that will fail
with hyphenated names.
> Any Ideas?
http://search.cpan.org/search?dist=Lingua-EN-NameParse may be just what you
are looking for.
e.
------------------------------
Date: Wed, 26 Apr 2000 08:29:26 +0200
From: Frederic Aussedat <Frederic.Aussedat@Alcatel.fr>
Subject: Question on operator overload
Message-Id: <39068CC6.E7FE4C7F@Alcatel.fr>
Is there here anybody who have experiment overload module?
I'm using Perl 5.004_04 on Solaris.
And get a few problem using this overload module.
The access to @_ variable cause the overload routine to stop (in fact
not stop but continue aditam eternam). I don't get the prompt again.
Following an extract of the code causing the pb.
Thanks to glance at it.
The problem exist also if in the first line I do
my @x = @_;
---------
package dotNumber; # eg: 1.10.004.12
#-- Overload comparison operators
use overload '==' => \&ge_
, '""' => \&string
;
sub ge_ {
#-- Get dot fields
print STDERR __LINE__."\n";
my @a = split /\./, $_[$_[2]?0:1];
print STDERR __LINE__."\n";
my @b = split /\./, $_[$_[2]?1:0];
print STDERR __LINE__."\n";
#-- Do comparison on each dot field
my $i=0;
while (defined $a[$i] && defined $b[$i] && $a[$i] == $b[$i]) {
$i++;
};
return ($a[$i] >= $b[$i]);
}
1;
------------------------------
Date: Tue, 25 Apr 2000 18:14:55 -0700
From: "Dan Grass" <grassdan@hotmail.com>
Subject: Re: Redirection with Perl and NT
Message-Id: <sgcgo9hvcdo16@corp.supernews.com>
"Scott Pyatt" <spyatt@selectica.com> wrote in message
news:39061C65.4CBC714A@selectica.com...
> I've recently loaded Active Perl on a pair of NT systems. All appears
> to be working fine until I attempt to redirect or pipe ouput from a
> Perl program. For instance I create a simple hello.pl script with the
> following line.
>
> print("Hello\n");
>
> I then run it.
>
> C:\hello.pl
> Hello
>
> It works. Now I redirect the output to a file.
>
> C:\hello.pl > howdy.txt
>
> As you would expect, no output is sent to the screen . However, the
> "howdy.txt" which gets created is empty! I've also tried the
> following without any luck.
>
> C:\hello.pl | sort
>
> No output is sent to the screen. I've also tried things like this,
> but it still does not work.
>
> print(STDOUT "Hello\n");
>
> Anyone have any thoughts other than opening a file in Perl or throwing
> NT out the window (pun intended).
>
> Thanks,
> -Scott
On my Windows 2000 box with Active perl 5.6 build 613
this works correctly, (ie it sends the output to the txt file).
------------------------------
Date: Wed, 26 Apr 2000 00:51:28 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: system return code problem
Message-Id: <FtLMDs.KGq@news.boeing.com>
In article <FtLAz7.KIp@news.boeing.com>,
Charles DeRykus <ced@bcstec.ca.boeing.com> wrote:
>In article <f1lbgscrc1cfmdu5j1tcpjog1s88nguhcn@4ax.com>,
>Al Bundy <AlBundy@aol.net> wrote:
>>I am trying to execute a system call such as:
>>
>>system( "myprogram | tee afile.log" );
>>...
>>the above system call returns 0.
>>
>>Any ideas on how to get around this? I can not simply add
>>"> afile.log" to the command due to other requirements.
>>
>
>Perhaps, a kludge:
>
>system q{ (myprogram;sv=$?) | tee afile.log;exit $sv };
>
Bad suggestion. Something even uglier and kludgier works
but pollutes your tee with the exit status:
system q{ (foo;echo $?)| tee afile.log;exit `tail -1 afile.log` };
--
Charles DeRykus
------------------------------
Date: Wed, 26 Apr 2000 03:23:41 GMT
From: james <jamesrfr@home.com>
Subject: Re: The final release?
Message-Id: <39066134.54CB3DB6@home.com>
that was great! :vD
------------------------------
Date: Tue, 25 Apr 2000 21:17:07 -0500
From: Z-man <dzapped@theramp.net>
Subject: uploading files with cgi-lib.pl
Message-Id: <390651A3.977F96CC@theramp.net>
Hi all,
I've run into a problem uploading files such as my document.doc (notice
the space in the file name is intentional) Has any one else had this
problem?Other than renaming the files is there any way to fixx this
problem?just an fyi I'm running my scripts on a win98 box.Any help
appreciated.
TIA
Denis
------------------------------
Date: Tue, 25 Apr 2000 20:55:32 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Variable Caching
Message-Id: <Pine.GSO.4.10.10004252051370.25963-100000@user2.teleport.com>
On Wed, 26 Apr 2000 0wn3d@my-deja.com wrote:
> I have been having a problem with some cgi scripts that I have been
> writing over the past month.
When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN.
http://www.perl.com/CPAN/
http://www.cpan.org/
http://www.cpan.org/doc/FAQs/cgi/idiots-guide.html
http://www.cpan.org/doc/manual/html/pod/
> some variables are cached after running the script,
Perl doesn't do that. Are you using mod_perl or something which is doing
that?
> so that if I have a variable called $task and the task that the script
> does is dependant upon the value of that variable, a value from before
> will be existant, instead of obliterating the variable to start a new
> operation. I do have each variable initialized with my in front of
> them, but it continues to behave in this manner.
You may be mistaken about what 'my' does. Without seeing any code, though,
it's hard to be sure.
> Does anybody have suggestions on how to eliminate a variable's value
> after it is used
Generally, you should use proper scoping. If you're sure you're doing this
right, cut your program down to the smallest example which displays this
behavior. Make it so that it doesn't have to be a CGI program, if
possible. Then you can post it here so that others can see what you're
doing, and perhaps try it themselves.
Good luck with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 25 Apr 2000 20:08:48 -0700
From: Helphand <helphand@pacbell.net>
Subject: Re: win32 ftp module...
Message-Id: <1dncgssnr3k4gfju645fpev45gqmq93eug@4ax.com>
On Tue, 25 Apr 2000 15:06:16 +0100, in comp.lang.perl.misc Kourosh A
Mojar <kmojar@bmjgroup.com> wrote:
>Dear all,
>
>I am a moderately novice perl programmer. I am using perl (win32) to
>automate some ftp tasks. I was using cross platform perl before which
>worked great. Now I am using win32 I have installed the NetLib module (I
>think I did it properly) although I cannot continue to work with my ftp
>scripting. I get an error:
>
>"can't call method "login" without a package or object reference at ...
>line... etc."
>
>Any help or suggestions?
>
A snippet of the offending code would be helpful.....
Scott
--
http://www.geocities.com/helphand1/
Helphand's Not So FAQ's for the Palm
http://www.geocities.com/helphand1/palmprobs.htm
------------------------------
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 2865
**************************************