[12124] in Perl-Users-Digest
Perl-Users Digest, Issue: 5725 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 19 13:07:20 1999
Date: Wed, 19 May 99 10:01:32 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 19 May 1999 Volume: 8 Number: 5725
Today's topics:
Re: How to pass params by ref/addr into subroutines (Andrew Allen)
Re: Making executables from .pl files? (Kai Henningsen)
Re: need pid of process initiated with backticks or sys (M.J.T. Guy)
Re: nested substring problem <swarren@www.wwwdotorg.org>
Re: or vs || (Larry Rosler)
Re: Perl, OLE, and Excel Graphs - off-topic (Michel Dalle)
Re: Problem moving OS/2-Perl, please help (Ilya Zakharevich)
Re: Protecting perl source code <jbc@shell2.la.best.com>
Re: Removing a directory with contents <cassell@mail.cor.epa.gov>
sharing, freezing and thawing <bwaite@uswest.com>
Re: Simple Time Manipulation <cassell@mail.cor.epa.gov>
Re: Tie Fighter (Chris Nandor)
Re: value from variable in a string (Larry Rosler)
Re: Y2K. localtime(time) (I R A Aggie)
Re: Y2K. localtime(time) <gellyfish@gellyfish.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 May 1999 16:24:45 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: How to pass params by ref/addr into subroutines
Message-Id: <7huokd$mt0$1@fcnews.fc.hp.com>
smnayeem@my-dejanews.com wrote:
: Hmm... there seems to be two ways of doing the same thing here, one is
: by making a reference, passing it and dereferencing it inside the
: subroutine and do whatever necessary,
: another way is to use the _ system variable.
: now my question is, which would be the better way? what are the pros and
: cons of both? say sometimes i have need to pass several parameters, is
: it better to use _ or references in those cases?
: thanks to anyone who might clear me on this :)
There's more than one way to do it. Use whatever's clearest. If you
need to modify the length of an array param, or modify a hash param,
you pretty much have to use references (but prototypes can help, see
perlsub).
Andrew
------------------------------
Date: 19 May 1999 09:38:00 +0200
From: kaih=7H8qT0T1w-B@khms.westfalen.de (Kai Henningsen)
Subject: Re: Making executables from .pl files?
Message-Id: <7H8qT0T1w-B@khms.westfalen.de>
ralawrence@my-dejanews.com wrote on 07.05.99 in <7guaqj$pa8$1@nnrp1.deja.com>:
> Having spoken to several people on this subject, there seems to be a lot of
> people who have the opinion that if you develop something on something that
> was free then what you developed should also be free and open.
That's not quite my impression.
People seem to think that sources should be open in general, and people
seem to think it's fairly pointless to keep sources closed if the binaries
are free.
Oh, and nobody thinks you should not be able to, somehow, make money from
your code. Several of them are, incidentally, making money with Perl -
*with* open sources. They just don't make it by selling binaries.
Kai
--
http://www.westfalen.de/private/khms/
"... by God I *KNOW* what this network is for, and you can't have it."
- Russ Allbery (rra@stanford.edu)
------------------------------
Date: 19 May 1999 16:29:18 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: need pid of process initiated with backticks or system call
Message-Id: <7huosu$fq8$1@pegasus.csx.cam.ac.uk>
Denis Lagarde <dlagarde@dnstelecom.fr> wrote:
>How do I get the pid of the process I initiated with
>`wget -O file.html www.perl.com `
>
>(the backticks are important there.)
Why do you want that? By the time you get an answer, the process will
be long gone. So the pid will be meaningless.
I wonder if you are confusing backticks with system() and/or fork/exec?
Mike Guy
------------------------------
Date: Wed, 19 May 1999 12:15:34 -0400
From: "Stephen Warren" <swarren@www.wwwdotorg.org>
Subject: Re: nested substring problem
Message-Id: <7huo66$ko9$1@owl.slip.net>
Berislav Vlahovic <berislav.vlahovic@sympatico.ca> wrote in message
news:927039947.629984254@news1.on.sympatico.ca...
> Hello,
>
> I'm trying to solve a problem that involves large recursion due to nested
> substrings.
>
> I have
>
> 1) A fairly large database of phrases (circa 2000 records)
>
> 2) A large number of html files (circa 300 3k files) containing those
phrases,
> that need to be linked to a cgi, with the unique id of the phrase
contained in
> the url
>
> The problem:
>
> The problem is that roughly 10% of the database is recursive phrases. IE
some
> of the phrases are substrings of other phrases.
You probably have to compute an ordering of your link phrases where the
'longest' are matched against your text first.
That way, if you match your phrases against your data in the order in the
database, you should find the 'longest' match first. Somehow, after a match,
you need to devise a way that nothing in that match can be matched again
when you continue matching the line against the data (since presumably there
can be multiple links on a line). That way, you can be sure that the 'short'
matches won't attach to substrings of the 'long' matches.
I'm not sure how I'd actually implement it though. Determining the
sub-expression ordering would be interesting in itself.
--
Stephen Warren, Snr Systems Engineer, Technology House, San Francisco
mailto:swarren@techhouse.com http://www.techhouse.com/
mailto:swarren@wwwdotorg.org http://www.wwwdotorg.org/
MIME, S/MIME and HTML mail are acceptable
------------------------------
Date: Wed, 19 May 1999 08:10:03 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: or vs ||
Message-Id: <MPG.11ac7420bf3a6bee989aa3@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <3742c1e9.0@news.cgocable.net> on Wed, 19 May 1999 09:53:28 -
0400, Andre Arpin <arpin@adan.kingston.net> says...
...
> It seems that >>> or and || <<< are different in more ways then precedence.
...
> print a or b;
> print "\n";
> print "|| >>";
> print a || b;
>
> ##################################################
>
> OUTPUT:
>
> or >> a
> || >> a b 1
The difference has only to do with precedence.
print a or b;
is
(print a) or b;
As 'print' returnes TRUE, b() is not executed.
print a || b;
is
print +(a || b);
As a() returns FALSE, b() is executed, and its return value (1) is
printed.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 19 May 1999 16:16:39 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Perl, OLE, and Excel Graphs - off-topic
Message-Id: <7huo4l$cs4$1@news.mch.sbs.de>
In article <37417BE8.4A036FB4@tivoli.com>, john_warner@tivoli.com wrote:
>Warning: Only quasi-Perl related. I've already posted this to several
>OLE oriented groups so no flames please!
>
>I am working on a project where I read information from an Oracle server
>using Perl (DBI&DBD::Oracle), manipulate the returned data, and then
>crank it into an Excel spreadsheet (based on a template) via
>Win32::OLE. All of this works quite well. However, there is a graph
>sheet that references a data
>sheet in the workbook. Since this workbook is based on a template with
>some pre-existing values, I need to update the data, series, and
>category ranges for the graph after I have manipulated the data sheet.
>Unfortunately, I haven't had much luck in finding OLE documentation on
>graph objects (yes, I have RTFM and checked FAQs) so I don't know what
>properties or methods are available to me. Can anyone give me a
>pointer? Is this the easiest approach or is there a better way? Along
>the same vein, what are some good OLE programming resources (on-line or
>hard copy)?
>
Have you tried the following :
1) open a workbook in Excel
2) start recording a macro
3) modify the series etc. of your chart
4) stop recording the macro
5) examine the macro in the Visual Basic editor
You'll notice commands like :
ActiveChart.SeriesCollection(1).XValues = "=Sheet1!R1C1:R16C1"
ActiveChart.SeriesCollection(1).Values = "=Sheet1!R2C2:R16C2"
6) Look up the meaning of these different methods and properties
in the Microsoft Excel Visual Basic help file
If you don't have that, run setup again (cfr. 'Hints for Microsoft Office
Automation' in your Win32::OLE documentation of Perl).
7) Convert the Visual Basic code into Perl, as explained in 'How do
I convert a VBA macro to Perl ?' in your 'Using OLE with Perl' FAQ
of Perl.
8) Blame Microsoft for any methods and properties not available
via OLE.
Isn't it amazing the kind of documentation that's already on your
local PC (without you knowing it) ? Did you indeed RTFM ?
Michel.
------------------------------
Date: 19 May 1999 16:02:20 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Problem moving OS/2-Perl, please help
Message-Id: <7hunac$f35$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Juergen Ibelgaufts
<ibelgaufts@gfc-net.de>],
who wrote in article <3742AB5C.70F92559@gfc-net.de>:
> Hi,
>
> Is there a way to move a Perl installation (latest OS/2 Perl) from one
> drive to another without using the complete installation procedure?
Yes, you need to set a couple of environment variables (view perl perlos2)
and edit Config.pm.
Ilya
------------------------------
Date: 19 May 1999 15:51:56 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: Protecting perl source code
Message-Id: <3742de1c$0$220@nntp1.ba.best.com>
Michel Dalle <michel.dalle@usa.net> wrote:
> Have you ever looked at the code for LinkScan ? It does something
> like this : no spaces, no newlines, random variable names, lots of
> nested variables and subroutines etc.
> (You'll find it at http://www.elsop.com/linkscan/)
Yeah, actually. I was one of their earlier customers. At one point I
encountered a bug, and thought, well, I know it's written in Perl; I'll
just pop in and see if I can fix it.
Agh! That's not code you'd want to have to make sense of.
This was subsequently discussed in this group (in an earlier
incarnation of this exact same thread), and the don't-hide-your-source
crowd was quick to point out that I wouldn't have had this experience
if Malcolm at elsop hadn't obfuscated his code. But as I see it, it was
his decision. Yes, it prevents his software from benefiting from all
those benefits of open source development. It still works well enough
for me that I still use it, opaque bugs and all.
When I corresponded with him about his obfuscator, his response was
that it wasn't that hard to create, at least for the minimal case of
obscuring his own script. Creating a more generally applicable
obfuscator might well be a more difficult proposition, as others have
pointed out here already.
--
John Callender
jbc@west.net
http://www.west.net/~jbc/
------------------------------
Date: Wed, 19 May 1999 09:32:22 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Removing a directory with contents
Message-Id: <3742E796.E3D9464D@mail.cor.epa.gov>
Jeff Foege wrote:
>
> Thanks David. The only thing that is happening is it prints out the die
> line and $0 is whatever I put. I guess I should have said that I am also
> doing this on NT for now. I don't have that #!/usr/bin/perl line in my code
> at all. I thought it was a comment and since it was showing unix folders I
> didn't bother. Where do I feed in the folder that I want deleted?
>
> Sorry about the text lines. I am heading into work right now and they don't
> have a ng port set up yet so I won't be able to respond until I get home,
> unless you use the email below.
>
> Thanks for your help!
>
> Jeff
>
The first line is not as useful on win32 boxes as on unix
boxes, but Perl will still grok any command-line options
you list. So tack on that -w, and let Perl help you find
any errors.
#!/usr/bin/perl -w
And you'll probably want to leave the comment line in there,
if not actually add to it. That way, you'll be able to
figure out how to use the thing when you come back to it
three months later.
# rmtree1 - from tchrist & gnat's Perl Cookbook
# remove whole directory trees like the unix 'rm -r'
# use: perl rmtree1.pl dirname
> use File::Find qw(finddepth);
> die "usage: $0 dir ..\n" unless @ARGV
^
Uh-oh. You're missing a semi-colon here.
> *name = *File::Find::name;
> finddepth \&zap, @ARGV;
> sub zap {
> if (!-1 && -d _) {
> print "rmdir $name\n";
> rmdir ($name) or warn "couldn't rmdir $name: $!";
> } else
>
> print "unlink $name\n";
> unlink ($name) or warn "couldn't unlink $name: $!";
> }
> }
In win32 systems, you can't simply chmod+x the file and
make it an executable program. But you can still say:
perl myscript.pl arg1 arg2 [...]
for however many args you have.
An alternative is the pl2bat program which comes with
ActiveState Perl. It wraps a little magic around your
Perl code so that you can run your program as a normal
.bat program, with Perl being called to execute the perl
code. If you do that (there's some fairly obvious
directions in the ActiveState HTML docs on your system),
then you can call your program like this:
myscript argument
just like you'd do with any other executable proggie
in win32.
Since you're on NT (as opposed to 95 or 98), there's
more you can do as well. Read the ActivePerl FAQ about
Win95 & WinNT programming, and you'll find a detailed
discussion.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 19 May 1999 09:02:02 -0600
From: Brad Waite <bwaite@uswest.com>
Subject: sharing, freezing and thawing
Message-Id: <3742D26A.12E7574A@uswest.com>
Okey-dokey.
'Been told that I need to use Storable::freeze on my GD::Image object before
dumping it into shared memory via IPC::ShareLite. But when I try to print the
thawed object as a gif, I only get about 10 bytes o' the data. Either that, or
I get this nifty file in my directory called, "core".
Suggestions??
------------------------------
Date: Wed, 19 May 1999 09:10:11 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Simple Time Manipulation
Message-Id: <3742E263.D4006FD6@mail.cor.epa.gov>
Sam Holden wrote:
>
> David Cassell <cassell@mail.cor.epa.gov> wrote:
> >hymie! wrote:
> >>
> >> In our last episode, the evil Dr. Lacto had captured our hero,
> >> Jonathan Stowe <gellyfish@gellyfish.com>, who said:
> >> >Newsworthy <hannum@ohio.edu> wrote:
> >> >> Hello,
> >> >>
> >> >> I want to be able to add 24 hours to the (timelocal) funciton. Could
> >> >> somebody tell me how I can best do this?
> >> >>
> >> >
> >> >I assume you mean localtime ?
> >> >
> >> >$time = localtime(time + 86400);
> >> >
> >> >Which of course might fail at some places at certain times of the year but
> >> >its usually good enough ;-}
> >>
> >> Why will this fail? Daylight savings time doesn't change the fact that
> >> 24 hours is 86,400 seconds.
> >
> >But daylight savings time *does* change the 'fact' that days
> >are 24 hours. In the non-pathological cases [:->] in the U.S.,
> >you have one day of 23 hours and one day of 25 hours each year.
>
> But the question was how to add 24 hours to the timelocal function.
> It wasn't how to get the next day.
Precise as always, Sam! And precision matters.
> Thus it will never fail even during those wonderful 2 hours of the
> year...
But.. as soon as the poster *uses* that value, he/she will
most likely have to deal with the stated issue.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 19 May 1999 15:06:19 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Tie Fighter
Message-Id: <pudge-1905991106210001@192.168.0.77>
In article <3746bbb3.16317778@news.skynet.be>, bart.lateur@skynet.be (Bart
Lateur) wrote:
# Chris Nandor wrote:
#
# ># Instead of returning the tied scalar, return a reference to it. Then
assign
# ># the reference to a typeglob.
# >
# >A solution requiring the use of global variables is no solution at all.
#
# Aren't you being a little too "strict"?
:p
Yeah, I use strict for everything (though it wouldn't be necessary in the
example code, since $_ is exempt). In Mac::Glue I have to hack the symbol
table here and there, but do a no strict 'refs' in a sub-block, and I set
up all my non-special globals with use vars, because I am a good little
perl hacker. :)
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Wed, 19 May 1999 07:50:30 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: value from variable in a string
Message-Id: <MPG.11ac6f91e076c9d6989aa0@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <3742BE68.4184D783@ensam.inra.fr> on Wed, 19 May 1999
13:36:40 +0000, Xavier Cousin <cousin@ensam.inra.fr> says...
> i have graphical variable defined as follow (it's for fly) :
>
> arc $x-100 $y 20 100 180 0 255 0 0
>
> each one parsed in an array. When $x and $y are defined, i use
>
> $graph =~ s/\$(\w+)/${$1}/eg;
>
> and $x and $y are converted to their numerical values
>
> but $graph become 170-100 and not 70.
>
> How can i force the script to execute this operation ??
#!/usr/local/bin/perl
$x = 170;
$y = 500;
my $graph = 'arc $x-100 $y 20 100 180 0 255 0 0';
$graph =~ s/\$(\w+)(\S*)/"${$1}$2"/eeg;
print $graph, "\n";
__END__
That does what you want, but is neither '-w'-clean nor 'use strict;'-
compatible. Here is a better approach:
#!/usr/local/bin/perl -w
use strict;
my %vals = ( x => 170, y => 500 );
my $graph = 'arc $x-100 $y 20 100 180 0 255 0 0';
$graph =~ s/\$(\w+)(\S*)/"$vals{$1}$2"/eeg;
print $graph, "\n";
__END__
Neither of these approaches deals with the cases where the variables are
not defined, which is left as an exercise for the reader. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 19 May 1999 14:51:50 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Y2K. localtime(time)
Message-Id: <slrn7k5k5f.559.fl_aggie@thepentagon.com>
On 19 May 1999 06:23:46 -0600, Daniel Grisinger
<dgris@moiraine.dimensional.com>, in
<m3n1z1qmct.fsf@moiraine.dimensional.com> wrote:
[about Matt's script archive]
+ Maybe someday somebody with a clue will reimplement those
+ dumb little programs.
Who has time? I've thought about it, but then there are a few dozen
more interesting pet projects I haven't gotten around to doing, either.
James
------------------------------
Date: 19 May 1999 16:16:11 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Y2K. localtime(time)
Message-Id: <3742d5bb@newsread3.dircon.co.uk>
I R A Aggie <fl_aggie@thepentagon.com> wrote:
> On 19 May 1999 06:23:46 -0600, Daniel Grisinger
> <dgris@moiraine.dimensional.com>, in
> <m3n1z1qmct.fsf@moiraine.dimensional.com> wrote:
>
> [about Matt's script archive]
>
> + Maybe someday somebody with a clue will reimplement those
> + dumb little programs.
>
> Who has time? I've thought about it, but then there are a few dozen
> more interesting pet projects I haven't gotten around to doing, either.
>
Maybe we ought to post bits of the code (or even the whole thing :) at the
weekend and do a group rewrite ...
/J\
--
Jonathan Stowe <jns@gellyfish.com>
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 5725
**************************************