[28754] in Perl-Users-Digest
Perl-Users Digest, Issue: 10118 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 4 18:10:20 2007
Date: Thu, 4 Jan 2007 15:10:11 -0800 (PST)
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, 4 Jan 2007 Volume: 10 Number: 10118
Today's topics:
Re: Silly li'l perl script, plx improve. <emschwar@pobox.com>
uninitialized value warnings and run time <juliabell@worldnet.att.net>
Re: uninitialized value warnings and run time <spamtrap@dot-app.org>
Re: uninitialized value warnings and run time <juliabell@worldnet.att.net>
Re: uninitialized value warnings and run time <glex_no-spam@qwest-spam-no.invalid>
Re: Unsecured scripts and site hacking? <john@castleamber.com>
Re: Unsecured scripts and site hacking? <DJStunks@gmail.com>
Re: Unsecured scripts and site hacking? <emschwar@pobox.com>
Re: Unsecured scripts and site hacking? <news@lawshouse.org>
Re: using Perl to find string.. seanjao@yahoo.com
Re: using Perl to find string.. <mritty@gmail.com>
Re: using Perl to find string.. seanjao@yahoo.com
which email module - MIME::LITE, Email::Send, other? <brewsterbear@googlemail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 04 Jan 2007 09:44:24 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Silly li'l perl script, plx improve.
Message-Id: <87tzz691xz.fsf@aragorn.emschwar>
"Klaus" <klaus03@gmail.com> writes:
> Eric Schwartz wrote:
> > if($ARGV[1]){
> > open my $outfile, ">>", $ARGV[1])
> > or die "Couldn't open $ARGV[1] for output: $!";
> > select $outfile;
> > }
> >
> > Note: because $outfile is declared in the if block, you can't refer to
> > it later. If you want to modify the program to use it later, you'll
> > need to declare $outfile outside the loop:
>
> I agree, and I would like to add what I think will happen in the above
> code fragment under the condition that $ARGV[1] is defined and not ""
> and not "0" and not 0:
How about testing what does happen? It probably would have taken you
less time than it took to compose your post. That's not an insult, by
the way-- I'm just pointing out that reality trumps logic by a large
factor.
$ cat /tmp/foo
if ($ARGV[0]) {
open my $outfile, '>', $ARGV[0] or die "couldn't open: $!";
select $outfile;
}
for (0..20_000_000) {
print
}
emschwar@aragorn:~$ perl /tmp/foo /tmp/beh
emschwar@aragorn:~$ cat /tmp/beh
01234567891011121314151617181920212223242526272829303132.....
> - the condition if($ARGV[1]) is true, so we enter the if-branch
> - the file $ARGV[1] is opened as $outfile for output (append)
> - and, given that the open was successful,
> - sets the default to $outfile for all subsequent prints (select)
So far, you're correct.
> - the file $outfile is closed as the scope of the if exits
Where do you get this last assertion? I don't find it anywhere in
perldoc -f open-- in fact, it suggests you use IO::File if you want
the behaviour you're asking for. In this case I cheated, and let the
OS close all open filehandles on exit for me. Yes, it's a bit
naughty, but not enough (in this context only) to keep me up at
nights. Toss in a
close();
at the end if you like.
> Now, for the rest of the program, all subsequent prints fail silently
> because print now defaults to the closed filehandle $outfile.
>
> I did not test the above scenario, but would like to ask anyway:
> Am I right ?
Why didn't you test it? It's very easy to create such a test (see
above, took me about 2 minutes), and you'd have answered your own
question before I even had my morning caffeine.
> > my $outfile;
> > if ($ARGV[1]) {....}
That gives you a filehandle that is accessible in a much larger scope
than you need it. Which is not evil, but I prefer to keep things as
tightly scoped as possible.
-=Eric
------------------------------
Date: 4 Jan 2007 11:45:53 -0800
From: "julia" <juliabell@worldnet.att.net>
Subject: uninitialized value warnings and run time
Message-Id: <1167939953.298526.157390@v33g2000cwv.googlegroups.com>
I'm reviewing a script to try to identify why it takes so ong to
execute.
It generates a lot (thousands) of uninitialized value warnings.
Does not properly initializing variables increase the run-time?
------------------------------
Date: Thu, 04 Jan 2007 16:25:44 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: uninitialized value warnings and run time
Message-Id: <m2zm8y8ox3.fsf@Sherm-Pendleys-Computer.local>
"julia" <juliabell@worldnet.att.net> writes:
> I'm reviewing a script to try to identify why it takes so ong to
> execute.
Have a look at Devel::DProf.
> Does not properly initializing variables increase the run-time?
No, it shouldn't. But guessing is pointless anyway - Devel::DProf will tell
you precisely where your script is spending its time, no guesswork needed.
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: 4 Jan 2007 14:24:44 -0800
From: "julia" <juliabell@worldnet.att.net>
Subject: Re: uninitialized value warnings and run time
Message-Id: <1167949484.027302.183670@38g2000cwa.googlegroups.com>
Thanks.
This confirmed my suspicions about where the majority of the time was
being spent.
It also provides some encouragement for moving blocks of code into
subroutines instead of keeping them inline (although I do sometimes
wonder if the overhead associated with a subroutine outweighs the
benefit compared with a block of inline code that is only ever called
from one location).
Julia
Sherm Pendley wrote:
> "julia" <juliabell@worldnet.att.net> writes:
>
> > I'm reviewing a script to try to identify why it takes so ong to
> > execute.
>
> Have a look at Devel::DProf.
>
> > Does not properly initializing variables increase the run-time?
>
> No, it shouldn't. But guessing is pointless anyway - Devel::DProf will tell
> you precisely where your script is spending its time, no guesswork needed.
>
> sherm--
>
> --
> Web Hosting by West Virginians, for West Virginians: http://wv-www.net
> Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Thu, 04 Jan 2007 16:42:30 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: uninitialized value warnings and run time
Message-Id: <459d8248$0$500$815e3792@news.qwest.net>
julia wrote:
> Thanks.
>
> This confirmed my suspicions about where the majority of the time was
> being spent.
>
> It also provides some encouragement for moving blocks of code into
> subroutines instead of keeping them inline (although I do sometimes
> wonder if the overhead associated with a subroutine outweighs the
> benefit compared with a block of inline code that is only ever called
> from one location.
While subroutines are a good coding practice, moving code that's only
called once into a subroutine won't improve the run-time. Figure
out why it's slower than expected and code/optimize as needed.
------------------------------
Date: 4 Jan 2007 19:12:04 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Unsecured scripts and site hacking?
Message-Id: <Xns98AE864A04310castleamber@130.133.1.4>
Ian Wilson <scobloke2@infotop.co.uk> wrote:
> Dean G. wrote:
>> If they tell you they have no logs at all, but that they know it
>> occured via port 80, then they are liars.
>
> It's possible that Alison requested webserver logs, which have gone, but
> the ISP has firewall logs from a separate firewall appliance.
>
> However, in Alison's shoes, I'd move to another hosting service.
Yup, me too. It all sounds to fabricated. I mean, a hacker exploits a home
brew script, becomes root on a virtual server, and the only thing he/she
does is rm -rf / ? Come one, even in Hollywood they wouldn't accept that
in a movie script
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: 4 Jan 2007 12:56:52 -0800
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: Unsecured scripts and site hacking?
Message-Id: <1167944212.051791.322710@q40g2000cwq.googlegroups.com>
Alison wrote:
> Randal L. Schwartz <merlyn@stonehenge.com> wrote:
> >
> > *FTP*? *FTP*? What is this, 1995?
>
> How else would you suggest I upload 50MB weekly updates of adult pornography
> to my site?
50 _megabytes a week_ ? hahaha this really IS 1995!
as soon as I buy myself that new US Robotics 28.8 modem for my 60MHz
IBM Aptiva I'm going to subscribe to your porn BBS, Alison! Good thing
I upgraded to the 727MB hard drive!
*chuckle*
-jp
------------------------------
Date: 04 Jan 2007 09:45:30 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Unsecured scripts and site hacking?
Message-Id: <87ps9u91w5.fsf@aragorn.emschwar>
Mirco Wahab <wahab-mail@gmx.de> writes:
> Eric Schwartz wrote:
> >> How else would you suggest I upload 50MB weekly updates of adult pornography
> >> to my site?
> > SFTP, scp, HTTPS, just to name three off the top of my head.
>
> rsync over ssh
Of course, since that's what I use at home, I completely forgot it. :-)
-=Eric
------------------------------
Date: Thu, 04 Jan 2007 22:42:29 +0000
From: Henry Law <news@lawshouse.org>
Subject: Re: Unsecured scripts and site hacking?
Message-Id: <1167950545.11991.0@proxy02.news.clara.net>
Lawrence Statton XE2/N1GAK wrote:
> You are clearly clue retardant. *plonk*
Remind me never to try to help this very unpleasant person.
--
Henry Law Manchester, England
------------------------------
Date: 4 Jan 2007 11:26:30 -0800
From: seanjao@yahoo.com
Subject: Re: using Perl to find string..
Message-Id: <1167938790.534739.59240@q40g2000cwq.googlegroups.com>
Josef Moellers wrote:
> seanjao@yahoo.com wrote:
> > Thanks guys!
>
> For what?
>
> > It helps.
>
> What helps?
>
> Please quote whatever you are replying to!
>
> Thank you,
>
> Josef
>
Hey Josef:
I think I am polite enough to express my appreciaton to all the
thoughts I got.
Of course, including your thought.
Why do I need to specifically to quote anything?
Think about it, man.
> > Thanks guys!
> >
> For what?
For their time and efforts to help someone he/she does not know.
Understand?
Sean
------------------------------
Date: 4 Jan 2007 11:34:45 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: using Perl to find string..
Message-Id: <1167939284.256488.115900@v33g2000cwv.googlegroups.com>
sean...@yahoo.com wrote:
> Josef Moellers wrote:
> > seanjao@yahoo.com wrote:
> > > Thanks guys!
> >
> > For what?
> >
> > > It helps.
> >
> > What helps?
> >
> > Please quote whatever you are replying to!
> >
> > Thank you,
> >
> > Josef
> >
> Hey Josef:
>
> I think I am polite enough
... there's some irony...
> to express my appreciaton to all the thoughts I got.
> Of course, including your thought.
> Why do I need to specifically to quote anything?
> Think about it, man.
Please do some thinking of your own. Not everyone reads a newsgroup
with threadding enabled. Even those of us who do are not guaranteed to
have seen the post to which you are replying. It's entirely possible
that your "thanks" showed up before the posts to which you're replying,
or that the posts to which you're replying simply never showed up at
all. That's how Usenet works. And that's why it's been standard
convention to quote material to which you're replying for *decades*.
Please do a bit of reasearch into what you're talking about before
accusing someone far more familiar with the medium of not thinking.
Paul Lalli
------------------------------
Date: 4 Jan 2007 12:40:37 -0800
From: seanjao@yahoo.com
Subject: Re: using Perl to find string..
Message-Id: <1167943237.522001.60800@51g2000cwl.googlegroups.com>
> And that's why it's been standard
> convention to quote material to which you're replying for *decades*.
If so, please let an experienced user, like you to show me how to
express my appreciation
to all of the thoughts posted for this topic.
Thank you.
Sean Jao
------------------------------
Date: 4 Jan 2007 14:52:19 -0800
From: "brewsterbear@googlemail.com" <brewsterbear@googlemail.com>
Subject: which email module - MIME::LITE, Email::Send, other?
Message-Id: <1167951139.523928.118730@v33g2000cwv.googlegroups.com>
Hi,
Just wondering which is the "preferred" way to send email, possibly
with attachments. I noticed MIME::Lite hasn't been developed for a few
years, not that it really needs development. Are people using
Email::Send or Mail::Send? Any recommendation appreciated.
Thanks
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 10118
****************************************