[30946] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2191 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 8 00:09:46 2009

Date: Sat, 7 Feb 2009 21:09:08 -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           Sat, 7 Feb 2009     Volume: 11 Number: 2191

Today's topics:
    Re: [OT] Programmers (UK)...? <uri@stemsystems.com>
    Re: [OT] Programmers (UK)...? <tadmc@seesig.invalid>
    Re: automating a perl installation on a cluster (or usi <xhoster@gmail.com>
    Re: automating a perl installation on a cluster (or usi <ben@morrow.me.uk>
    Re: duplicating filehandles <pgodfrin@gmail.com>
        good email parser ?? <jack_posemsky@yahoo.com>
    Re: Perl Memory and die...what is happening here? <someone@example.com>
    Re: Perl Memory and die...what is happening here? <ben@morrow.me.uk>
    Re: Perl Memory and die...what is happening here? <whynot@pozharski.name>
        Perl vs. .NET (was: Re: Programmers (UK)...?) <rvtol+usenet@xs4all.nl>
    Re: Perl vs. .NET (was: Re: Programmers (UK)...?) <cartercc@gmail.com>
    Re: Perl vs. .NET (was: Re: Programmers (UK)...?) <tim@burlyhost.com>
    Re: Reducing log size <xhoster@gmail.com>
    Re: Reducing log size <XXjbhuntxx@white-star.com>
    Re: Reducing log size <ben@morrow.me.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 07 Feb 2009 15:11:43 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: [OT] Programmers (UK)...?
Message-Id: <x7hc36roqo.fsf@mail.sysarch.com>

>>>>> "CM" == Cliff MacGillivray <cliff@excite.com> writes:

  CM> Uri Guttman wrote:
  >>>>>>> "TJM" == Tad J McClellan <tadmc@seesig.invalid> writes:
  TJM> Chris Davies <chris-usenet@roaima.co.uk> wrote:
  >> >> Can anyone recommend places (websites) or agencies I should be contacting,
  >> >> where Perl experience is an advantage rather than a deadweight?
  TJM> http://jobs.perl.org
  >> also the london perl monger's manage their own jobs list so you would
  >> get more a more focused group. and i know several UK hackers who might
  >> be available. but maybe hiring in 2 months is not useful immediately.
  >> as for placement agencies, i am the only one in the world that is
  >> 100%
  >> dedicated to SPAMSPAMSPAMSPAMSPAMSPAMSPAM  you
  >> have been talking to useless agents who do buzzword matching.
  CM> abuse complaint sent

sent to whom and about what? it wasn't spam. i was just telling him that
there are agents who do understand perl and the perl job market. i just
happen to be the only one. bfd. if i posted stuff here all the time
about it, it would be spam. i also redirected him to a free resource
dedicated to perl jobs in his country. was that spam too?

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


------------------------------

Date: Sat, 7 Feb 2009 14:42:37 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: [OT] Programmers (UK)...?
Message-Id: <slrngorsht.88r.tadmc@tadmc30.sbcglobal.net>

Cliff MacGillivray <cliff@excite.com> wrote:
> Uri Guttman wrote:
>>>>>>> "TJM" == Tad J McClellan <tadmc@seesig.invalid> writes:
>> 
>>   TJM> Chris Davies <chris-usenet@roaima.co.uk> wrote:
>>   >> Can anyone recommend places (websites) or agencies I should be contacting,
>>   >> where Perl experience is an advantage rather than a deadweight?
>> 
>>   TJM>    http://jobs.perl.org
>> 
>> also the london perl monger's manage their own jobs list so you would
>> get more a more focused group. and i know several UK hackers who might
>> be available. but maybe hiring in 2 months is not useful immediately.
>> 
>> as for placement agencies, i am the only one in the world that is 100%
>> dedicated to SPAMSPAMSPAMSPAMSPAMSPAMSPAM  you
>> have been talking to useless agents who do buzzword matching.
> abuse complaint sent


What abuse is that you have observed?


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


------------------------------

Date: Fri, 06 Feb 2009 19:16:45 -0800
From: Xho Jingleheimerschmidt <xhoster@gmail.com>
Subject: Re: automating a perl installation on a cluster (or using non-standard nfs paths)
Message-Id: <498e1051$0$21105$ed362ca5@nr5-q7.newsreader.com>

Rahul wrote:
> 
> My approach:
> All the nodes have a common nfs mounter directory too (/usr/local/) so I 
> thought of doing manual compiles once to this non-standard location by 
> using " perl Makefile.PL PREFIX=/usr/local/lib/perl; make; make test; 
> make install" 

I don't understand what the independent purposes of PREFIX and LIB are, 
but it seems you have set both of them, not just PREFIX, or things go 
wrong, in the way you described.

> Unfortunately then the next programs down the line don't seem to find the 
> modules they need where they expect to find them. eg.
> 
> ######error########
> Can't locate Math/Calc/Units/Convert.pm in @INC (@INC contains: 
> /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi 
> /usr/lib64/perl5/site_perl/5.8.7/x86_64-linu
> #########################
> 
> I tried " setenv PERL5LIB /usr/local/lib/perl" but many modules seem to 
> be installed deep down this heirarchy.  PERL5LIB based searches do not 
> seem recursive?

It is, at least in some circumstances, but the recursion is rules-based, 
not exhaustive.  You can't just set PERL5LIB to be / and have it scour 
your entire system!  you might need to set PERL5LIB to some thing like 
/usr/local/lib/perl/lib to have it work right.

> 
> Example: /usr/lib/perl5/site_perl/5.8.8/Math/Calc/Units/Convert.pm

Ah, what is that an example of?  "/usr/local/lib/perl" ne 
"/usr/lib/perl5/site_perl"



Xho


------------------------------

Date: Sun, 8 Feb 2009 01:51:10 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: automating a perl installation on a cluster (or using non-standard nfs paths)
Message-Id: <edq166-a0h.ln1@osiris.mauzo.dyndns.org>


Quoth Xho Jingleheimerschmidt <xhoster@gmail.com>:
> Rahul wrote:
> > 
> > My approach:
> > All the nodes have a common nfs mounter directory too (/usr/local/) so I 
> > thought of doing manual compiles once to this non-standard location by 
> > using " perl Makefile.PL PREFIX=/usr/local/lib/perl; make; make test; 
> > make install" 
> 
> I don't understand what the independent purposes of PREFIX and LIB are, 
> but it seems you have set both of them, not just PREFIX, or things go 
> wrong, in the way you described.

Recentish versions of MakeMaker (since 6.31) have an INSTALL_BASE
parameter which actually does the right thing: INSTALL_BASE=/usr/local
is probably what you want in this case. PREFIX is rather weird, in that
it tries to emulate the structure of your system perl installation,
rather than using a normal layout. 

> > Unfortunately then the next programs down the line don't seem to find the 
> > modules they need where they expect to find them. eg.
> > 
> > ######error########
> > Can't locate Math/Calc/Units/Convert.pm in @INC (@INC contains: 
> > /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi 
> > /usr/lib64/perl5/site_perl/5.8.7/x86_64-linu
> > #########################
> > 
> > I tried " setenv PERL5LIB /usr/local/lib/perl" but many modules seem to 
> > be installed deep down this heirarchy.

This is probably because you set PREFIX wrong. You've probably ended up
installing somewhere like
/usr/local/lib/perl/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi,
which is several levels deeper than you meant. If you use
INSTALL_BASE=/usr/local you should instead get modules in
/usr/local/lib/perl5/x86_64-linux-thread-multi, which
PERL5LIB=/usr/local/lib/perl5 will find just fine (see below).

> > PERL5LIB based searches do not seem recursive?
> 
> It is, at least in some circumstances, but the recursion is rules-based, 
> not exhaustive.

Specifically, an entry /foo in PERL5LIB will also include
/foo/VERSION/ARCH, /foo/VERSION and /foo/ARCH where VERSION is something
like 5.8.8 and ARCH is something like i386-linux. It will also include
directories for any compatible previous versions that were found at
Configure time: you can get the list with perl -V:inc_version_list. This
is exactly the same logic as used by 'use lib'.

Ben



------------------------------

Date: Sat, 7 Feb 2009 19:47:49 -0800 (PST)
From: pgodfrin <pgodfrin@gmail.com>
Subject: Re: duplicating filehandles
Message-Id: <d271a821-f846-4143-93b1-4f50d2b994f1@g1g2000pra.googlegroups.com>

Yup - that was it... embarrassingly easy...
pg

On Feb 2, 12:22=A0pm, an...@alumni.caltech.edu (Gary E. Ansok) wrote:
> In article <8388a564-f978-464f-af6f-3c145e45b...@i24g2000prf.googlegroups=
 .com>,
>
> pgodfrin=A0<pgodf...@gmail.com> wrote:
> >That's interesting - I suppose that would work, but I still would have
> >to do a mass substitution.
>
> >Is there a way to say something like
>
> > =A0 open OUTFILE, ">STDOUT" ;
>
> open OUTFILE, ">&STDOUT";
>
> Look in perldoc perlopentut (specifically the section "Obscure Open
> Tricks"), or in perldoc -f open, for more details.
>
> Gary Ansok
> --
> Chaos reigns within.
> Reflect, repent, and reboot.
> Order shall return.



------------------------------

Date: Sat, 7 Feb 2009 15:59:24 -0800 (PST)
From: Jack <jack_posemsky@yahoo.com>
Subject: good email parser ??
Message-Id: <8d1c9324-9efd-43e7-a68d-7fed623b3174@40g2000prx.googlegroups.com>

Hi I havent had any luck with the CPAN email modules, I just want to
parse multipart and mime and base64, with all the varieties of email
files out there, these modules just dont work... does anyone know a
free or low cost command line driven email client or parser that can
do the job.

Thank you,

Jack


------------------------------

Date: Sat, 07 Feb 2009 13:02:52 -0800
From: "John W. Krahn" <someone@example.com>
Subject: Re: Perl Memory and die...what is happening here?
Message-Id: <bGmjl.566$0v.154@newsfe17.iad>

Martin Harris wrote:
> This program uses up all the memory deliberatly...but I have some questions
> about what is actually happening...
> 
> The first loop will run out of RAM and exit status 1.  Out of Memory is
> printed to stderr.
> 
> while (1) {
>   # Out of Memory when RAM limit is reached, then Crash out.
>   push @growthing,@growthing;
> }

$ perl -le'
my @growthing = "a";
for ( 1 .. 5 ) {
     push @growthing, @growthing;
     }
print "@growthing";
'
a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a


> This second loop takes longer to grab the memory.  i.e the growth line is
> not so steep.
> 
> In addition it grows past RAM into Swap.
> 
> while (1) {
>   # These seem to carry on growing 
>   # into swap until eventualy even these die ..why?
>   # These are also much slower, why?
>   push @growthing,@growthing || die "ouch: $!\n";
>   
>   # Similar to the die example
>   # push @growthing,@growthing || exit 1;
> }

$ perl -le'
my @growthing = "a";
for ( 1 .. 5 ) {
     push @growthing, @growthing || die "ouch: $!\n";
     }
print "@growthing";
'
a 1 2 3 4 5


> 1. Why is the second loop slower to eat the memory.

The first loop doubles the size of the array for each iteration.  The 
second loop adds a single value to the end of the array for each 
iteration (the || operator forces the array into scalar context.)


> 2. Why does the second loop eat into swap before exit where the first loop
> exits at the end of ram?

Because doubling the size of the array will cause it to crash before it 
can use swap while increasing the array by one element will let it use swap.


> 3. The die never gets executed...presumably because there is no memory to
> perform the operation.

The die never gets executed because @growthing is always true in scalar 
context.  Instead of using the '||' operator you should be using the 
'or' operator:

     push @growthing, @growthing or die "ouch: $!\n";

or enclose the arguments to push in parentheses.

     push( @growthing, @growthing ) || die "ouch: $!\n";



John
-- 
Those people who think they know everything are a great
annoyance to those of us who do.        -- Isaac Asimov


------------------------------

Date: Sun, 8 Feb 2009 01:56:51 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Perl Memory and die...what is happening here?
Message-Id: <3oq166-a0h.ln1@osiris.mauzo.dyndns.org>


Quoth Martin Harris <martinhport-news@yahoo.com>:
>
> 4. How can you write perl that checks something will fit into memory before
> it tries the operation?

Basically, you can't. Perl tends to act on the assumption that infinite
memory is available, and to fail rather badly when this isn't true.

There is a special variable $^M, documented in perlvar, which you can in
principle use to recover from lack of memory; but your perl has to be
built to use it, and you have to be *incredibly* careful (it's basically
impossible to be sure you've allocated enough emergency memory to do
anything non-trivial).

Ben



------------------------------

Date: Sun, 08 Feb 2009 00:35:27 +0200
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: Perl Memory and die...what is happening here?
Message-Id: <slrngos35g.ejo.whynot@orphan.zombinet>

On 2009-02-07, Martin Harris <martinhport-news@yahoo.com> wrote:
> This program uses up all the memory deliberatly...but I have some questions
> about what is actually happening...
>
> The first loop will run out of RAM and exit status 1.  Out of Memory is
> printed to stderr.
>
> while (1) {
>   # Out of Memory when RAM limit is reached, then Crash out.
>   push @growthing,@growthing;
> }
>
> This second loop takes longer to grab the memory.  i.e the growth line is
> not so steep.
>
> In addition it grows past RAM into Swap.
>
> while (1) {
>   # These seem to carry on growing 
>   # into swap until eventualy even these die ..why?
>   # These are also much slower, why?
>   push @growthing,@growthing || die "ouch: $!\n";
>   
>   # Similar to the die example
>   # push @growthing,@growthing || exit 1;
> }
>
> 1. Why is the second loop slower to eat the memory.

Not for me.  Though I wasn't that evil, and just experimented with
C<ulimit -v 200000>

> 2. Why does the second loop eat into swap before exit where the first loop
> exits at the end of ram?

No idea.  Consider using B<strace(1)> or something that your OS
provides.  I admit that I didn't compared outputs thoroughly, at glance
they appeared to be the same.

> 3. The die never gets executed...presumably because there is no memory to
> perform the operation.

That's easy.  Your memory-eating perl is signaled.  And have you read
C<perldoc -f push> output?

	{29027:44} [0:0]$ perl -wle '@x = (); push @x, @x or die'
	Died at -e line 1.

> 4. How can you write perl that checks something will fit into memory before
> it tries the operation?

Since we are going to shoot in your foot, consider this (untested):

	defined my $pid = fork or die;
	unless ($pid) {
		do_nasty_thing();
		exit 0;
	};
	waitpid $pid, 0;
	$? and die "can't do nasty thing"
	do_nasty_thing();


-- 
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom


------------------------------

Date: Sat, 07 Feb 2009 21:23:21 +0100
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Perl vs. .NET (was: Re: Programmers (UK)...?)
Message-Id: <498dedb9$0$188$e4fe514c@news.xs4all.nl>

cartercc wrote:

> I've had some
> recent experience programming in .NET, and while it's true that you
> can do bunches of things in .NET that you can't do in Perl, it's also
> true that you can do bunches of things in Perl that you can't do
> in .NET. But of course you already know that.

Can you give examples? In my view there aren't any.

-- 
Ruud


------------------------------

Date: Sat, 7 Feb 2009 19:03:05 -0800 (PST)
From: cartercc <cartercc@gmail.com>
Subject: Re: Perl vs. .NET (was: Re: Programmers (UK)...?)
Message-Id: <33927aa8-bb41-4fd1-b2f9-db30fef0ca99@x9g2000yqk.googlegroups.com>

On Feb 7, 3:23=A0pm, "Dr.Ruud" <rvtol+use...@xs4all.nl> wrote:
> cartercc wrote:
> > I've had some
> > recent experience programming in .NET, and while it's true that you
> > can do bunches of things in .NET that you can't do in Perl, it's also
> > true that you can do bunches of things in Perl that you can't do
> > in .NET. But of course you already know that.
>
> Can you give examples? In my view there aren't any.
>
> --
> Ruud

When I say .NET, I'm referring to the whole shootin' match, Visual
Studio and all. I've taught Perl and VB on a post-secondary level, and
I have observed that a group of students (not university level or
computer scientists, but ordinary young people) can do quite a bit
more after a quarter of VB than after a quarter of Perl. Also,
building Windows apps is a lot easier with all the Microsoft libraries
that attempted to do it with Perl. In fact, if I were building a
Windows app, I wouldn't even consider using Perl -- Visual Studio
makes it pretty easy.

 .NET is not a language, or a set of libraries, but a framework. Perl
is a language. You really can't compare the two on an equal basis. For
one thing, with .NET, you can use VB, C++/CLI (a significant MS
extension to C++), C#, J#, maybe F#, and maybe even Perl. With Perl,
you can only use Perl. That would be one thing you could do with .NET
but not with Perl.

CC


------------------------------

Date: Sat, 07 Feb 2009 19:33:52 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: Perl vs. .NET (was: Re: Programmers (UK)...?)
Message-Id: <Aosjl.2921$5B.1140@newsfe20.iad>

cartercc wrote:

>  I've taught Perl and VB on a post-secondary level, and
> I have observed that a group of students (not university level or
> computer scientists, but ordinary young people) can do quite a bit
> more after a quarter of VB than after a quarter of Perl.

No offense, but how are you qualified to judge this, let alone to teach
it, when you're here on this group the last couple of months asking
very basic questions and still posting with questions that result from
you still not using what you've been taught here?  I'm not trying to be
mean, and maybe you can code fine in VB or other languages, but what
you've demonstrated about your lack of Perl knowledge doesn't really
fairly and accurately portray what amount people could know and use,
had they been taught by someone more qualified.  I'm not attacking you,
but I find your claims of Perl comparisons without merit, based on
these reasons.
-- 
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!


------------------------------

Date: Sat, 07 Feb 2009 15:08:20 -0800
From: Xho Jingleheimerschmidt <xhoster@gmail.com>
Subject: Re: Reducing log size
Message-Id: <498e15b0$0$21142$ed362ca5@nr5-q7.newsreader.com>

Cosmic Cruizer wrote:
> I searched, but could not find suggestions on reducing the size of log 
> files on Windows. Truncate did not work since it keeps to top portion of 
> the log. I did not try to use tail.

Why not?

> Now that I wrote something that does what I want... what is a cleaner way 
> of doing this?

Using tail.  Or rotating your logs more often, then deleting some of the 
  older ones.

Or can't you cleanly rotate logs on Windows?

>       while (<$in>){
>         $x+=1;
>         print $out $_ if($x > $target_size);
>       }
>       print $out "\n$time_stamp\tFile size truncated\n\n";
>     close $in;
>     close $out;
> 
>     # Replace old logfile and clean up temp
>     unlink $log;

What happened to data that get written into the logfile after the while 
finished but before the unlink happened?

>     move ("TEMP.txt", "$log");

What happened to process that tried to open $log during it's period of
nonexistence?

>     unlink "TEMP.txt";

Does move leave a copy of that behind?


Xho


------------------------------

Date: Sun, 08 Feb 2009 02:27:13 GMT
From: Cosmic Cruizer <XXjbhuntxx@white-star.com>
Subject: Re: Reducing log size
Message-Id: <Xns9BABBB714AE7Accruizermydejacom@207.115.33.102>

Ben Morrow <ben@morrow.me.uk> wrote in
news:j02166-ute.ln1@osiris.mauzo.dyndns.org: 


Ben, thanks for the suggestions. I made several of the changes both you and 
Tad suggested. By using $. for the counter and removing several other 
superfluous bits of code, it looks much better.

I'm surprised at how fast the code works, even on a 500 mb logfile. 

There is one comment I'm unsure of... you asked "Why open for append?" Is 
there a more effecient way to write to a file?

Thanks,

 ...Cos


------------------------------

Date: Sun, 8 Feb 2009 03:37:33 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Reducing log size
Message-Id: <tk0266-ohi.ln1@osiris.mauzo.dyndns.org>


Quoth Cosmic Cruizer <XXjbhuntxx@white-star.com>:
> 
> There is one comment I'm unsure of... you asked "Why open for append?" Is 
> there a more effecient way to write to a file?

It's not about efficiency (although File::Slurp::write_file is probably
more efficient than writing it line by line). The differences between a
normal open-for-writing with ">" and open-for-append with ">>" are

    - if the file already exists, ">" will remove all its contents, but
      ">>" won't;

    - every write to a file open for append is atomically placed at the
      end of the file, so if you have several processes appending to the
      same file they won't scribble on each others' work.

If you don't need either of these, it's clearer to use a plain ">".

Ben



------------------------------

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 V11 Issue 2191
***************************************


home help back first fref pref prev next nref lref last post