[8420] in Perl-Users-Digest
Perl-Users Digest, Issue: 2036 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 5 19:16:57 1998
Date: Thu, 5 Mar 98 16:00:42 -0800
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, 5 Mar 1998 Volume: 8 Number: 2036
Today's topics:
Re: @INC and lib jabedi@its.brooklyn.cuny.edu
Re: Add int, convert to string, substitute. HELP! <jdf@pobox.com>
Re: BIG integers <spp@colltech.com>
Re: Clearing the screen (Earl Hood)
Re: Clearing the screen <dformosa@st.nepean.uws.edu.au>
Re: Conflict in this Newsgroup <dformosa@st.nepean.uws.edu.au>
Re: Create directory from input in file? <jdf@pobox.com>
Re: Help with perl, immediate answers wanted! (Andy Lester)
Re: i know it didn't do what i wanted... but what DID i <jdporter@min.net>
Re: i know it didn't do what i wanted... but what DID i <cmargoli@world.northgrum.com>
Re: i know it didn't do what i wanted... but what DID i <jdf@pobox.com>
Re: i know it didn't do what i wanted... but what DID i <cmargoli@world.northgrum.com>
In defense of Netcom (Brand and Karina Hilton)
Re: In defense of Netcom <fnord@panix.com>
Re: In defense of Netcom <zenin@best.com>
Re: in the name of Baby Jesus PLEASE HELP ME... (Abigail)
Re: ksh2perl converter? (Michael Wang)
Re: Length of an array? (David Wall)
local/global var question <gmanuel@ti.com>
Re: local/global var question <mishra.aditya@emeryworld.com>
Re: padding a file -- Better way?? (Andrew M. Langmead)
Re: Perl FAQ Error... <jdf@pobox.com>
Re: Perl Purify'd? <jdporter@min.net>
Re: Perl QRG(Quick Reference Guide) <jdporter@min.net>
Portable I/O Multiplexing (dave)
problems with one-liners on the command line (Kevin B Cohen)
Re: problems with one-liners on the command line <mishra.aditya@emeryworld.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 05 Mar 1998 16:33:22 -0600
From: jabedi@its.brooklyn.cuny.edu
Subject: Re: @INC and lib
Message-Id: <6dn963$olv$1@nnrp1.dejanews.com>
In article <34FEC5B4.72EB6776@houston.Geco-Prakla.slb.com>,
Dave Barnett <barnett@houston.Geco-Prakla.slb.com> wrote:
> The use lib keyword combination is a great way to use private
> libraries. Things that you write yourself, but don't want generally
> used, things from CPAN that your ISP|Systems Admin|Someone else will not
> install in the default libraries, ...
Dave,
Thanks for the reply. What about if I want to include new perl library
directories in the @INC that would be available to everyone? Anyway to do this
besides setting PERL5LIB? Thanks again!
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 05 Mar 1998 15:51:26 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Add int, convert to string, substitute. HELP!
Message-Id: <wwe8zws1.fsf@news.concentric.net>
as646@FreeNet.Carleton.CA (John Robson) writes:
> s/"([0-9][0-9][0-9][0-9])"/$1+1000/ge
> But I want to see the numbers in quotes " " !
Boy, were you close.
s/^"(\d{4})/'"' . ($1 + 1000)/e;
is one approach. Notice: the use of ^ to anchor the match to the
beginning of string; the use of a character class \d to match a digit;
the use of {} in the regex to match an exact number of entities; the
fact that once you've got the four digits there's no need to keep
matching (in this *particular* case); the fact that data-types are
implicitly and silently converted in an expression like
my $example = 'foo' . 23 . 'bar'; # gives 'foo23bar';
and the fact that, since the pattern only occurs once, the 'g'
modifier is not needed. HTH.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: 05 Mar 1998 17:29:07 -0600
From: Stephen Potter <spp@colltech.com>
Subject: Re: BIG integers
Message-Id: <uug1kwson0.fsf@psasolar.private.psa.pencom.com>
Uri Guttman <uri@sysarch.com> writes:
> Jeff Hay <jrhay@lanl.gov> writes:
>
> > integer range of my version of Perl (running on SunOS). Does anybody
> > know of a module, etc, for handling BIG integer numbers with Perl?
> >
> it is called appropriately BigInt (sp?) and is located at your favorite
> CPAN site. check out www.perl.com for CPAN
Actually, Math::BigInt is part of the standard perl distribution. There's
no need to go all the way out to CPAN to get it.
-spp
--
Stephen P Potter |~~~~| |~~~~| spp@colltech.com
Ph: 312-781-1111 |____| C o l l e c t i v e |____| Team "OH, Yeah!"
Pg: 800-759-8888, |_______ _______| Webstreet Securities
571-1869 [] technologies [] jthome.jthome.com/~spp
a pencom company
------------------------------
Date: 5 Mar 1998 21:41:40 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: Clearing the screen
Message-Id: <6dn66k$goo@news.service.uci.edu>
In article <EpCp7x.1Lv@world.std.com>,
Andrew M. Langmead <aml@world.std.com> wrote:
>"Joshua Frank" <joshua@midwest.net> writes:
>
>>Is there a simple way to clear the screen in perl 4? Without using tk or
>>anything like that.
>
>From what I recall, in perl 4 you have the choices of running another
>process that will clear the screen for you ("system('clear')"),
>Outputting the appropriate escape codes yourself (if you can be
>guarenteed the type of terminal the code will be running with.)
In a program I wrote years ago, I have initialization code that will
capture the output of the "clear" command into a variable. Then,
anytime I needed to clear the screen, just print the variable to avoid
the overhead of using system each time I wanted to clear the screen.
Example code showing technique:
open(CLEAR, 'clear |') || die;
$clear = join("", <CLEAR>);
close CLEAR;
print $clear;
Modularize as you see fit. Note, only works under Unix systems.
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: 5 Mar 1998 22:22:12 GMT
From: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: Clearing the screen
Message-Id: <889136532.10569@cabal>
In <6dlf59$bhq$1@usenet54.supernews.com> "Joshua Frank" <joshua@midwest.net> writes:
>Is there a simple way to clear the screen in perl 4?
Well on some systems printing a Form Feed char to the screen will clear
it. On others calling the program 'clear' via system will do this.
--
Please excuse my spelling as I suffer from agraphia see the url in my header.
Never trust a country with more peaple then sheep.
Support NoCeM http://www.cm.org/
I'm sorry but I just don't consider 'because its yucky' a convincing argument
------------------------------
Date: 5 Mar 1998 22:39:39 GMT
From: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: Conflict in this Newsgroup
Message-Id: <889137579.466361@cabal>
In <01bd4536$0f8707a0$7eaa8bcd@space.netusa1.net> "V. Chandrasekhar" <shaker@netusa1.net> writes:
[...]
>2. Two types of interactions may be identified in people relations:
> Master - Disciple (MD) (Rare in msot places)
> Consumer - Producer (CP) (Very common)
However CP releationships exist only where thay are supported by payment.
[...]
>Disciple is expected to show a lot of self-discipline, not ask
>anything that will anger the master, only ask things that provide
>the master at least some measure of amusement, in general let the
>master dictate, make sure that they don't piss him off,
If you are asking for a free service, should you not a least make
the person who is giving that service life better ratheer then worse.
[...]
>At least some posters come expecting a measure of the CP
>relationship.
Then thay are fundermentaly deluded about not only the nature of this
newsgroup but the nature of Usenet itself. Usenet (and by the extention
this newsgroup) is a voltory orginisation, so CP are not relevent to
interaction.
[...]
>3. When the Perl masters teach courses, almost certainly a CP
>relationship applies; nobody's head is bitten off when the students
>ask a FAQ or a CGI question in a Perl class.
But there getting payed money.
>4. When the Perl masters publish books, again a CP relationship is
>evident.
And again there getting payed to do it.
>5. Between a poster and his ISP, there is a CP relationship. The
>ISP gives each subscriber the right to post in all groups.
Not at all, no-one has the right to post in any group. The fact that a
message propregates is due to the voltry co-operation of newmasters.
There is no compustion for a message to ever leave your ISP's hard drive.
This is Usenet your are a guest, you have no rights.
--
Please excuse my spelling as I suffer from agraphia see the url in my header.
Never trust a country with more peaple then sheep.
Support NoCeM http://www.cm.org/
I'm sorry but I just don't consider 'because its yucky' a convincing argument
------------------------------
Date: 05 Mar 1998 16:04:46 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Create directory from input in file?
Message-Id: <vhtszw5t.fsf@news.concentric.net>
as646@FreeNet.Carleton.CA (John Robson) writes:
> How do I read the first field of each line, create a directory with the
> name of that first field, read the second field of the line, and then copy
> the actual file from the second field into the directory created (from 1st
> field) ???
This doesn't really strike me as a Perl-related question. It sounds
like you need some help in designing an *algorithm* to do what you want.
Then, if you know even a little Perl, you should be able to translate
your algorithm into perl code. If you don't know enough Perl to
accomplish these things, then you should get yourself a copy of
_Learning Perl_, and work your way through it. You'll then find this
newsgroup to be an excellent resource for problems that aren't clearly
addressed in the documentation that accompanies perl. Come to think
of it, it's likely that there will be a response following mine that
writes the code for you... Enjoy it, and I hope this helps too.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: 5 Mar 1998 22:33:10 GMT
From: petdance@maxx.mc.net (Andy Lester)
Subject: Re: Help with perl, immediate answers wanted!
Message-Id: <6dn976$7v4$1@usenet11.supernews.com>
: Hi all, I was wondering if anyone could help me with a problem, well not
Seems more like you were demanding. "Immediate answers wanted!" indeed.
xoxo,
Andy
--
--
Andy Lester: <andy@petdance.com> http://tezcat.com/~andy/
Chicago Shows List: <shows@ChicagoMusic.com> http://ChicagoMusic.com/
------------------------------
Date: Thu, 05 Mar 1998 17:25:03 -0500
From: John Porter <jdporter@min.net>
Subject: Re: i know it didn't do what i wanted... but what DID it do??
Message-Id: <34FF263F.6059@min.net>
Kevin B Cohen wrote:
>
> while trying to define a hash, a did a typo... well, actually a
> brain-o... and put curly braces where i should have put parentheses:
>
> %letters = {
> 'a' => 'eI',
> 'b' => 'bi',
> 'c' => 'si',
> etc.
>
> that did not make me a hash named %letters; e.g., if i had a variable
> $char = 'c' and tried to assign $phon = $letters{$char}, i got
> nothing. once i changed the curly braces to parentheses, my problems
> disappeared.
>
> my question is, what DID i do when i used the curly braces? it
> compiled just fine (no, i wasn't using -w). looks kinda like an
> anonymous array on the right hand side, but what's the left?
When I do this, I get a compiler error:
"Odd number of elements in hash list..."
So I think that "etc." must have contained something interesting.
The left side is a hash variable, it supplies list context to
the rhs of the assignment, and requires that the list on the
rhs have an even number of elements.
John Porter
------------------------------
Date: Thu, 5 Mar 1998 22:33:28 GMT
From: Charles Margolin <cmargoli@world.northgrum.com>
Subject: Re: i know it didn't do what i wanted... but what DID it do??
Message-Id: <34FF2838.646D@world.northgrum.com>
Kevin B Cohen wrote:
>
> while trying to define a hash, a did a typo... well, actually a
> brain-o... and put curly braces where i should have put parentheses:
>
> %letters = {
> 'a' => 'eI',
> 'b' => 'bi',
> 'c' => 'si',
> etc.
>
> that did not make me a hash named %letters; e.g., if i had a variable
> $char = 'c' and tried to assign $phon = $letters{$char}, i got
> nothing. once i changed the curly braces to parentheses, my problems
> disappeared.
>
> my question is, what DID i do when i used the curly braces? it
> compiled just fine (no, i wasn't using -w). looks kinda like an
> anonymous array on the right hand side, but what's the left?
>
An assignment with curly braces on the right hand side creates
an "anonymous hash" and returns a reference to it. If the left side
is a scalar variable then you can capture that reference and use it:
$letters = {
'a' => 'eI',
'b' => 'bi',
'c' => 'si',
};
print $letters->{'b'}, "\n";
See the perlref man page for more info.
In your case, you should have seen an error message like
Odd number of elements in hash list
because the reference is one item and you assigned it to the hash.
--
Charles G. Margolin DSSD Internal Information Services
cmargoli@world.northgrum.com Northrop Grumman Corp. 0624/23
margolin@acm.org Hawthorne, California 90250-3277
------------------------------
Date: 05 Mar 1998 17:20:27 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: i know it didn't do what i wanted... but what DID it do??
Message-Id: <ra4gzsno.fsf@news.concentric.net>
kcohen@julius.ling.ohio-state.edu (Kevin B Cohen) writes:
> while trying to define a hash, a did a typo... well, actually a
> brain-o... and put curly braces where i should have put parentheses:
> my question is, what DID i do when i used the curly braces? it
> compiled just fine (no, i wasn't using -w). looks kinda like an
> anonymous array on the right hand side, but what's the left?
You created an anonymous hash and then tried to assign it to a hash.
What mystifies me is that you didn't get the message "Odd number of
elements in hash list" when you ran your script, with or without -w.
What version of perl are you running?
Anyway, you'll want to read the "perldata," "perlref," "perldsc," and
"perllol" documents, which treat this topic well-nigh exhaustively.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Thu, 5 Mar 1998 23:39:52 GMT
From: Charles Margolin <cmargoli@world.northgrum.com>
Subject: Re: i know it didn't do what i wanted... but what DID it do??
Message-Id: <34FF37C8.5418@world.northgrum.com>
Jonathan Feinberg wrote:
> What mystifies me is that you didn't get the message "Odd number of
> elements in hash list" when you ran your script, with or without -w.
It turns out that what Kevin did was to code the offending statement
inside a sub definition, but he didn't call the sub. The error
is not detected until runtime, with or without -w.
--
Charles G. Margolin DSSD Internal Information Services
cmargoli@world.northgrum.com Northrop Grumman Corp. 0624/23
margolin@acm.org Hawthorne, California 90250-3277
------------------------------
Date: Thu, 5 Mar 1998 21:55:53 GMT
From: bkhilton@netcom.com (Brand and Karina Hilton)
Subject: In defense of Netcom
Message-Id: <bkhiltonEpD8x6.700@netcom.com>
In article <6dmeps$7mv$1@info.uah.edu>, Greg Bacon <gbacon@cs.uah.edu> wrote:
>In article <6dki8u$ra9@dfw-ixnews10.ix.netcom.com>,
> jeff@yoak.com (Jeff Yoak) writes:
>: ----- Transcript of session follows -----
>: Message rejected: Mail from unauthorized host
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>Here's what my log has to say about that message:
>
> 1998/03/03 20:51:24 [9116]: Message from jeff@yoak.com (Re: Controlling TWO input files (merging))
> 1998/03/03 20:51:24 [9116]: Spamchecker caught \bnetcom\.com\b
>
>Quit giving money to spam harborers.
>
>BTW, The filter I use is based on the one Tom uses. :-)
>
>Greg
Netcom appears to be making more of an effort to deter
spammers. We received the following email yesterday:
>From support@netcom.com Thu Mar 5 13:49:02 1998
Date: Wed, 4 Mar 1998 13:53:24 -0800 (PST)
From: support@netcom.com
To: bkhilton@netcom.com
Subject: A Message about SPAM
Dear Netcom Customer:
A Message about SPAM - unsolicited bulk E-mail/netnews
Because you chose to be an Internet user, you know that the value you
receive from the network lies both in the number of people who are
connected to the Internet and in your ability to send and receive E-mail
from all those people or to read a thread of interest within a newsgroup.
Today the Internet, made up of Netcom's network and the networks of
thousands of other network operators, is being inundated with millions of
transmissions that are unsolicited bulk E-mail or netnews. This type of
message, frequently called SPAM, is like receiving an undesired direct
marketing mailing you didn?t sign-up to receive. Most of these messages
are unsolicited. The volume of these messages makes it difficult for you to
send and receive desired mail and for Netcom to operate a reliable network
for your use.
Over the years, Netcom has taken many steps to provide you the type of
service that you so desire. From our earliest days as a provider of a
shared Unix-system, Netcom's contracts with you have forbidden unsolicited
bulk traffic on our network or through our servers. In 1994 our policies
were widely discussed among the Internet community and the press when we
terminated the accounts of some notorious network abusers. Today the
problem is getting worse and we want to tell you what we are doing to
lessen the impact of SPAM on or through the Netcom network.
Our aggressive approach to combating SPAM E-mail and netnews include:
* Quickly reacting to complaints about SPAM coming from our network. We
have a group of trained technical support people who investigate these
complaints. We strictly enforce the anti-SPAM provisions in our Terms and
Conditions and we are continuing to change them to reflect abuses that were
not initially spelled out explicitly. Under these contracts, we can (and
do) terminate the accounts of confirmed offenders. We may also post
information about the disciplinary action to network administrator
newsgroups and mailing lists and to a webpage
* Based on information in the message header , intercepting and blocking
E-mail from known SPAM sites from or to the Netcom mail servers. We also
block multiple, identical messages from being sent
* Blocking postings of identical messages to multiple newsgroups
Our fight against SPAM may affect you in the following way. The Netcom Unix
Shell systems may no longer be used to relay E-mail or to support SMTP
services for client hosts. This means Netcom's shell systems will not send
E-mail for any domain other than netcom.com. Netcom shell customers will
be able to send mail by using an interactive session on the Netcom servers.
Shell customers may continue to connect to a Post Office Protocol (POP)
server to receive their E-mail. Having the Shell systems open for mail
relay allows those systems to be abused by SPAMMERs netwide. Therefore, we
must close down the relay service. We suggest that you look into the other
Netcom services to see if one of those services may fit your needs better.
When you notice network abuse from a Netcom customer, we'd like to know.
Please send a copy of the E-mail or the Usenet news posting with full
message header information to abuse@netcom.com. You can also call Netcom
Technical Support at 408-881-1810.
If you'd like more information about Netcom's Terms and Conditions of
Service and Acceptable Use Guidelines, please visit the following sites:
For Netcom's Terms and Conditions:
http://www.netcom.com/netcom/terms.html
For Netcom's Acceptable Use Guidelines:
http://www.netcom.com/netcom/aug.html
Netcom takes its creditability as a reliable, responsible provider of
Internetworking services, very seriously. Working together with you, our
responsible customers, with other network providers, within our trade
associations, and with law enforcement agencies, we can combat this problem
so that we can all enjoy the benefits of being connected to the Internet.
If you have further questions, please send them to support@netcom.com. We
appreciate your business.
Sincerely,
Dave Garrison
Chairman and CEO
------------------------------
Date: 5 Mar 1998 17:29:52 -0500
From: Cliff Heller <fnord@panix.com>
Subject: Re: In defense of Netcom
Message-Id: <upsoowbwkh.fsf@panix3.panix.com>
bkhilton@netcom.com (Brand and Karina Hilton) writes:
> Netcom appears to be making more of an effort to deter
> spammers. We received the following email yesterday:
Sorry. They still expressly refuse to shut down their website customers
who spam from throwaway accounts on other ISPs.
Read: Netcom provides a safe haven for spammers.
Read: Netcom encourages the abuse of other networks.
See news.admin.net-abuse.email for detailed discussions of netcom's
pathetic spam policies.
They may be taking steps, but they have a *lot* further to go before they
come out of my filters.
------------------------------
Date: 5 Mar 1998 22:55:05 GMT
From: Zenin <zenin@best.com>
Subject: Re: In defense of Netcom
Message-Id: <889138842.523521@thrush.omix.com>
Brand and Karina Hilton <bkhilton@netcom.com> wrote:
>snip<
: Netcom appears to be making more of an effort to deter
: spammers. We received the following email yesterday:
Yes, but not enough (IMHO). Isn't Netcom still under
a UDP (Usenet Death Penalty) action?
--
-Zenin
zenin@best.com
------------------------------
Date: 5 Mar 1998 23:05:29 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: in the name of Baby Jesus PLEASE HELP ME...
Message-Id: <6dnb3p$lq2$2@client2.news.psi.net>
Aditya (mishra.aditya@emeryworld.com) wrote on 1647 September 1993 in
<URL: news:6dmrm8$pdo@ljcqs003.cnf.com>:
++
++ If you are a prisoner of the Evil Empire and your dummy.exe resides in
++ c:\tmp the
++ command would be
++ system("c:\tmp\dummy.exe")
I don't think so. (A *tab* in the second position?)
system "c:/tmp/dummy.exe"; works fine, even on MS systems.
Abigail
--
perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT
------------------------------
Date: 5 Mar 1998 22:07:19 GMT
From: mwang@alhena.ibk.ml.com (Michael Wang)
Subject: Re: ksh2perl converter?
Message-Id: <6dn7mn$3br$1@news.ml.com>
Ed Overton <saseao@unx.sas.junkmail.com> wrote:
>Hi all,
> I'm looking for a ksh to perl converter. I've got quite a number of ksh
>scripts that I'll need to convert, and I'd rather not write a converter
>myself...
>
>Thanks in advance,
Perl is not a superset of KSH, there are things that KSH
can do and Perl can not.
For example, ksh "select" function and its terminal management
as illustrated below:
#!/bin/ksh
PS3='yes sir?'
select i in a b c d e f g food good wood mood a b c d e f g food good wood mood a b c d e f g food good wood mood a b c d e f g food good wood mood a b c d e f g food good wood mood a b c d e g hh jj \
a b c d e f g food good wood mood a b c d e f g food good wood mood a b c d \
g food good wood mood a b c d e f g food good wood mood a b c d e f g food good wood mood \
g food good wood mood a b c d e f g food good wood mood a b c d e f g food good wood mood \
a b c d e g hh jj \
a b c d e f g food good wood mood a b c d e f g food good wood mood a b c d \
g food good wood mood a b c d e f g food good wood mood a b c d e f g food good wood mood \
a b c d e f g food good wood mood a b c d e f g food good wood mood a b c d \
g food good wood mood a b c d e f g food good wood mood a b c d e f g food good wood mood \
g food good wood mood a b c d e f g food good wood mood a b c d e f g food good wood mood \
a b c d e g hh jj \
a b c d e f g food good wood mood a b c d e f g food good wood mood a b c d \
g food good wood mood a b c d e f g food good wood mood a b c d e f g food good wood mood
do
echo $i
break
done
------------------------------
Date: Thu, 05 Mar 1998 22:16:33 GMT
From: dkw0@cdc.gov (David Wall)
Subject: Re: Length of an array?
Message-Id: <6dn8hh$mkl5@cdc4.cdc.gov>
In article <34FF06F2.BBD8C16F@bigsky.net>, "Keith L. Miller" <miller@bigsky.net> wrote:
>If I have a string stored in $_ and I split it into an array, how can I
>know what the length of the array (how many fields there are in the
>array)?
try
perl -e "$a=split(/ /,'$a is 3'); print $a"
or
perl -e "$a=scalar ('$a','is','3'); print $a"
And if I'm getting the swing of things correctly, these two one-liners are
just about equivalent, except for the split. In both cases, I'm forcing a
list into a scalar context.
The gurus around here can doubtless come up with even more clever examples.
Of course, they'd also tell you to look it up in a book or FAQ. Being a
novice myself, that's what I did, 'cause I didn't know the answer until you
asked.
David Wall
------------------------------
Date: Thu, 05 Mar 1998 16:28:03 -0600
From: Glenn Manuel <gmanuel@ti.com>
Subject: local/global var question
Message-Id: <34FF26F3.888@ti.com>
I'm trying to understand part of a CGI script I found.
I've simplified it below.
A local variable is declared in a subroutine,
and accessed from outside of the subroutine.
The original is the first line.
I tried many other permutations, with mixed results,
as noted in the comments.
I am using Perl 5.001, but I suspect the original was
written for Perl 4 because it uses "local".
Can someone explain why a local variable
can be accessed globally, and why assigning
the empty list of subroutine args makes a difference ???
#!/usr/local/bin/perl
sub sub1 {
local (*in) = @_ if @_; # ORIGINAL. allows global access
# local (*in); # does NOT allow global access
# local (@in) = @_ if @_; # allows global access
# local (@in); # allows global access
# local (%in) = @_ if @_; # allows global access
# local (%in); # does NOT allow global access
# local ($in) = @_ if @_; # allows global access
# local ($in); # allows global access
# my (*in) = @_ if @_; # error
# my (*in); # error
# my (@in) = @_ if @_; # allows global access
# my (@in); # allows global access
# my (%in) = @_ if @_; # does NOT allow global access
# my (%in); # does NOT allow global access
# my ($in) = @_ if @_; # allows global access
# my ($in); # allows global access
$in{'foo'} = "bar";
print "Local: $in{'foo'}\n";
}
&sub1;
print "Global: $in{'foo'}\n";
# The End
--
Glenn Manuel
Raytheon Systems (formerly Texas Instruments) Dallas, TX
------------------------------
Date: Thu, 5 Mar 1998 15:56:12 -0800
From: "Mishra, Aditya" <mishra.aditya@emeryworld.com>
Subject: Re: local/global var question
Message-Id: <6dnc35$1u92@ljcqs003.cnf.com>
>Can someone explain why a local variable
>can be accessed globally, and why assigning
>the empty list of subroutine args makes a difference ???
Well , the only truly local variables are "my" variables or lexical
variables.
all others are global or pseudo - local
------------------------------
Date: Thu, 5 Mar 1998 20:30:56 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: padding a file -- Better way??
Message-Id: <EpD4zL.41o@world.std.com>
Douglas Cordero <dcordero@giss.nasa.gov> writes:
> @paddedval = (@paddedval, sprintf "%-80.80s", $_ );
It would be much more efficient to push() the new element onto the
array rather than making a copy, adding a new element to it, and
throwing away the original.
push @paddedval, sprintf "%-80.80s", $_;
and I guess another way to say it would be to use pack instead of sprintf:
push @paddedval, pack 'A80', $_;
I guess I'd just replace the entire padder subroutine with:
@padded = map { pack 'A80', $_ } @unpadded;
--
Andrew Langmead
------------------------------
Date: 05 Mar 1998 16:22:54 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Perl FAQ Error...
Message-Id: <soowzvbl.fsf@news.concentric.net>
Steve Wells <steve@prilnari.com> writes:
> The last line doesn't have an closing / or an ending ).
True enough, though in my pods the punctuation is correct. I can only
guess that there's some glitch in whatever version of pod2html was
used to convert the one to the other. I think perlbug might be the
way to go, though I'm sure one of the gurus will spank me now.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
Butt held high.
------------------------------
Date: Thu, 05 Mar 1998 17:18:57 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Perl Purify'd?
Message-Id: <34FF24D1.17CA@min.net>
John Porter wrote:
>
> Q: has perl been Purify'd? I sure hope so...
If I had posted this question on comp.lang.perl.wizards,
I would have gotten severely scorched for not looking
at the distribution, especially the Changes file and
sv.c. I find that at least Tim and Chip have dealt with
Purify issues.
John Porter
------------------------------
Date: Thu, 05 Mar 1998 17:53:29 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Perl QRG(Quick Reference Guide)
Message-Id: <34FF2CE9.E55@min.net>
David Wall wrote:
>
> (Yea, I know, it's free on the net, but I don't have a postscript printer,
> and I'm too lazy to print it some other way when there's such a cute little
> booklet available.)
Well, I printed it on a postscript printer, and I am thoroughly
impressed. I might just send Johan a few gilders anyway, out of
gratitude!
John Porter
------------------------------
Date: Thu, 05 Mar 1998 22:40:36 GMT
From: meet@the.zoo (dave)
Subject: Portable I/O Multiplexing
Message-Id: <34ff284b.8674190@news.isoc.net>
I'm trying to have Perl read both STDIN and a tcp socket in a loop.
How should this be done so that the same script works on System 5
Unix (HPUX), Windows 95 and Windows NT?
Thanks,
Dave
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dlripberXisoc.net (sub X with shunned char)
http://www.isoc.net/dlripber
/--\./==\./ee\./oo\./--\
------------------------------
Date: 5 Mar 1998 17:55:01 -0500
From: kcohen@julius.ling.ohio-state.edu (Kevin B Cohen)
Subject: problems with one-liners on the command line
Message-Id: <6dnag5$fcv@julius.ling.ohio-state.edu>
i've never been able to get the hang of running one-liners on the
command line (much less the >1-liners that apparently are possible!).
i can pull off a substitution (thanks to tchrist) with something like
perl -pi.bak -e s/foo/bar/g; myfile.txt
but i can't manage much else. i'm trying to do a little grep-like
operation---say, finding and printing any word in a one-word-per-line
file that contains "ea" followed by 1 to 3 consonants. here's a bunch
of stuff that DOESN'T work:
perl -p -e /ea.{1,3}/ && print $_; lexicon.txt
perl -p -e m/ea.{1.3}/ && print $_; lexicon.txt
perl -p -e if(m/ea.{1,3}/) {print $_; } lexicon.txt
perl -p -e if(m/ea{1,3}/) {print $_ }; lexicon.txt
perl -p -e if(m/ea{1,3}/) {print $_; }; lexicon.txt
perl -p -e if(m/ea{1,3}/) {print $_ } lexicon.txt
so, those are my attempts at one-liners. i can't even imagine a
multi-line attempt; when would it start running??
kevin
------------------------------
Date: Thu, 5 Mar 1998 15:57:38 -0800
From: "Mishra, Aditya" <mishra.aditya@emeryworld.com>
Subject: Re: problems with one-liners on the command line
Message-Id: <6dnc5r$1acs@ljcqs003.cnf.com>
enclose your mini-perl script in quotes
Adi
------------------------------
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 2036
**************************************