[9802] in Perl-Users-Digest
Perl-Users Digest, Issue: 3395 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 7 23:07:16 1998
Date: Fri, 7 Aug 98 20:00:23 -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 Fri, 7 Aug 1998 Volume: 8 Number: 3395
Today's topics:
Re: Autoincrement with hashes maryesme@hotmail.com
Re: Autoincrement with hashes <jdf@pobox.com>
Re: c.l.p.moderated: not much traffic? (Nathan V. Patwardhan)
clp.misc etiquette question <mpersico@erols.com>
Re: comp.lang.perl.announce redux lvirden@cas.org
Re: Disrib. with other apps? <foursuns@inetport.com>
Re: File Info (Larry Rosler)
Re: Good Book? lvirden@cas.org
Re: HELP WANTED: Problems with Servers Side Includes (S (Bob Trieger)
Re: hiding user input <rra@stanford.edu>
Re: Intriguing coderef question (Sitaram Chamarty)
Re: math error (M.J.T. Guy)
Re: MSDEV & OLE Automation <nospam.shardy@seanet.com>
Re: ODBC, Perl, Unix and Macs (William Burrow)
Re: Perl 'beutifier' <mpersico@erols.com>
Re: Perl 'beutifier' <mooneer@themall.net>
Re: Perl Docs.. forget the original post (M.J.T. Guy)
Re: perlfaq - frequently asked questions about Perl (pa lvirden@cas.org
Re: Please help! (Larry Rosler)
Re: Please help! (Andre L.)
Quick Stupid Question. <randy@stonemarche.org>
Re: Quick Stupid Question. (Larry Rosler)
Re: Quick Stupid Question. <mpersico@erols.com>
Re: Quick Stupid Question. <perlguy@inlink.com>
Re: Quick Stupid Question. <mooneer@themall.net>
Re: Quick Stupid Question. (Craig Berry)
Re: Quick Stupid Question. <randy@stonemarche.org>
Re: re first language <mpersico@erols.com>
Re: Scoping Question sneaker@fccj.org
Re: Set-Cookie <donatla@ix.netcom.com>
Re: Set-Cookie (brian d foy)
Re: Set-Cookie (Kelly Hirano)
Re: Socket & Storable don't mix? and a Tk question too. <fecund@fatnet.net>
Re: Socket & Storable don't mix? and a Tk question too. <fecund@fatnet.net>
Re: Socket & Storable don't mix? (Nem W Schlecht)
Re: variable indirection (Larry Rosler)
Re: variable indirection (M.J.T. Guy)
Re: variable indirection (Larry Rosler)
Re: WANTED: Free Homepage Script <perlguy@inlink.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 08 Aug 1998 00:44:50 GMT
From: maryesme@hotmail.com
Subject: Re: Autoincrement with hashes
Message-Id: <6qg722$6q6$1@nnrp1.dejanews.com>
Thanks to everyone for making this all clearer to me.
Now I get what this is doing. The statement is actually within a loop that
reinterates through a hash of (references to) arrays. It does this to make
one big hash of the elements of those arrays.
Anyway, the statement
grep($ALL_FIELDS{$_}++, @$_);
The $_'s are two different values. The $_ in @$_ points to the value
returned by the foreach loop that is around this statement (for the complete
code, see: http://www.wiley.com/compbooks/stein/text/loan.txt -- a link I
should have provided before). The $_ in the $ALL_FIELDS hash is the value
"plucked" off the @$_ array. It simply increments the value of the value
that goes with that key, bringing a non-existant one into being (I have used
count++ this way before and just didn't see it this time).
The examples I had seen in the FAQ were of this form:
@out = grep(!$whatever{$_}++, @in);
The element of @in gets shipped off to @out only the first time, because the
second time the expression !$whatever{$_}++ evaluates to false as
$whatever{'whatever this value is the second time around'} already exists the
second time around.
Do I got it????
If I do, thanks a million. If not, feel free to put me in my place.
Mark :)
In article <6qfdbh$34j@mozo.cc.purdue.edu>,
gebis@fee.ecn.purdue.edu (Michael J Gebis) wrote:
> Jonathan Feinberg <jdf@pobox.com> writes:
> } foreach (@$_) { $ALL_FIELDS{$_}++ }
>
> }It's a common idiom for autovivifying hash elements. If $h{foo}
> }doesn't exist, then the phrase $h{foo}++ will bring it into existance.
> }The fact that its value is now 1 is immaterial. If we run into foo
> }again, the value will increase, but it's only the existance of the key
> }foo that interests us.
>
> I think Jonathan means, "The value is the number of times the element
> appeared in the original array, and thus is sometimes indispensible."
> :)
>
> --
> Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 07 Aug 1998 21:25:53 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: maryesme@hotmail.com
Subject: Re: Autoincrement with hashes
Message-Id: <iuk4us3y.fsf@mailhost.panix.com>
maryesme@hotmail.com writes:
> Do I got it????
On the nose.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf/
------------------------------
Date: 8 Aug 1998 01:01:44 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: c.l.p.moderated: not much traffic?
Message-Id: <6qg81o$j84@fridge.shore.net>
Gabor (gabor@vmunix.com) wrote:
: 'trickle' to you. I think it's great to be able to read carefully all
: the posts, though I have noticed a flame war already brewing between the
: old guard in the group. :(
<wear blanket="warm">
*sigh*
Yeah, just like the good, 'ol days.
</wear>
--
Nate Patwardhan|root@localhost
"Fortunately, I prefer to believe that we're all really just trapped in a
P.K. Dick book laced with Lovecraft, and this awful Terror Out of Cambridge
shall by the light of day evaporate, leaving nothing but good intentions in
its stead." Tom Christiansen in <6k02ha$hq6$3@csnews.cs.colorado.edu>
------------------------------
Date: Fri, 07 Aug 1998 22:15:49 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: clp.misc etiquette question
Message-Id: <35CBB4D5.F10F12C3@erols.com>
When the answer to a question posed here is conceptually:
perldoc yadayady | grep conceptInQuestion
what is the general feeling in the group about posting the answer and/or
mailing the answer?
My take is this:
Posting such a simple question wastes bandwidth, makes yet another
thread to have to skip.
OTHOH, posting the answer may make another person not post such a simple
answer. The personal response may be habit fomring and encourage the
posting more FAQ questions. Unless the mailed answer contained the ***
FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! text.
Is that too obnoxious to do?
--
#!/usr/bin/perl -- Matthew O. Persico
print "Just Another Perl Neophyte\n";
## Simplicity is a blessing when you're
## supporting the program at 2AM
------------------------------
Date: 8 Aug 1998 01:47:26 GMT
From: lvirden@cas.org
Subject: Re: comp.lang.perl.announce redux
Message-Id: <6qgane$l32$1@srv38s4u.cas.org>
According to Nathan Torkington <gnat@frii.com>:
:FAQ? Tom and I obviously don't think so, as we're now going back and
:merging into the FAQ things we learned and developed during the
:writing of the Cookbook.
That's great to hear. In another newsgroup I occasionally use, the faq
keeper wrote a book around his excellent faq, expanding the info greatly.
The unfortunate thing is that since that book came out, the faq has not
changed - and it's been almost 2 years. Now, it's very possible I guess
that no new questions about the language in question have been frequently
appearing in the past two years, but it seems rather unlikely.
It's great to know that the excellent perl FAQs continue to improve.
--
<URL:mailto:lvirden@cas.org> Quote: In heaven, there is no panic,
<*> O- <URL:http://www.teraform.com/%7Elvirden/> only planning.
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.
------------------------------
Date: Fri, 7 Aug 1998 19:04:50 -0500
From: "Steve Serrell" <foursuns@inetport.com>
Subject: Re: Disrib. with other apps?
Message-Id: <6qg4oa$jpi$1@news13.ispnews.com>
Andrew M. Langmead wrote in message ...
>"Steve Serrell" <foursuns@inetport.com> writes:
>
>>What would be the legal issues of distributing perl 5.0 with an
application
>>written in C++, This application would cost money, and among other things,
>>offers the user the ability to run PERL scripts.
>
>If I were you, I'd start with the file named "Artistic" in the perl
>distibution and read it. Then, if there are any issues that you want
>clarified, consult a legal professional.
Thank you Andrew, this is what I call usefull info.
>Do you think it is really a bright idea to trust your business to what
>people on Usenet tell you?
Do you think it is a really bright assumption to equate automatic
trust with inquery?
>It seems to me that the requirements of the license will affect you
>differntly depending on whether you are just including an unmodified
>copy of the standard perl package with your software (aggregation), or
>producing a modifed version of perl.
>
>When heading out to see your lawyer, don't worry too much. I've always
>had the feeling that Perl's Artistic license is more concerned about
>the copyright holder retaining control over what is called "Perl", and
>preventing confusion by anyone receiving something that is supposed to
>be "Perl", over any worry about whether you will or won't make a
>zillion dollars from it.
Thanks for your feedback and your feelings...
Steve
------------------------------
Date: Fri, 7 Aug 1998 17:38:07 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: File Info
Message-Id: <MPG.10353dcc418e2268989759@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <1vdfq6.ls3.ln@localhost> on Fri, 7 Aug 1998 12:36:33 -0500,
Tad McClellan <tadmc@metronet.com> says...
> Darren Ferguson (Darren@introdesign.com) wrote:
> : Does anyone have a couple of quick lines of Perl to demonstrate
> : how to get info on a file size, permissions and creation date?
...\
> Creation date is *impossible* as it is not saved anywhere
> with Unix style filesystems.
>
> Maybe you meant "change date" instead?
(stat)[10] [ctime] is documented as "inode change time (NOT creation
time!)" in perlfunc. But on Windows/DOS systems, it really is the
creation time.
Fortunately, ctime or -C covers them both, though not exactly portably.
:-)
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 8 Aug 1998 01:57:54 GMT
From: lvirden@cas.org
Subject: Re: Good Book?
Message-Id: <6qgbb2$m3h$1@srv38s4u.cas.org>
According to Dennis M. Parrott <dparrott@ford.com>:
:Just as a word means exactly what I choose it to mean, nothing
:more and nothing less, a Good Book is one that "learnt ya
:sumthin'", nothing more and nothing less.
Even if the 'sumthin' is wrong? I surely hope that the programmers
I deal with each day don't take this attitude. But perhaps that's why
I spend so much of my day fixing the bugs of others...
--
<URL:mailto:lvirden@cas.org> Quote: In heaven, there is no panic,
<*> O- <URL:http://www.teraform.com/%7Elvirden/> only planning.
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.
------------------------------
Date: Sat, 08 Aug 1998 02:19:53 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: HELP WANTED: Problems with Servers Side Includes (SSI) on IIS 4.
Message-Id: <6qgcpl$q19$1@ligarius.ultra.net>
[ posted and mailed ]
"Ronald van Gogh" <Ronald.vanGogh@nl.origin-it.com> wrote:
-> If i run the perl script manually i see no problems.
Then why are you posting to a perl group looking for help?
Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-400-1972
Ext: 1949 and let the jerk that answers know
that his toll free number was sent as spam. "
------------------------------
Date: 07 Aug 1998 17:45:44 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: hiding user input
Message-Id: <m3r9yscnd3.fsf@windlord.Stanford.EDU>
Chris Nandor <pudge@pobox.com> writes:
> Russ Allbery <rra@stanford.edu> wrote:
>> It is generally considered to be good manners, if you are maintaining
>> an archive of any sort, to honor the X-No-Archive header. Something
>> along those lines is likely to be put into the next revision of the
>> news standards, after which point if you were maintaining a publically
>> accessible archive and did not honor the header, and this caused
>> problems for someone, it's quite likely you could be sued and would
>> lose.
> Not a chance. RFCs do not laws make. I would contend that it is not
> possible to make a constitutional law that would disallow me from
> keeping a public archive of everything ever posted to any or all
> newsgroups. The post is by definition public once it is posted. What
> makes it legal for me to keep it on my news server for a month, but
> illegal to keep it on my web server for a year or more? I'd hate to see
> a draft of such legislation, because it would be nonsensical.
It doesn't need new legislation. It's the case right now. It's called
the Berne Copyright Convention.
Everything I write is copyrighted. Everything. Including posts to
Usenet. If you take a post that I write to Usenet and republish it as a
book and make money off of it without paying me, I can sue you for your
profits, and I'll stand a very good chance of winning.
This isn't exactly an unknown issue. I moderate a fiction newsgroup. You
think that a short story magazine would just take short stories off that
newsgroup and republish them without giving royalties to the authors and
expect *not* to be sued? Think again.
The way these things almost invariably work is that the court would apply
a reasonable person's standard. What does the average poster to Usenet
*expect* to happen to their message? An X-No-Archive header, if that is
widely known and accepted, is a pretty clear-cut statement of expectation.
And people *own* what they post. Violate reasonable person expectations
with your archive and you *are* opening yourself up for legal problems.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: 8 Aug 1998 00:06:09 GMT
From: sitaram@diac.com (Sitaram Chamarty)
Subject: Re: Intriguing coderef question
Message-Id: <slrn6sm8f6.j4q.sitaram@diac.com>
On Thu, 06 Aug 1998 11:57:14 -0400, Aravind Subramanian
<aravind@genome.wi.mit.edu> wrote:
>The need for this is that the code in the anon subroutine is dynamically
>generated and I'd like the users to see the results of the code as well
>as the code itself.
If it is dynamically generated it should be even easier to print
it. At some point you are doing an eval of some string - just
print that string before eval-ing it, and you're done.
On the other hand, you cannot do this with:
> $coderef = sub { print "Boink!\n"; };
------------------------------
Date: 8 Aug 1998 00:54:38 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: math error
Message-Id: <6qg7ke$lkm$1@pegasus.csx.cam.ac.uk>
Tom Bridgwater <T.Bridgwater@mindgear.com> wrote:
>I've come across a strange problem with integer vs. floating point math
>that seems like Perl 5.004 isn't handling correctly. The increment in
>the following code doesn't work under certain circumstanes. I haven't
>been able to pinpoint those circumstances exactly, but the code suggests
>paramaters which do illustrate the problem.
You're failing to understand the nature of floating point arithmetic
and rounding errors. The first entry in perldoc perlfaq4 is
relevant.
Mike Guy
------------------------------
Date: Fri, 7 Aug 1998 06:45:44 -0700
From: "steve hardy" <nospam.shardy@seanet.com>
Subject: Re: MSDEV & OLE Automation
Message-Id: <#kYAJngw9GA.58@uppssnewspub05.moswest.msn.net>
hint: it's probably a scheduler security context problem.
have you seen "Troubleshooting AT Command Using /k Switch"
(http://support.microsoft.com/support/kb/articles/q142/0/40.asp)?
steve
eoloughlin@my-dejanews.com wrote in message
<6qc133$4is$1@nnrp1.dejanews.com>...
>Hi,
>
>I'm trying to get a nightly build running by starting MSDEV from a perl
>script using OLE automation. The script works fine when run interactively
but
>when run via the 'at' command, MSDEV throws up an error dialog that tells
me
>there's been a 'runtime error!' and nothing else.
>
>My scheduler service is running with administrator privileges and the job
is
>submitted with the /interactive switch. I don't think the problem is with
the
>perl script - everything's fine when run from the command line.
>
>Any help would be most appreciated - I've no idea what exactly is wrong
with
>DevStudio and it doesn't seem to create a log file or send anything to the
>event log.
>
>Thanks,
>Ed O'Loughlin.
>
>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
>
------------------------------
Date: 8 Aug 1998 01:05:14 GMT
From: aa126@NOSPAM.fan.nb.ca (William Burrow)
Subject: Re: ODBC, Perl, Unix and Macs
Message-Id: <slrn6sn925.6i5.aa126@fan1.fan.nb.ca>
On Fri, 07 Aug 1998 14:52:00 -0400,
Chris Nandor <pudge@pobox.com> wrote:
>In article <35cb3838.0@news.new-era.net>, scott@softbase.com wrote:
>
># Forget it! FileMaker may be geting a revamp, but there's no way it will
># be able to compete with Oracle and DB2 on the high end as a networked
># database. You're not going to be able to access a Mac database from a
># UNIX box without a lot of pain and lots and lots of money for
># middleware connectivity products.
Just to clear the air here, the Unix box is not in any way near the Mac
box. I develop CGI on the Unix box and port it to the Mac box. With
Perl, this is a pretty seamless process. The intent was to develop CGI
for the Mac that talks with the FileMaker db on the Mac. Development
would be done on the Unix box.
>Anyway, someone does need to write a FileMaker module, but once thatis
>done, then it would be fairly simple and painless (aside from performance)
>to write a daemon to pass queries from client to database and back. Most
>likely, it would be done with Apple Events, which adds additional
>performance pains, but sometimes performance is not an issue as much as
>just getting the data.
I get the impression that accessing the FileMaker db from Perl now is not
possible, and developing it on the Unix box would not be feasible anyway?
After a couple of days actually using the Mac web server while it was
in use, and some comments on the Mac server newsgroup, I get the
impression that Mac CGI (which also uses Apple Events) kinda sucks.
The entire machine stops when the webserver is serving pages, when a
CGI process runs or any number of things. Unix forever. :)
--
William Burrow, VE9WIL -- New Brunswick, Canada o
Copyright 1998 William Burrow ~ /\
~ ()>()
------------------------------
Date: Fri, 07 Aug 1998 22:03:42 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: Re: Perl 'beutifier'
Message-Id: <35CBB1FE.669C37F0@erols.com>
Steve Linberg wrote:
>
> Pish-posh! The best way to format your code the way you want to is to do
> it yourself in the first place. Go through your old code and clean it
> up! :)
>
But when yuo do go through it, use [X]emacs wit cperl-mode and let it do
all the work! <grin>
--
#!/usr/bin/perl -- Matthew O. Persico
print "Just Another Perl Neophyte\n";
## Simplicity is a blessing when you're
## supporting the program at 2AM
------------------------------
Date: Fri, 7 Aug 1998 19:01:29 -0700
From: "Mooneer Salem" <mooneer@themall.net>
Subject: Re: Perl 'beutifier'
Message-Id: <6qgc0m$9ii$2@ash.prod.itd.earthlink.net>
I ran some code from my site, HyperNetMsg, into the Perl beautifier,
but it barely did any modification (it just increased the number of lines
by 5 and reduced the byte count by 50 bytes). It's not worth it. I recommend
that you clean it up manually.
Mooneer Salem
http://hypernetmsg.hypermart.net
Tk Soh wrote in message <35CB26C5.D4697D54@email.sps.mot.com>...
>Does anybody know of any perl script 'formatting' utility (preferably
>also a perl script itself) that would help me rearrange (with proper
>indentation) some of the badly-written perl programs that I inherited
>from others.
>
>You know how it feels like when trying to hack through that kind of
>codes (perhaps that disqualified me as a hacker).
>
>-TK
>
>------------
>TK Soh
>r28269@email.sps.mot.com
------------------------------
Date: 8 Aug 1998 00:45:32 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Perl Docs.. forget the original post
Message-Id: <6qg73c$l9l$1@pegasus.csx.cam.ac.uk>
Bart Lateur <bart.mediamind@tornado.be> wrote:
>
>Now that smells like a horrible justification for conservatism.
>
>"The PODs are great because WE wrote them."
>
>Doesn't that sound just a little off?
You've not got that quite right. It should be
"The PODs are no better than they are because YOU haven't provided
patches to improve them."
The theme tune of perl5-porters is "Patches always welcome". Anyone
can contribute. See the file Porting/patching.pod in the Perl
distribution for more details.
Mike Guy
------------------------------
Date: 8 Aug 1998 02:17:27 GMT
From: lvirden@cas.org
Subject: Re: perlfaq - frequently asked questions about Perl (part 0 of 9)
Message-Id: <6qgcfn$na7$1@srv38s4u.cas.org>
According to Curtis Jewell / Dennis Whalen <cjdpcssd@ims-1.com>:
:What about those unlucky ones who do not have a man (Win32, Mac)? I've been
:looking for a man variant at all (much less that RUNS) on Win95 for a YEAR.
Perhaps if you report what goes wrong when you run the man perl script,
someone could help you debug it on your platform.
--
<URL:mailto:lvirden@cas.org> Quote: In heaven, there is no panic,
<*> O- <URL:http://www.teraform.com/%7Elvirden/> only planning.
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.
------------------------------
Date: Fri, 7 Aug 1998 17:58:09 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Please help!
Message-Id: <MPG.10354277c402362298975a@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <XcHy1.3787$JR2.5619454@nntpserver.swip.net> on Fri, 07 Aug
1998 17:56:07 GMT, Jonah Olsson <jonah@g-s.net> says...
...
> In my chat system everything is logged and feeded into a file where each
> block of data (name, time, text etc.) starts and ends with %%%.
>
> When printing each block I open the file into a string like this:
>
> open (CHAT, "$datafile") || die "The chat will should be back soon! ($!)\n";
> local $/;
> $chat = <CHAT>;
> close (CHAT);
>
> But how should I search for the blocks starting and ending with %%%? Is it
> better to use an array?
Everyone else who answered has made heavy work out of this. My choice
would be simpler.
{
local $/ = '%%%';
while (<CHAT>)
{ do something with the chunk delimited by '%%%', now in $_ }
}
If you omit the outer curlies, you may regret it later on!
If each chunk both begins and ends with '%%%', you can toss out the empty
chunks.
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 07 Aug 1998 22:32:27 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Please help!
Message-Id: <alecler-0708982232270001@dialup-820.hip.cam.org>
In article <6qfnir$16j@handupme.avid.com>, alastair@psoft.co.uk wrote:
> Jonah Olsson <jonah@g-s.net> wrote:
[...]
> >open (CHAT, "$datafile") || die "The chat will should be back soon! ($!)\n";
> > local $/;
> > $chat = <CHAT>;
> >close (CHAT);
[...]
> Further to that, I'm not sure why you bother using the '$/' here. I
> think if you want to slurp in the whole file you need to undef the
> current value of $/.
That's what "local $/" does, with the added advantage that the undefed $/
is scoped to the enclosing block, reverting to its previous value
afterward.
Andre
------------------------------
Date: Fri, 7 Aug 1998 21:30:16 -0400
From: "Randy Perryman" <randy@stonemarche.org>
Subject: Quick Stupid Question.
Message-Id: <6qg9qt$8lo$1@pyrite.mv.net>
I have a stupid one.
How do you strip the leading character of String. I know 'CHOP' and 'CHOMP'
for the end, but how do you do the reverse..
What I have is something like this
$count=[430;
How do I make it into just '430'
Thanks
Randy
------------------------------
Date: Fri, 7 Aug 1998 18:52:27 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Quick Stupid Question.
Message-Id: <MPG.10354f3aeec29a7c98975c@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <6qg9qt$8lo$1@pyrite.mv.net> on Fri, 7 Aug 1998 21:30:16 -
0400, Randy Perryman <randy@stonemarche.org> says...
...
> $count=[430;
> How do I make it into just '430'
$count = substr $count, 1;
is the fastest. This also works:
$count =~ s/.//;
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 07 Aug 1998 22:05:06 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
To: Randy Perryman <randy@stonemarche.org>
Subject: Re: Quick Stupid Question.
Message-Id: <35CBB252.F3B7E490@erols.com>
perldoc perlfunc
search for substr
Randy Perryman wrote:
>
> I have a stupid one.
> How do you strip the leading character of String. I know 'CHOP' and 'CHOMP'
> for the end, but how do you do the reverse..
>
> What I have is something like this
>
> $count=[430;
> How do I make it into just '430'
>
> Thanks
>
> Randy
--
#!/usr/bin/perl -- Matthew O. Persico
print "Just Another Perl Neophyte\n";
## Simplicity is a blessing when you're
## supporting the program at 2AM
------------------------------
Date: Fri, 07 Aug 1998 21:04:40 -0500
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: Quick Stupid Question.
Message-Id: <35CBB238.43203ACB@inlink.com>
Randy Perryman wrote:
>
> I have a stupid one.
> How do you strip the leading character of String. I know 'CHOP' and 'CHOMP'
> for the end, but how do you do the reverse..
>
> What I have is something like this
>
> $count=[430;
> How do I make it into just '430'
>
> Thanks
>
> Randy
Don't know how efficient this is, but it works...
while(<FILE>){
($d,@rest) = split(//,$_);
print @rest;
}
HTH
--
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$ Brent Michalski $
$ E-Mail: perlguy@technologist.com $
$ Web developer, author, nice guy. :-) $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
------------------------------
Date: Fri, 7 Aug 1998 18:56:59 -0700
From: "Mooneer Salem" <mooneer@themall.net>
Subject: Re: Quick Stupid Question.
Message-Id: <6qgc0k$9ii$1@ash.prod.itd.earthlink.net>
Use the following example code to strip the leading character of a string:
$count = '[430';
$count =~ s/^(.)//;
Hope this helps,
Mooneer Salem
http://hypernetmsg.hypermart.net
Randy Perryman wrote in message <6qg9qt$8lo$1@pyrite.mv.net>...
>I have a stupid one.
>How do you strip the leading character of String. I know 'CHOP' and
'CHOMP'
>for the end, but how do you do the reverse..
>
>What I have is something like this
>
>
>$count=[430;
>How do I make it into just '430'
------------------------------
Date: 8 Aug 1998 02:30:30 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Quick Stupid Question.
Message-Id: <6qgd86$hpm$1@marina.cinenet.net>
Randy Perryman (randy@stonemarche.org) wrote:
: I have a stupid one.
: How do you strip the leading character of String. I know 'CHOP' and 'CHOMP'
: for the end, but how do you do the reverse..
Zillions of ways to do it. Two that spring to mind:
$string =~ s/^.//s;
substr($string, 0, 1)) = '';
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Fri, 7 Aug 1998 22:46:02 -0400
From: "Randy Perryman" <randy@stonemarche.org>
Subject: Re: Quick Stupid Question.
Message-Id: <6qge90$a33$1@pyrite.mv.net>
Thanks all....
Randy Perryman wrote in message <6qg9qt$8lo$1@pyrite.mv.net>...
>I have a stupid one.
>How do you strip the leading character of String. I know 'CHOP' and
'CHOMP'
>for the end, but how do you do the reverse..
>
>What I have is something like this
>
>
>$count=[430;
>How do I make it into just '430'
>
>Thanks
>
>Randy
>
>
------------------------------
Date: Fri, 07 Aug 1998 21:56:50 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
To: Simon Wistow <simon@new-mediacom.com>
Subject: Re: re first language
Message-Id: <35CBB062.EA140A5@erols.com>
Simon Wistow wrote:
>
> 3) code written whilst on Jolt cola or drunk is generally better than
> stuff you've been planning on paper for days
Corollary I: The quality of the code you write is inversely proportional
to the distance between the time it is written and the tru midpoint of
time between sunset and sunrise.
Corollary II: The efficency of your coding is inversely proportional to
the distance between the time it is written and the time you absolutely
have to leave the office to catch the train your wife wants you to be
on.
--
#!/usr/bin/perl -- Matthew O. Persico
print "Just Another Perl Neophyte\n";
## Simplicity is a blessing when you're
## supporting the program at 2AM
------------------------------
Date: Sat, 08 Aug 1998 02:08:17 GMT
From: sneaker@fccj.org
Subject: Re: Scoping Question
Message-Id: <6qgbuh$bql$1@nnrp1.dejanews.com>
In article <35CB4E5F.78B7@min.net>,
jdporter@min.net wrote:
> sneaker@fccj.org wrote:
> >
> > open (outfile, "mytest") or die "can't: $!";
> > print outfile;
> >...
> > open (outfile, "mytest") or die "can't: $!";
> > print outfile;
>
> And people give me a hard time for always using
>
> open(F,"< $file")...
> and
> open(F,"> $file")...
>
> --
> John Porter
>
At least you didn't e-mail me :]
I have found the solution to my previous scope question.
-> A good nights sleep <-
Take care :)
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Fri, 7 Aug 1998 20:07:26 -0400
From: "Donald W. McArthur" <donatla@ix.netcom.com>
Subject: Re: Set-Cookie
Message-Id: <6qg4ti$ka1@sjx-ixn6.ix.netcom.com>
mikane,
I think that your statement about printing the Content-type text/html
must come after your statement to print the cookie. Something like:
print "Set-Cookie: VISIT=yes\n";
print "Content-type: text/html\n\n";
Please note the "text/html" must be followed by two newlines.
Don
mikane@shell3.ba.best.com wrote in message
<6qf05f$obn$1@nntp1.ba.best.com>...
>I am trying to send a cookie with the following code but its
>not working, can someone tell me why?
>
>All I get is a page with:
>
>"Set-Cookie: ID=m4lvrt; HOME=usa; expires:Friday, 7-Aug-98 23:48:56 GMT
Hello world"
>
>and no cookie.
>
>Thanks
>
>Mike
>
>
>-----------------------------------------------------------
>#!/bin/perl
>
>print<<NEWPAGE;
>Content-type: text/html
>
>Set-Cookie: ID=m4lvrt; HOME=usa; expires:Friday, 7-Aug-98 23:48:56 GMT
>
><html>
><head>
><title></title></head>
>
>
><body>
>
>Hello world
>
></body>
></html>
>
>
>NEWPAGE
>
>
>
>
>exit;
>
------------------------------
Date: Fri, 07 Aug 1998 20:20:42 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Set-Cookie
Message-Id: <comdog-ya02408000R0708982020420001@news.panix.com>
Keywords: from just another new york perl hacker
In article <6qg4ti$ka1@sjx-ixn6.ix.netcom.com>, "Donald W. McArthur" <donatla@ix.netcom.com> posted:
> I think that your statement about printing the Content-type text/html
>must come after your statement to print the cookie. Something like:
>print "Set-Cookie: VISIT=yes\n";
>print "Content-type: text/html\n\n";
order of headers does not matter.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>
------------------------------
Date: 7 Aug 1998 17:27:55 -0700
From: hirano@Xenon.Stanford.EDU (Kelly Hirano)
Subject: Re: Set-Cookie
Message-Id: <6qg62b$9h1@Xenon.Stanford.EDU>
Keywords: from just another new york perl hacker
In article <comdog-ya02408000R0708982020420001@news.panix.com>,
brian d foy <comdog@computerdog.com> wrote:
>In article <6qg4ti$ka1@sjx-ixn6.ix.netcom.com>, "Donald W. McArthur" <donatla@ix.netcom.com> posted:
>
>> I think that your statement about printing the Content-type text/html
>>must come after your statement to print the cookie. Something like:
>>print "Set-Cookie: VISIT=yes\n";
>>print "Content-type: text/html\n\n";
>
>order of headers does not matter.
they don't matter, but the last header must be followed by two newlines.
--
Kelly William Hirano Stanford Athletics:
hirano@cs.stanford.edu http://www.gostanford.com/
hirano@alumni.stanford.org (WE) BEAT CAL (AGAIN)! 100th BIG GAME: 21-20
------------------------------
Date: Fri, 07 Aug 1998 17:42:09 -0700
From: Yary Hluchan <fecund@fatnet.net>
To: Nem W Schlecht <nem@abattoir.cc.ndsu.nodak.edu>
Subject: Re: Socket & Storable don't mix? and a Tk question too.
Message-Id: <35CB9EE1.6171@fatnet.net>
]Works fine on my IRIX 6.2 box. So.. if you put your print statement before
]the retrieve() call it works fine? I didn't see (vie grep()) anything in
]the source code for Storable mentioning 'inet'.
Whoops, it was nstore- putting print statement before that "fixed" it.
Using store instead of nstore really fixed it. I don't need to be
all that portable.
I've encountered two other problems, that I can't yet distill into simple test
cases:
a) calling "store \%var, 'file.pls'" was giving me an error-
Can't determine type of SCALAR(0xbc129c) at
d:\QFS\BIN\perllib\site/auto/Storable/_store.al line 16, at ./rep_callbacks.pl
line 34
But: calling "Dumper \%var;store \%var, 'file.pls'" works!
b) The code creates several objects, all have a method that takes a Tk frame
and draws some info in them. Some of that info are label-widgets that use
the "textvariable" option. When the objects are newly-created, they work
as I expect. When they are restored via "retrieve", several (but not all)
of the text-variable widgets of several (but not all) objects are tied to the
same variable. It's hard to describe, other than many labels are changing
in unison to the same thing and they shouldn't be.
tricky!
-y
------------------------------
Date: Fri, 07 Aug 1998 18:24:30 -0700
From: Yary Hluchan <fecund@fatnet.net>
Subject: Re: Socket & Storable don't mix? and a Tk question too.
Message-Id: <35CBA8CE.6BDB@fatnet.net>
Bad form to reply to oneself, I am told, and yet...
Found the source of problem b- TK objects being set the same-
turns out it's Storable again! Try this one:
#!perl -w
use strict;
use Storable qw(store retrieve);
my %VAR1 = (
A => bless( {
Message => undef,
RunStatus => undef}, 'Aloha' ),
B => bless( {
Message => undef,
RunStatus => undef}, 'Bienvienu' )
);
my $file = "foo.pls";
store \%VAR1, $file;
my %test = %{ retrieve $file };
$test{A}{RunStatus} = "flub\n";
print $test{B}{Message};
__END__
Looks like on retrieval, all undef's in an object reference the same
undef'd thingie. Setting one sets them all.
So, I'll be sure to init all my class variables to '' or 0.
(What a waste of time... still, glad to have Storable around.)
-y
------------------------------
Date: 7 Aug 1998 19:02:57 -0500
From: nem@abattoir.cc.ndsu.nodak.edu (Nem W Schlecht)
Subject: Re: Socket & Storable don't mix?
Message-Id: <6qg4jh$7e@abattoir.cc.ndsu.nodak.edu>
[courtesy copy e-mailed to author(s)]
In comp.lang.perl.misc, Yary Hluchan <fecund@fatnet.net> wrote:
>Using GS binary distribution (thanks!), WinNT, version 5.004_02:
>
>#!perl -w
>use strict;
>use Socket;
>use Storable qw(nstore retrieve);
>
>my $file = "foo.pls";
>nstore {}, $file;
>my %bar = %{retrieve $file};
>
>print join('.',unpack('CCCC',inet_aton('localhost'))),"\n";
>__END__
>and I get:
>Use of uninitialized value at tst.pl line 10.
Works fine on my IRIX 6.2 box. So.. if you put your print statement before
the retrieve() call it works fine? I didn't see (vie grep()) anything in
the source code for Storable mentioning 'inet'.
--
Nem W Schlecht nem@plains.nodak.edu
NDUS UNIX SysAdmin http://www.nodak.edu/~nem/
"Perl did the magic. I just waved the wand."
------------------------------
Date: Fri, 7 Aug 1998 16:59:45 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: variable indirection
Message-Id: <MPG.103534cf7f562f48989758@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <6qfbqb$ca7$3@marina.cinenet.net> on 7 Aug 1998 16:59:55 GMT,
Craig Berry <cberry@cinenet.net> says...
> Tom Christiansen (tchrist@mox.perl.com) wrote:
> : : $names{"a"} = 'good';
> :
> : Well, that could be single-quotes around the 'a'
> : for the sake of small hobgoblins.
>
> Or no quotes at all, for tiny kobolds. :)
Except if you are using '-w' and you use the single letters 'm', 's', or
'y', or a host of all-lower-case strings. :-(
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 8 Aug 1998 00:29:07 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: variable indirection
Message-Id: <6qg64j$kkj$1@pegasus.csx.cam.ac.uk>
Larry Rosler <lr@hpl.hp.com> wrote:
>Craig Berry <cberry@cinenet.net> says...
>> Or no quotes at all, for tiny kobolds. :)
>
>Except if you are using '-w' and you use the single letters 'm', 's', or
>'y', or a host of all-lower-case strings. :-(
Not in modern Perls (i.e. 5.005+ or 5.004_05+)
Mike Guy
------------------------------
Date: Fri, 7 Aug 1998 18:22:47 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: variable indirection
Message-Id: <MPG.1035483e6ee8430a98975b@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <6qg64j$kkj$1@pegasus.csx.cam.ac.uk> on 8 Aug 1998 00:29:07
GMT, M.J.T. Guy <mjtg@cus.cam.ac.uk> says...
> Larry Rosler <lr@hpl.hp.com> wrote:
> >Craig Berry <cberry@cinenet.net> says...
> >> Or no quotes at all, for tiny kobolds. :)
> >
> >Except if you are using '-w' and you use the single letters 'm', 's', or
> >'y', or a host of all-lower-case strings. :-(
>
> Not in modern Perls (i.e. 5.005+ or 5.004_05+)
When one's programs run on many systems maintained by others, one learns
not to worry too much about "modern" Perls except insofar as they break
things that used to work. And they do break them sometimes!
My programs run on perl 5.002 through 5.004_03. "Modern" Perl is a
theoretical luxury, I fear. I will always have to "code defensively" for
the worst case.
while (defined($line = <FILE>)) { ... }
for example. Warning about needing 'defined' added in 5.004, dropped in
5.005. So what? I will always have to have the 'defined' in my code.
This leads to some pretty weird stuff, like:
{ local $^W = 0 if $] < 5.004; $hash{'may be undefined'} += $n }
whereas simply ++$hash... never got a warning. Sigh...
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 07 Aug 1998 21:05:58 -0500
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: WANTED: Free Homepage Script
Message-Id: <35CBB286.6E899562@inlink.com>
Have you checked http://www.cgi-resources.com ???
That is a good place for scripts. This is a good place for programming
questions...
--
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$ Brent Michalski $
$ E-Mail: perlguy@technologist.com $
$ Web developer, author, nice guy. :-) $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3395
**************************************