[7560] in Perl-Users-Digest
Perl-Users Digest, Issue: 1186 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 16 14:09:57 1997
Date: Thu, 16 Oct 97 11:00:34 -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 Thu, 16 Oct 1997 Volume: 8 Number: 1186
Today's topics:
Re: 'Insecure dependency in unlink while running with - (Lack Mr G M)
Re: Any plans for Min and Max operators? (Paul Moore)
Re: Any plans for Min and Max operators? <rootbeer@teleport.com>
Re: Constants (contains spoiler:-) <psrc@corp.airmedia.com>
File creation in macPerl <chris_braiotta@harvard.edu>
Re: HEX question (Tad McClellan)
Re: HEX question <rootbeer@teleport.com>
Re: How to delete a directory <fred@foobar.com>
Re: How to extract substrings out of a line? <fred@foobar.com>
Re: How to make a word bold? (John Robson)
IPC and FIFOs <fred@foobar.com>
Re: Newbie problem with regex (Tad McClellan)
Re: Perl and SQL? <tlowery@dsdcng1.dsdc.dla.mil>
Re: Perl support <rootbeer@teleport.com>
Re: Q: How to make a dirhandle local to a subroutine? <brad.bradley@bridge.bellsouth.com>
Q: perlembed and memory leaks (Dragomir R. Radev)
Re: regular expression extensions <rootbeer@teleport.com>
Re: Replacing special chars with special chars <rootbeer@teleport.com>
Re: Return code values for backtic ops <merlyn@stonehenge.com>
Re: Some strange Perl things? <rootbeer@teleport.com>
Re: Static variables <rootbeer@teleport.com>
Re: statics or const in perl ? (Andrew M. Langmead)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 16 Oct 1997 15:45:11 BST
From: gml4410@ggr.co.uk (Lack Mr G M)
Subject: Re: 'Insecure dependency in unlink while running with -T switch'
Message-Id: <1997Oct16.154511@ukwit01>
In article <344767b8.2826165@news.wwa.com>, Faust Gertz <faust@wwa.com> wrote:
|>
|> > $mail_address=~/([\w-.]+\@[\w-.]+)/;
|> > $untainted_address = $1;
Missed the original, and this is not perl-related per se, but does
seem to crop up in here.
The recipient part of a mail address can contain more than [\w-.]+
Even forgetting the quoted, information-only part, RFC822 defines it
(eventually) as being a atom. That means it is anything in 7-bit ASCII
except specials, SPACE and CTL.
specials are: ()<>@,;:\".[]
SPACE is: space
CTL is: control characters and DEL (0-31 and 127 decimal)
So, it would appear that you should be able to have your mail address
as !#$%^&*+=|{}'?/~`@where.you.are.
--
----------- Gordon Lack ----------------- gml4410@ggr.co.uk ------------
The contents of this message *may* reflect my personal opinion. They are
*not* intended to reflect those of my employer, or anyone else.
------------------------------
Date: Thu, 16 Oct 1997 15:03:07 GMT
From: Paul.Moore@uk.origin-it.com (Paul Moore)
Subject: Re: Any plans for Min and Max operators?
Message-Id: <34462706.22731849@news.origin.nl>
On 16 Oct 1997 03:39:02 GMT, jahwan@supernova.math.lsa.umich.edu
(Jahwan Kim) wrote:
>On Wed, 15 Oct 1997 19:27:17 -0500, Tad McClellan <tadmc@flash.net> wrote:
>> Brett W. Denner (Brett.W.Denner@lmtas.lmco.com) wrote:
>[snip]
>
> What about adding functions, min and max?
>
>print min $a,$b;
>print max $a,$b,$c,$d;
>
>Adding these wouldn't do any harm but hopefully tiny amount of good.
>
>Jahwan
sub min (@) {
my $result = shift;
foreach my $arg (@_) {
$result = $arg if $result > $arg;
}
$result;
}
sub max (@) {
my $result = shift;
foreach my $arg (@_) {
$result = $arg if $result < $arg;
}
$result;
}
Used as
$val1 = min $a, $b, $c;
$val2 = max $a, $b, $c;
You also need variations which use lt and gt (string comparison)
instead of < and > (numeric comparison). I can't think of a good
naming convention (like </lt) to distinguish these.
You could do
sub min ($@) {
my $cmp = shift;
my $result = shift;
foreach my $arg (@_) {
$result = $arg if &$cmp($result,$arg) < 0;
}
$result;
}
Then you have
$val = min { $_[0] <=> $_[1] } $a, $b, $c;
$val = min { $_[0] cmp $_[1] } $a, $b, $c;
But this is more verbose than $val = ($a < $b ? $a : $b)...
Paul Moore.
------------------------------
Date: Thu, 16 Oct 1997 08:30:50 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Brett W. Denner" <Brett.W.Denner@lmtas.lmco.com>
Subject: Re: Any plans for Min and Max operators?
Message-Id: <Pine.GSO.3.96.971016082410.20497O-100000@usertest.teleport.com>
On Tue, 14 Oct 1997, Brett W. Denner wrote:
> Are there any plans for Min and Max operators in Perl?
If anyone makes some, they should accept lists (not just two values). What
should they do when given undef? (I'd say, treat it like zero, but return
it if it is then the min or max.)
In any case, I'd say you should put them in a module, rather than making
them builtins. When you've finished it and uploaded it to CPAN, announce
it on c.l.p.announce! :-)
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 16 Oct 1997 13:35:16 -0400
From: Paul S R Chisholm <psrc@corp.airmedia.com>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Constants (contains spoiler:-)
Message-Id: <34465054.632B@corp.airmedia.com>
On 14 Oct 1997, Matthew Cravit wrote:
> sub NUMERIC_CONSTANT { 27.3; }
> $foo += NUMERIC_CONSTANT;
Tom Phoenix wrote:
> Unfortunately...
> $bar = NUMERIC_CONSTANT + 3;
> print "$bar\n";
> Doesn't do what you might expect....
... because ...
(spoiler follows; wouldn't you really rather figure it out yourself?-)
... it's parsed as:
NUMERIC_CONSTANT(+3)
not:
NUMERIC_CONSTANT()+3
Ouch!-) Thanks, Tom!
--
Paul S. R. Chisholm, AirMedia, Inc. (formerly Ex Machina)
mailto:psrc@corp.airmedia.com http://corp.airmedia.com/~psrc
I'm not speaking for the company, I'm just speaking my mind
------------------------------
Date: Thu, 16 Oct 1997 10:48:04 -0500
From: Chris Braiotta <chris_braiotta@harvard.edu>
Subject: File creation in macPerl
Message-Id: <3446372D.827DF939@harvard.edu>
I'm sure this question has been answered a million times, but I've found
nothing in dejanews or any of the macPerl faq's. I have two questions,
and any help at all (including pointers to documentation) would be
greatly appreciated.
How does one
a) create folders in macperl
b) write files to specific folders
This is all quite easy in UNIX based perl, but I'm at a loss in macPerl.
thanks!
Chris Braiotta
chris_braiotta@harvard.edu
------------------------------
Date: Thu, 16 Oct 1997 10:39:05 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: HEX question
Message-Id: <pec526.ktj.ln@localhost>
Kick Fronenbroek (Kick@IT.net) wrote:
: Hello, I got some replies via mail (it should also be in the newsgroup
: (but I still do not see them)) that I should use printf.
: However, I need the hex code in a variable and (as far as I know) I
^^^^^^^^^^^^^^^^
Then you don't yet know about sprintf() ;-)
: cannot give the output of printf to a variable.
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 16 Oct 1997 09:33:20 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Kick Fronenbroek <Kick@IT.net>
Subject: Re: HEX question
Message-Id: <Pine.GSO.3.96.971016093021.20497T-100000@usertest.teleport.com>
On Thu, 16 Oct 1997, Kick Fronenbroek wrote:
> However, I need the hex code in a variable and (as far as I know) I
> cannot give the output of printf to a variable.
You could use sprintf. Or something like this:
$var = unpack "H*", pack "i", 12345678;
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 16 Oct 1997 12:25:42 -0400
From: I hate SPAM <fred@foobar.com>
Subject: Re: How to delete a directory
Message-Id: <34464005.6B7BB3B1@foobar.com>
--------------F7463D3B350C179E4ADAE5B0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
fischers@execpc.com wrote:
> How would I delete an entire directory that has a file inside with one
> command?
rm -fR directoryname
or
rm -Rf directoryname
this is like playing with dynamite...
--
_______________________________________________
Ben Newman benneman@nortel.ca
Nortel Technologies
35 Davis Drive (919)991-2622
Research Triangle Park
Raleigh, North Carolina 27613 ESN 294-2622
_______________________________________________
Note: In an effort to reduce spamming, the reply
to address in this message's header may be
incorrect. Please use benneman@nortel.ca.
--------------F7463D3B350C179E4ADAE5B0
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<HTML>
fischers@execpc.com wrote:
<BLOCKQUOTE TYPE=CITE>How would I delete an entire directory that has a
file inside with one
<BR>command?</BLOCKQUOTE>
rm -fR directoryname
<P> or
<P>rm -Rf directoryname
<P>this is like playing with dynamite...
<PRE>--
_______________________________________________
Ben Newman benneman@nortel.ca
Nortel Technologies
35 Davis Drive (919)991-2622
Research Triangle Park
Raleigh, North Carolina 27613 ESN 294-2622
_______________________________________________
Note: In an effort to reduce spamming, the reply
to address in this message's header may be
incorrect. Please use benneman@nortel.ca.</PRE>
</HTML>
--------------F7463D3B350C179E4ADAE5B0--
------------------------------
Date: Thu, 16 Oct 1997 11:53:23 -0400
From: I hate SPAM <fred@foobar.com>
Subject: Re: How to extract substrings out of a line?
Message-Id: <34463872.240A8CF@foobar.com>
--------------C7F3A7953A6DBFA1011C5D90
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
John Robson wrote:
> $line = "testing: 7/100 45/100 30/50"
>
> Would like to extract 7, 45 and 30 from $line and store them in the array
> @mynumbers. Why doesn't this work ? How to do this ?
>
> if ( $line =~ (/[0-9]+\//) )
> {
> push(@mynumbers, $1);
> }
An alternate, and dare I say more elegant, solution would be to make use of
the split function. Consider the following:
$line = "testing: 7/100 45/100 30/50" ;
@myNumbers = split (/ \//, $line);
You are now allowed to talk about myNumbers[1] (=7), myNumbers[3] (=45), and
myNumbers[5] (=30).
Voila,
Ben
--
_______________________________________________
Ben Newman benneman@nortel.ca
Nortel Technologies
35 Davis Drive (919)991-2622
Research Triangle Park
Raleigh, North Carolina 27613 ESN 294-2622
_______________________________________________
Note: In an effort to reduce spamming, the reply
to address in this message's header may be
incorrect. Please use benneman@nortel.ca.
--------------C7F3A7953A6DBFA1011C5D90
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<HTML>
John Robson wrote:
<BLOCKQUOTE TYPE=CITE>$line = "testing: 7/100 45/100 30/50"
<P>Would like to extract 7, 45 and 30 from $line and store them in the
array
<BR>@mynumbers. Why doesn't this work ? How to do this ?
<P>if ( $line =~ (/[0-9]+\//) )
<BR> {
<BR> push(@mynumbers, $1);
<BR> }</BLOCKQUOTE>
<P>An alternate, and dare I say more elegant, solution would be to make
use of the split function. Consider the following:
<P>$line = "testing: 7/100 45/100 30/50" ;
<P>@myNumbers = split (/ \//, $line);
<P>You are now allowed to talk about myNumbers[1] (=7), myNumbers[3] (=45),
and myNumbers[5] (=30).
<P>Voila,
<BR>Ben
<PRE>--
_______________________________________________
Ben Newman benneman@nortel.ca
Nortel Technologies
35 Davis Drive (919)991-2622
Research Triangle Park
Raleigh, North Carolina 27613 ESN 294-2622
_______________________________________________
Note: In an effort to reduce spamming, the reply
to address in this message's header may be
incorrect. Please use benneman@nortel.ca.</PRE>
</HTML>
--------------C7F3A7953A6DBFA1011C5D90--
------------------------------
Date: 16 Oct 1997 16:29:39 GMT
From: as646@FreeNet.Carleton.CA (John Robson)
Subject: Re: How to make a word bold?
Message-Id: <625fdj$s9q@freenet-news.carleton.ca>
brian d foy (comdog@computerdog.com) writes:
> In article <62351b$a6t@freenet-news.carleton.ca>, as646@FreeNet.Carleton.CA (John Robson) wrote:
>
>>How do you make a word or pattern *bold* by using the substitution.
>>Is it possible to do this in Perl?
>
> Perl doesn't know anything about bold. Perhaps this is a TeX question?
> if you explain what you are trying to do (the big picture, not the fine
> detail) someone might be able to help. :)
I'm trying to search for a word in a text file and then change that word
to bold. More precisely, print the line containing the word on the screen,
but show the word in BOLD. I'm thinking maybe there is some kind of
special ASCII code in MS-DOS or Unix that you can substitute to make
something look "bold" or "underlined". How does a word processor do it
anyway? How does a word processor translate from one document format to
another and still preserve the word attributes? Maybe it's not a Perl
question, but if Perl can do it, I'll be happy! :)
------------------------------
Date: Thu, 16 Oct 1997 12:09:14 -0400
From: I hate SPAM <fred@foobar.com>
Subject: IPC and FIFOs
Message-Id: <34463C2A.C35679F2@foobar.com>
--------------57A111EFAB2BC03D9DFE5914
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Ok, since no one responded to my question about threads and Perl, I am
going to assume that Perl has no support for multiple threads of control
(come on guys: no one is going to take Perl seriously as a programming
language until we get some _basic_ issues resolved ie multi-threading).
So let me pose the question another way: How do I get three processes to
communicate cyclically? Here's the best scenario I can come up with:
1) Process1 uses open2 to spawn process2.
2) Process1 uses open2 to spawn process3.
3) Now I need process2 to send its STDOUT to process3's STDIN, but it
cannot do so by routing it through process1. I was thinking FIFO, but I
have very little UNIX programming experience.
Here is a crappy ASCII diagram of what needs to happen. All input and
output is STDIN and STDOUT:
-----<----Process1----<-----
| |
V |
Process2 Process3
| |
V ^
------->---->----->------
Any suggestions?
--
_______________________________________________
Ben Newman benneman@nortel.ca
Nortel Technologies
35 Davis Drive (919)991-2622
Research Triangle Park
Raleigh, North Carolina 27613 ESN 294-2622
_______________________________________________
Note: In an effort to reduce spamming, the reply
to address in this message's header may be
incorrect. Please use benneman@nortel.ca.
--------------57A111EFAB2BC03D9DFE5914
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<HTML>
Ok, since no one responded to my question about threads and Perl, I am
going to assume that Perl has no support for multiple threads of control
(come on guys: no one is going to take Perl seriously as a programming
language until we get some _basic_ issues resolved ie multi-threading).
<P>So let me pose the question another way: How do I get three processes
to communicate cyclically? Here's the best scenario I can come up with:
<P>1) Process1 uses open2 to spawn process2.
<BR>2) Process1 uses open2 to spawn process3.
<BR>3) Now I need process2 to send its STDOUT to process3's STDIN, but
it <I>cannot </I>do so by routing it through process1. I was thinking FIFO,
but I have very little UNIX programming experience.
<P>Here is a crappy ASCII diagram of what needs to happen. All input and
output is STDIN and STDOUT:
<P>
-----<----Process1----<-----
<BR>
|
|
<BR>
V
|
<BR>
Process2
Process3
<BR>
|
|
<BR>
V
^
<BR>
------->---->----->------
<BR>Any suggestions?
<PRE>--
_______________________________________________
Ben Newman benneman@nortel.ca
Nortel Technologies
35 Davis Drive (919)991-2622
Research Triangle Park
Raleigh, North Carolina 27613 ESN 294-2622
_______________________________________________
Note: In an effort to reduce spamming, the reply
to address in this message's header may be
incorrect. Please use benneman@nortel.ca.</PRE>
</HTML>
--------------57A111EFAB2BC03D9DFE5914--
------------------------------
Date: Thu, 16 Oct 1997 10:43:45 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Newbie problem with regex
Message-Id: <hnc526.ktj.ln@localhost>
mark.johns@dawson.com wrote:
: I am using the following script, which doesn't work.
: #!/opt/gnu/bin/perl -w -i.bak
the example on p332 of the Camel has a -p switch in there too...
: I get the following errors:
: $ ../munge_test.pl test_munger.pl
: Use of uninitialized value at ../munge_test.pl line 24 (#1)
: I am using, as a model, the example from Camel p.332, for the -i option.
: What am I doing wrong?
You are not reading any lines into $_ before you attempt a substitution
on $_
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: 16 Oct 97 17:03:05 GMT
From: "Thomas A. Lowery" <tlowery@dsdcng1.dsdc.dla.mil>
Subject: Re: Perl and SQL?
Message-Id: <01bcda4d$d6cc9540$338a19c6@tlowery.dsac.dla.mil>
Henry,
You want to look at DBI/DBD modules from CPAN. It's an awesome set of
modules to
access common databases.
http://www.hermetica.com/technologia/DBI/
Tom
Henry Hartley <hartleh1@westat.com> wrote in article
<34462585.EDFDBBBB@westat.com>...
> I am relatively new to Perl but wanted to write some scripts to lookup,
> modify, etc. records in an SQL database. I've managed to write a script
------------------------------
Date: Thu, 16 Oct 1997 08:07:19 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Patrick Hanly <phanly@panix.com>
Subject: Re: Perl support
Message-Id: <Pine.GSO.3.96.971016080622.20497K-100000@usertest.teleport.com>
On 15 Oct 1997, Patrick Hanly wrote:
> Does anyone know of a company that provides professional quality support
> for perl?
The Perl Clinic
http://www.perl.co.uk/
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 16 Oct 1997 10:34:16 -0500
From: Brad Bradley <brad.bradley@bridge.bellsouth.com>
Subject: Re: Q: How to make a dirhandle local to a subroutine?
Message-Id: <344633F8.8BF58DEA@bridge.bellsouth.com>
David,
This can be accomplished by making the dirhandle a variable, something similar to
the delimiting variable that you check at the recursive program terminates. As
this value changes from call to call, so does the name of your filehandle. I think
this helps with the problem.
Sincerely,
Brad Bradley
mrbaseball2@rocketmail.com
David Stoner wrote:
> How can I make a dirhandle local to a subroutine?
>
> As mentioned in a previous article, I wrote a recursive subroutine in Perl to
> traverse a tree of directories, but I could find no way to make the dirhandle
> local to the subroutine, so different instances of the subroutine clobbered
> each other's dirhandles. I worked around the problem by having the subroutine
> read the entire directory into an array and close it before the subroutine
> called itself. That makes the routine a memory hog, so it fails on moderate-
> sized filesystems.
------------------------------
Date: 16 Oct 1997 12:48:42 -0400
From: radev@news.cs.columbia.edu (Dragomir R. Radev)
Subject: Q: perlembed and memory leaks
Message-Id: <625gha$ldi@ground.cs.columbia.edu>
I am using perlembed to access several Perl scripts from within a C
program. Everything works the way that I want, except for the memory
leaks. The main C process keeps growing at a very fast rate with every call
to perl_parse().
I have declared all relevant variable as "my". I have made sure that the
perl interpreter gets initialized only once.
I am using 'perl_destruct_level = 1;' before calling perl_destruct().
Any ideas?
Thanks,
Drago
--
Dragomir R. Radev Graduate Research Assistant
Natural Language Processing Group Columbia University CS Department
H: 212-749-9770 O: 212-939-7121 http://www.cs.columbia.edu/~radev
------------------------------
Date: Thu, 16 Oct 1997 08:11:09 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Shrikant Vijay Ranade <svr5@cac.psu.edu>
Subject: Re: regular expression extensions
Message-Id: <Pine.GSO.3.96.971016081010.20497L-100000@usertest.teleport.com>
On Wed, 15 Oct 1997, Shrikant Vijay Ranade wrote:
> i get the following error message.
> /&((?!vendor)|(?!Vendor)|(?!delivery))/: ?+* follows nothing in regexp
I don't. :-) What version of Perl are you using?
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 16 Oct 1997 08:42:27 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: eT <eT@nanoteq.com>
Subject: Re: Replacing special chars with special chars
Message-Id: <Pine.GSO.3.96.971016084007.20497P-100000@usertest.teleport.com>
On Thu, 16 Oct 1997, eT wrote:
> I would like to run through a file and replace a set of
> special chars (i only have the hex values) with other
> special chars..
Your code may include something like this.
tr[\x48\x65\x78\x20]
[\x63\x6f\x64\x65];
Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 16 Oct 1997 08:28:10 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: bobm@cunix.com (Bob Mariotti)
Subject: Re: Return code values for backtic ops
Message-Id: <8cwwjdafsl.fsf@gadget.cscaper.com>
(By the way, comp.lang.perl has been dead for over two years.]
>>>>> "Bob" == Bob Mariotti <bobm@cunix.com> writes:
Bob> We have serveral perl5 scripts that use the backtic characters to
Bob> execute a c program that returns info via stdout.
Bob> We are attempting to determine if the c program alarmed out or not.
Bob> We notices that there are several different return code values
Bob> (via-$?) but cannot find a guide to decipher them. We seem to get 0,
Bob> 14 and 256. Can anyone provide either a list of return code values OR
Bob> a URL to find them?
It's the value from "wait" or "waitpid", so the manpage would have
told youthat, but in brief, it's the child exit status times 256, plus
128 if core was dumped, plus the signal number that killed it if any.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 320 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Thu, 16 Oct 1997 08:18:04 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Jim Xikis <jxikis@mail.hsclib.sunysb.edu>
Subject: Re: Some strange Perl things?
Message-Id: <Pine.GSO.3.96.971016081231.20497M-100000@usertest.teleport.com>
On Wed, 15 Oct 1997, Jim Xikis wrote:
> Newsgroups: comp.lang.perl.misc, comp.lang.perl
If your news administrator still carries comp.lang.perl, please let him
or her know that that newsgroup has not existed since 1995. If you
have such an outdated newsgroup listing, you are probably missing out
on many other valid newsgroups as well. You'll be doing yourself and
many others a favor to use only comp.lang.perl.misc (and other valid
Perl newsgroups) instead.
> close <G>; }
That's (almost) never right. Don't close the line input operator! :-)
close G;
> open(F, "bills");
> open(G, ">temp1");
Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check of the return value after opening a
file.
> if (@line[0] eq ".colhead\n") {
Not using -w, are you? That will remind you that you'd be better off with
$line[0] there.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 16 Oct 1997 08:21:37 -0700
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Static variables
Message-Id: <Pine.GSO.3.96.971016081859.20497N-100000@usertest.teleport.com>
On Tue, 14 Oct 1997, Joe Gottman wrote:
> Is it possible to declare a static variable inside a Perl
> subroutine? By static I mean that the variable is initialized only
> once (when the subroutine is first called), maintains its value
> between calls, and is only in scope inside the subroutine.
Does this do what you want?
BEGIN {
my $private = 'initialized';
sub fiddle {
$private .= " + modified";
$private; # return value
}
}
> [Remove nospam to reply]
(Remove nospam if you want replies by email. :-)
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 16 Oct 1997 16:14:06 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: statics or const in perl ?
Message-Id: <EI5JrI.MsA@world.std.com>
Doug Seay <seay@absyss.fr> writes:
>As far as I'm concerned, they rival sliced bread. After rereading the
>docs, I still don't see any problems. At least not with scalars, they
>aren't as nice with lists.
Unfortunately, because the problems with lists, they don't quite fit
the original posters criteria.
use constant LIST => qw(a b c de f g);
for(@_) {
tr/a-mn-zA-MN-Z/n-za-mN-ZA-M/;
}
Silently ignores attempts to change the members of LIST and:
use constant LIST => qw(a b c de f g);
passsub(LIST);
sub passsub {
for(@_) {
tr/a-mn-zA-MN-Z/n-za-mN-ZA-M/;
print;
}
print "\n";
}
allows changes for the duration of the subroutine.
--
Andrew Langmead
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.
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 1186
**************************************