[30576] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1819 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 25 21:09:43 2008

Date: Mon, 25 Aug 2008 18:09:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 25 Aug 2008     Volume: 11 Number: 1819

Today's topics:
        Can't remove directory <slick.users@gmail.com>
    Re: Can't remove directory <spamtrap@dot-app.org>
    Re: Can't remove directory <jurgenex@hotmail.com>
    Re: Can't remove directory <tadmc@seesig.invalid>
    Re: Converting the text output to excel via perl. <1usa@llenroc.ude.invalid>
    Re: Debugging "exit" <john@castleamber.com>
    Re: Debugging "exit" <ignoramus9283@NOSPAM.9283.invalid>
    Re: Debugging "exit" <ignoramus9283@NOSPAM.9283.invalid>
    Re: Debugging "exit" xhoster@gmail.com
    Re: Debugging "exit" xhoster@gmail.com
    Re: Debugging "exit" <jurgenex@hotmail.com>
    Re: Debugging "exit" <alex@digriz.org.uk>
    Re: Getting Fatal error while compiling Perl 5 10 sridharanandaraj@gmail.com
    Re: Parallel search in Perl and other languages <igouy2@yahoo.com>
        Perl Fork options BryanBBFan@ca.rr.com
    Re: Perl Fork options xhoster@gmail.com
    Re: Regular express for <p>, <ul> and <ol> tags <jurgenex@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 25 Aug 2008 11:58:53 -0700 (PDT)
From: Slickuser <slick.users@gmail.com>
Subject: Can't remove directory
Message-Id: <7daea806-30a9-481a-82c8-cb51eb394b15@r35g2000prm.googlegroups.com>

I use SVN to checkout a folder and SVN set the directory to read only.

Using File::Path module, rmtree($path) to try do delete all files &
directories in that folder.
I get error: Can't remove directory

Is there some way I can remove it. I try looking at chmod but doesn't
help it either. Thanks.

my $dir_del = "C:\folderA\ABC\D\E";
$dir_del =~ s/\\/\//ig;
chmod($dir_del,0755);
rmtree($dir_del);


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

Date: Mon, 25 Aug 2008 16:03:38 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Can't remove directory
Message-Id: <m13aksq2ud.fsf@dot-app.org>

Slickuser <slick.users@gmail.com> writes:

> my $dir_del = "C:\folderA\ABC\D\E";

Those backslashes aren't doing what you think they're doing:

    localhost:~ sherm$ cat testme.pl 
    #!/usr/bin/perl
    
    use warnings;
    use strict;
    
    my $dir_del = "C:\folderA\ABC\D\E";
    print $dir_del, "\n";

    localhost:~ sherm$ perl testme.pl 
    Unrecognized escape \A passed through at testme.pl line 6.
    Unrecognized escape \D passed through at testme.pl line 6.
    C:
      olderAABCD
    localhost:~ sherm$ 


You should just use forward slashes, which work just fine on Windows,
and don't mean anything special in double-quoted strings.

It's a good idea enable both strict and warnings, and pay attention to
messages such as the warnings shown above. It's also a good idea to
include the filename in any error messages you print, along with $!,
to help alert you when a filename you're using isn't really what you
think it is.

sherm--

-- 
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: Mon, 25 Aug 2008 20:27:54 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Can't remove directory
Message-Id: <6656b4p2mj5lvjv48bfvs23e1j4oipn9r7@4ax.com>

Slickuser <slick.users@gmail.com> wrote:
>I use SVN to checkout a folder and SVN set the directory to read only.
>
>Using File::Path module, rmtree($path) to try do delete all files &
>directories in that folder.
>I get error: Can't remove directory
>
>Is there some way I can remove it. I try looking at chmod but doesn't
>help it either. Thanks.
>
>my $dir_del = "C:\folderA\ABC\D\E";

Are you sure you got a directory named

	C:<formfeed>olderAABCDE

See "perldoc -q DOS"
  	Why can't I use "C:\temp\foo" in DOS paths?  
	What doesn't `C:\temp\foo.exe` work?
for details.

jue


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

Date: Mon, 25 Aug 2008 18:30:42 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Can't remove directory
Message-Id: <slrngb6g52.f4o.tadmc@tadmc30.sbcglobal.net>

Slickuser <slick.users@gmail.com> wrote:


> I try looking at chmod 


> chmod($dir_del,0755);


Did you look as far as the 2nd sentence in the docs for chmod?

   ... The first element of the list must be the numerical mode


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


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

Date: Mon, 25 Aug 2008 22:44:02 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Converting the text output to excel via perl.
Message-Id: <Xns9B05BE8C9F0F1asu1cornelledu@127.0.0.1>

Sana <scriptsana@gmail.com> wrote in news:9d2f3fe5-c804-480e-9feb-
e5a6b93e362a@z11g2000prl.googlegroups.com:

> I have the following output  which I want to convert into excel...Any
> pointers how to achieve it via Spreadsheet::WriteExcel;
> 
> I am a beginer so pardon my lack of knowledge in perl.

s/perl/Perl/

perl is the binary, Perl is the language.

Do you know any Perl? Can you put something together using the 
documentation for the module Spreadsheet::WriteExcel?

The documentation is extremely clear and well written. Examples abound. 
Just the synopsis is enough to solve this problem if you can program in 
any language.

So, please read the posting guidelines for this group, then come up with 
your best effort at implementing a solution. You will be much more 
likely to get good help if you are willing to do that.

To provide some incentive for you to learn how to fish, here is a 
template:

#!/usr/bin/perl

use strict;
use warnings;

use Spreadsheet::WriteExcel;

my $book = # add code to create a new workbook
my $sheet = # add code to add a new sheet to $book

while ( my $line = <DATA> ) {
    $line =~ s/^\s+//;
    $line =~ s/\s+$//;
    last unless length $line;

    my $row = [ split /\s+/, $line ];
    # Add code to write a new row to $sheet
    # the special variable $. would be useful
    # here. See perldoc perlvar.
}

# add code to close $book

__DATA__
lpar_name       minmem  desmem  maxmem  minpr   despr   maxpr
commuq21        2048    8192    12288   0.1     1.0     2.0
commuq20        2048    8192    12288   0.1     1.0     2.0
commuq23        2048    16384   40960   0.1     2.0     4.0
commud18        3072    40960   61440   0.2     2.0     5.0
commup03        2048    24576   30720   0.1     3.0     4.0
commup02        10240   32768   32768   1.0     4.0     8.0
commup01        10240   32768   32768   1.0     4.0     8.0



-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/


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

Date: 25 Aug 2008 15:22:02 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Debugging "exit"
Message-Id: <Xns9B05697573EA2castleamber@130.133.1.4>

Ignoramus9283 <ignoramus9283@NOSPAM.9283.invalid> wrote:

> We have a script that is supposed to run continuously and never to
> die or exit. And it generally does that, except that sometimes it does
> not and exits mysteriously.

Besides finding the cause, you might want to look into a way to have it 
restart automatically (and if it's important, pick up were it left).

-- 
John    http://johnbokma.com/ - Hacking & Hiking in Mexico

Perl help in exchange for a gift:
http://johnbokma.com/perl/help-in-exchange-for-a-gift.html


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

Date: Mon, 25 Aug 2008 10:53:59 -0500
From: Ignoramus9283 <ignoramus9283@NOSPAM.9283.invalid>
Subject: Re: Debugging "exit"
Message-Id: <a6OdnSpWsMMKSC_VnZ2dnUVZ_vqdnZ2d@giganews.com>

On 2008-08-25, Sherm Pendley <spamtrap@dot-app.org> wrote:
> Ignoramus9283 <ignoramus9283@NOSPAM.9283.invalid> writes:
>
>> We have a script that is supposed to run continuously and never to
>> die or exit. And it generally does that, except that sometimes it does
>> not and exits mysteriously. 
>>
>> We capture its stdout and stderr and there is "nothing abnormal". 
>>
>> We do use strict and use warnings. 
>>
>> So, I think that possibly some library routine, or some such thing,
>> calls "exit". I would like to trap exit globally, and still exit
>
> Sounds to me like you want an END block:
>
>     END {
>         print "Goodbye, world!\n";
>     }

That's about what the END block is good for. 

Specifically, you cannot find out what subroutine called exit, from
the END block. The call stack does not tell you that.

> In a nutshell, END blocks are "... executed as late as possible, that
> is, after perl has finished running the program and just before the
> interpreter is being exited, even if it is exiting as a result of a
> die() function." (from perlmod)
>
> Note that there are some situations in which END blocks are not
> called. Have a look at "perldoc perlmod" for details, in the section
> "BEGIN, CHECK, INIT, and END".
>
>> at least print stack trace or some such, before exiting, is that
>> possible?
>
> The caller() function will print a stack trace, at whatever depth you
> want it. See "perldoc -f caller" for details.
>

Except the END block is not called from inside the routine that called
exit. 

-- 
   Due to extreme spam originating from Google Groups, and their inattention 
      to spammers, I and many others block all articles originating 
       from Google Groups. If you want your postings to be seen by 
         more readers you will need to find a different means of 
                       posting on Usenet.
                   http://improve-usenet.org/


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

Date: Mon, 25 Aug 2008 10:54:45 -0500
From: Ignoramus9283 <ignoramus9283@NOSPAM.9283.invalid>
Subject: Re: Debugging "exit"
Message-Id: <a6OdnSVWsMNYSC_VnZ2dnUVZ_vqdnZ2d@giganews.com>

On 2008-08-25, John Bokma <john@castleamber.com> wrote:
> Ignoramus9283 <ignoramus9283@NOSPAM.9283.invalid> wrote:
>
>> We have a script that is supposed to run continuously and never to
>> die or exit. And it generally does that, except that sometimes it does
>> not and exits mysteriously.
>
> Besides finding the cause, you might want to look into a way to have it 
> restart automatically (and if it's important, pick up were it left).
>

Yes, it already picks up where it left. We do not restart it
automatically yet.

We may have found the cause of it a few minutes ago. 
-- 
   Due to extreme spam originating from Google Groups, and their inattention 
      to spammers, I and many others block all articles originating 
       from Google Groups. If you want your postings to be seen by 
         more readers you will need to find a different means of 
                       posting on Usenet.
                   http://improve-usenet.org/


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

Date: 25 Aug 2008 16:22:45 GMT
From: xhoster@gmail.com
Subject: Re: Debugging "exit"
Message-Id: <20080825122246.835$oG@newsreader.com>

Ignoramus9283 <ignoramus9283@NOSPAM.9283.invalid> wrote:
> We have a script that is supposed to run continuously and never to
> die or exit. And it generally does that, except that sometimes it does
> not and exits mysteriously.
>
> We capture its stdout and stderr and there is "nothing abnormal".
>
> We do use strict and use warnings.
>
> So, I think that possibly some library routine, or some such thing,
> calls "exit".

What libraries are you using?  Can you grep through them for "exit"?


> I would like to trap exit globally, and still exit, but
> at least print stack trace or some such, before exiting, is that
> possible?
>
> Is so, how?

See "Overriding Built-in Functions" in perldoc perlsub.
It doesn't do it globally, so it might take some more work to achieve that.

use Carp;
use subs 'exit';
sub exit { confess "tried to exit"; };
sub foo { exit; };
foo();
__END__
tried to exit at end.pl line 3
        main::exit() called at end.pl line 4
        main::foo() called at end.pl line 5



Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: 25 Aug 2008 16:24:33 GMT
From: xhoster@gmail.com
Subject: Re: Debugging "exit"
Message-Id: <20080825122435.383$qS@newsreader.com>

Ignoramus9283 <ignoramus9283@NOSPAM.9283.invalid> wrote:
> On 2008-08-25, Sherm Pendley <spamtrap@dot-app.org> wrote:
> > Ignoramus9283 <ignoramus9283@NOSPAM.9283.invalid> writes:
> >
> >> We have a script that is supposed to run continuously and never to
> >> die or exit. And it generally does that, except that sometimes it does
> >> not and exits mysteriously.
> >>
> >> We capture its stdout and stderr and there is "nothing abnormal".
> >>
> >> We do use strict and use warnings.
> >>
> >> So, I think that possibly some library routine, or some such thing,
> >> calls "exit". I would like to trap exit globally, and still exit
> >
> > Sounds to me like you want an END block:
> >
> >     END {
> >         print "Goodbye, world!\n";
> >     }
>
> That's about what the END block is good for.
>
> Specifically, you cannot find out what subroutine called exit, from
> the END block. The call stack does not tell you that.

True.  But it still provides useful info.  Are you seeing a normal
exit, which goes through END, or some kind of crash or POSIX::_exit
that doesn't.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Mon, 25 Aug 2008 16:38:35 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Debugging "exit"
Message-Id: <opn5b4hnn1jqkujcrl4ghkvarbn2p3enp4@4ax.com>

Ignoramus9283 <ignoramus9283@NOSPAM.9283.invalid> wrote:
>We have a script that is supposed to run continuously and never to
>die or exit. 

User-level processes occasionally can and will be terminated by the OS
or admin for a varity of reasons. Therefore you may want to run that
script as a deamon using whatever method your OS provides for managing
deamons, including watchdog and automatic restart functionality.

jue


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

Date: Mon, 25 Aug 2008 19:08:15 +0100
From: Alexander Clouter <alex@digriz.org.uk>
Subject: Re: Debugging "exit"
Message-Id: <f19bo5-67v.ln1@woodchuck.wormnet.eu>

Ignoramus9283 <ignoramus9283@nospam.9283.invalid> wrote:
>
> We have a script that is supposed to run continuously and never to
> die or exit. And it generally does that, except that sometimes it does
> not and exits mysteriously. 
> 
> We capture its stdout and stderr and there is "nothing abnormal". 
> 
> We do use strict and use warnings. 
> 
> So, I think that possibly some library routine, or some such thing,
> calls "exit". I would like to trap exit globally, and still exit, but
> at least print stack trace or some such, before exiting, is that
> possible?
> 
> Is so, how?
>
If you have the diskspace, run the code and attach strace to it from
another (screen'd possibly) console.

I had something similar recently and noticed that I was getting a
SIGPIPE from one of my sockets[1] that appeared clearly in an strace.

Just another tool worth adding to your 'utility belt' batman :)

Cheers

Alex

[1] buggy Google IMAP, who would have guessed... :-/


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

Date: Mon, 25 Aug 2008 09:55:14 -0700 (PDT)
From: sridharanandaraj@gmail.com
Subject: Re: Getting Fatal error while compiling Perl 5 10
Message-Id: <a3e08b93-0115-43b5-a366-b879e276211b@k13g2000hse.googlegroups.com>

On Aug 22, 3:35=A0pm, Peter Makholm <pe...@makholm.net> wrote:
> sridharananda...@gmail.com writes:
> > sh: gcc: not found
> > ***Errorcode 1
> >make:Fatalerror:Commandfailedfortarget`miniperlmain.o'
>
> You don't have gcc installed.
>
> //Makholm


Thanks for the information Makholm.

As we are trying to install Perl 5.10, we have faced this fatal error
problem due to gcc compiler unavailabilty. also we dont have the
installer file for Perl 5.10, we have moved our view to install Perl
5.8.8. For that we have downloaded both the source code file and the
installer file "perl-5.8.8-sol10-sparc-local.gz " from sunfree ware.

for the first step of installing 5.8.8 we have gunzipped this file and
went for pkgadd command. But its asking for the root permission. As we
took a backup copy of all the data and the code we went for this
second option.

The current version we are using is perl 5.6 (32 bit copiler)and the
reason which we are trying to install is like we got a problem of
processing / validating  files size which is large. As the loading of
the hashes into the memory is the problem we are looking for a 64 bit
compiler.

Suggest us what shall we proceed further to fullfill our requirement.

Appreciate your great help in this regard.


Sridhar Anandaraj







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

Date: Mon, 25 Aug 2008 09:08:44 -0700 (PDT)
From: Isaac Gouy <igouy2@yahoo.com>
Subject: Re: Parallel search in Perl and other languages
Message-Id: <5a93879a-827c-4498-a63c-bc0f7ec0b8c1@1g2000pre.googlegroups.com>

On Jul 30, 1:02=A0am, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:

-snip-

> > Thebenchmarks gamesite
> [...]
> >http://shootout.alioth.debian.org/gp4/index.php
>
> [...]
>
> These are a lot of fun but not very relevant for the real world. Almost
> all of the benchmarks focus on specific operations, not on doing a task.



"Almost all of the benchmarks focus on specific operations..." ?

The focus on specific operations was perhaps apparent in Doug Bagley's
2001 "The Great Computer Language Shootout"

http://web.archive.org/web/20010124090400/http://www.bagley.org/~doug/shoot=
out/


Take the trouble to count how many of the benchmarks in the current
benchmarks game "focus on specific operations, not on doing a task". A
ridiculously broad interpretation of "specific operations" still comes
in around 70% - nothing like "Almost all".


The obvious criticism is that *all* the programs are minuscule
compared to the programs we work on, and we shouldn't just assume that
what's true of minuscule programs would be true of larger programs.



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

Date: Mon, 25 Aug 2008 11:28:06 -0700 (PDT)
From: BryanBBFan@ca.rr.com
Subject: Perl Fork options
Message-Id: <2bd3c023-4839-4528-9cd7-01bd2fde58c9@t1g2000pra.googlegroups.com>

I have an application which uses PBS to allocates 32 nodes on a Linux
Cluster.  A Perl script needs to spawn off 100+ completely independent
processes from this job.  The Perl use fork to do this.  The script
came from a shared memory machine where ther was plenty of memory each
node could access.  The system it needs to run on is not a shared
memory system, where each node has its own memory.  The problem is
that although 32 nodes have been allocated for this job, each "fork"
spawns off a process on the same node, and therefore runs out of
memory.

My question is:  Is there any option to the "fork" command to tell the
child process to go to particular nodes?

Thanks


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

Date: 25 Aug 2008 20:50:43 GMT
From: xhoster@gmail.com
Subject: Re: Perl Fork options
Message-Id: <20080825165045.744$aG@newsreader.com>

BryanBBFan@ca.rr.com wrote:
> I have an application which uses PBS to allocates 32 nodes on a Linux
> Cluster.

Phosphate Buffered Saline?

> A Perl script needs to spawn off 100+ completely independent
> processes from this job.  The Perl use fork to do this.  The script
> came from a shared memory machine where ther was plenty of memory each
> node could access.  The system it needs to run on is not a shared
> memory system, where each node has its own memory.  The problem is
> that although 32 nodes have been allocated for this job, each "fork"
> spawns off a process on the same node, and therefore runs out of
> memory.

And even if it didn't, wouldn't they all be using the same node's CPU
and not spreading out?  Or does "PBS" take care of that (but without
taking care of the memory)?

>
> My question is:  Is there any option to the "fork" command to tell the
> child process to go to particular nodes?

Perl's fork is basically just a wrapper around the OS's fork, at least
if your OS has a fork.

Do you know how you would accomplish what you want in C or something other
than Perl?  If you do and you tell us how you would do it, we might be able
to help you translate that into Perl.

Otherwise, the first thing that comes to my mind is to try system rather
than fork.  The second thing that comes to my mind is that when I use
a grid with SunGridEngine I found that the best way was to learn all the
quirks of SGE and then tell SGE I wanted 100 Perl jobs, not tell Perl I
wanted 100 Perl jobs.  Maybe SGE is so different from "PBS" that this
answer doesn't port.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Mon, 25 Aug 2008 16:47:42 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Regular express for <p>, <ul> and <ol> tags
Message-Id: <v0o5b4lbj4l943hh2e3b7tan1k60jbblee@4ax.com>

Shahid <mirzashahidmahmood@gmail.com> wrote:
>I am parsing an .HTML file that contains following example code:
[snip]
>I am trying to parse all the <p>, <ol> and <ul> tags but couldn't
>succeed yet.
>I am trying following Regular Expression(RE):
>"(<[pP][^>]*>(.*)</[pP]>)|(<[oO][lL][^>]+>(.*)</[oO][lL]>)|(<[uU][lL]
>[^>]+>(.*)</[uU][lL]>)"

HTML is not a regular language! While the extensions to Perl's RE
language might be powerful enough to cover HTML, no sane person would
even try to do so. If you want to parse HTML then use a proper HTML
parser. There are several on CPAN.

>I am using preg_match_all(). 

Undefined subroutine &main::preg_match_all called at [...]

>Remember I am working in PHP.

You must have walked into the wrong room. This here is about Perl. Of
course, I suppose PHP's REs are not even as powerful as Perl's, so
probably trying to parse HTML using PHP's REs is even worse than using
Perl's REs.

>If any one can help me, I will be very grateful to him/her. I need its
>solution urgent.

Use a parser, dude.

jue


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

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 1819
***************************************


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