[26076] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8277 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 25 18:05:36 2005

Date: Mon, 25 Jul 2005 15:05:05 -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 Jul 2005     Volume: 10 Number: 8277

Today's topics:
    Re: Argument list too long (keep reading, it's not the  (Anno Siegel)
    Re: Argument list too long (keep reading, it's not the  <pasdepub.Hugues.de-Mazancourt@lingway.com>
    Re: Argument list too long (keep reading, it's not the  xhoster@gmail.com
    Re: copy contructor <abigail@abigail.nl>
        From number to clearer string <sun_tong@users.sourceforge.net>
    Re: From number to clearer string <null@no.spam>
        Linux distribs lacking perldoc axel@white-eagle.invalid.uk
    Re: Linux distribs lacking perldoc <sherm@dot-app.org>
    Re: paging page trouble <""alexjaquet\"@[no spam]msn.com">
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 25 Jul 2005 13:24:40 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Argument list too long (keep reading, it's not the FAQ)
Message-Id: <dc2p6o$i3o$1@mamenchi.zrz.TU-Berlin.DE>

Hugues de Mazancourt <pasdepub.Hugues.de-Mazancourt@lingway.com> wrote in comp.lang.perl.misc:
> Hi,
> 
> I have a Perl deamon that keeps running, forking other (perl) processes,
> which in turn issue (among other things) system() calls.
> After some time (...), the scripts issue "Argument list too long" to every
> system() that is made, as if there was a global buffer that ran out of
> space.
> I don't have any wildcards in my system() calls, no <*> either.
> 
> My solution was to make the daemon loop a certain number of times, then
> exiting, and have a shell-script that re-lauches the deamon every time it is
> finished. This works, but is little satisfactory, and I'm constantly
> decreasing that "certain number", as new installations raise the problem
> again and again.

MAX_ARGS is a fixed kernel parameter, and each system call starts a new
process.  There is nothing that could "wear out" this way, or you'd see
"Out of memory".

Are you sure your commands aren't collecting some garbage that adds to
their length without changing their function?

Show a minimal code example that exhibits the problem.

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: Mon, 25 Jul 2005 18:46:20 +0200
From: "Hugues de Mazancourt" <pasdepub.Hugues.de-Mazancourt@lingway.com>
Subject: Re: Argument list too long (keep reading, it's not the FAQ)
Message-Id: <dc359g$r6a$1@s1.news.oleane.net>

> Are you sure your commands aren't collecting some garbage that adds to
> their length without changing their function?

As I log the commands (see below), I can check that there is no garbage
collected among usage
>
> Show a minimal code example that exhibits the problem.

Here is - roughly - how my code behaves. The "else" part is taken verbatim
from my source (with some repeatingly code removed). I fork, then prepare
wget's argument and start crawling. It runs every night, with the same data
in $source (which is a loaded from a record in MySQL).

$pid=fork();
if($pid)
{
    push(@pids_to_wait4, $pid);
}
else
{
    my $wget=$self->{wgetpath}?$self->{wgetpath}."/":"";
    $wget.="wget -r --timestamping";
    $wget.=" --level=".$source->intval('level') if($source->param('level'));
    $wget.=" --span-hosts" if($source->true('spanhosts'));
    $wget.=" --domains=".$source->param('domains')
if($source->true('spanhosts') && $source->param('domains'));
    $wget.=" --quota=".$source->param('quota') if($source->param('quota'));
    $wget.=" --wait=1 --random-wait" if($source->true('randomwait'));
    $wget.=" --no-parent" if($source->true('noparent'));
    # ... several lines removed, all looking like
$wget.="--option=".$source->param('option')  if($source->param('option'));
    my $wgetdir=$self->{srcdir};
    $wget.=" --directory-prefix=$wgetdir";
    my $wgetlog=$self->my_tmpfile($source->name(), '.wgetlog');
    $wget.=" -nv --html-extension --output-file=$wgetlog";
    $wget.=" --cookies=on --load-cookies=".$source->param('cookiefile')
if($source->param('cookiefile'));
    $wget.=" \"".$source->param('url')."\"";
    $self->logger()->message("Crawler", "Starting WGET: $wget");
    system($wget); # And here, sometimes (...) I get "Argument list too
long"
}

Best,

Hugues




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

Date: 25 Jul 2005 17:04:03 GMT
From: xhoster@gmail.com
Subject: Re: Argument list too long (keep reading, it's not the FAQ)
Message-Id: <20050725130403.184$ms@newsreader.com>

"Hugues de Mazancourt" <pasdepub.Hugues.de-Mazancourt@lingway.com> wrote:
> > Are you sure your commands aren't collecting some garbage that adds to
> > their length without changing their function?
>
> As I log the commands (see below), I can check that there is no garbage
> collected among usage

You can check, but do you actually check?

>     $self->logger()->message("Crawler", "Starting WGET: $wget");

add

$self->logger()->message("Crawler", "Length for WGET: ". length $wget);

>     system($wget); # And here, sometimes (...) I get "Argument list too
> long"

What do you mean you "get" that?  You don't seem to be checking either
the return value of system or $?.  Where do you get it?

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: 25 Jul 2005 22:04:36 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: copy contructor
Message-Id: <slrndeaofk.7fo.abigail@alexandra.abigail.nl>

Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMMMCCCXLV
September MCMXCIII in <URL:news:dc0ndi$7pg$1@mamenchi.zrz.TU-Berlin.DE>:

[ Inside-Out Objects ]

{}  
{}  Well, paradise.  A sunlit Caribbean island with no inheritance tax.  The
{}  one thing I don't see at a glance is how you would do multiple inheritance
{}  that way.  Your object *is* an object of the base class, only blessed
{}  into yours.  It can't be physically be many structures at once.


If you're inheriting from two classes who use a different structure,
it's going to be hard. With different structures, you'll have to resort
to a has-a relationship, and dispatch all the methods of said class.

If you are inheriting from two classes that use the same structure, you
might be lucky, and will be able to do something by breaking encapsulation
and merging the objects. If both classes use refs to hashes, and they don't
use the same attributes, you can fill on hash with the content of the other.
Or you use a has-a relationship.

If the classes you want to inherit from are Inside-Out Objects, and their
constructors only construct (and don't initialize) the object, multiple
inheritance is easy:

    #!/usr/bin/perl

    use strict;
    use warnings;
    no warnings qw /syntax/;


    package Floor::Wax; {
        use Scalar::Util 'refaddr';
    
        my %colour;
    
        sub DESTROY {
            my $self = shift;
            delete $colour {refaddr $self};
        }

        sub new  {bless \do {my $v} => shift;}
        
        sub init {
            my $self = shift;
            $colour {refaddr $self} = "yellow";
            $self;
        }

        sub colour {
            my $self = shift;
            $colour {refaddr $self};
        }
    }
        
    package Dessert::Topping; {
        use Scalar::Util 'refaddr';

        my %colour;

        sub DESTROY {
            my $self = shift;
            delete $colour {refaddr $self};
        }

        sub new  {bless \do {my $v} => shift;}

        sub init {
            my $self = shift;
            $colour {refaddr $self} = "white";
            $self;
        }

        sub colour {
            my $self = shift;
            $colour {refaddr $self};
        }
    }

    package Perl; {
        our @ISA = qw /Floor::Wax Dessert::Topping/;

        sub init {
            my $self = shift;
            $self -> Floor::Wax::init;
            $self -> Dessert::Topping::init;
        }

        sub colour {
            my $self = shift;
    
            sprintf "%s and %s" => $self -> Floor::Wax::colour,
                                   $self -> Dessert::Topping::colour;
        }
    }

    package main;

    my $p = Perl -> new -> init;

    print $p -> colour, "\n";


    __END__
    yellow and white



Abigail
-- 
# Count the number of lines; code doesn't match \w. Linux specific.
()=<>;$!=$=;($:,$,,$;,$")=$!=~/.(.)..(.)(.)..(.)/;
$;++;$*++;$;++;$*++;$;++;`$:$,$;$" $. >&$*`; 


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

Date: Mon, 25 Jul 2005 15:18:44 -0400
From: * Tong * <sun_tong@users.sourceforge.net>
Subject: From number to clearer string
Message-Id: <pan.2005.07.25.19.18.43.119862@users.sourceforge.net>

Hi, 

Is any Perl modules that can translate number like 10987654321 into
clearer to read string 10,987,654,321? and back?

I don't know what this kind of transformation called, so I don't know how
to search. thanks.

-- 
Tong (remove underscore(s) to reply)
  *niX Power Tools Project: http://xpt.sourceforge.net/
  - All free contribution & collection


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

Date: Mon, 25 Jul 2005 14:46:15 -0500
From: Todd <null@no.spam>
Subject: Re: From number to clearer string
Message-Id: <dc3fi7$k7v$1@home.itg.ti.com>

* Tong * wrote:
> Hi, 
> 
> Is any Perl modules that can translate number like 10987654321 into
> clearer to read string 10,987,654,321? and back?
> 
> I don't know what this kind of transformation called, so I don't know how
> to search. thanks.
> 

Hmmm, number and commas	

what if I try

perldoc -q commas

Found in /apps/perl/5.9.1/lib/5.9.1/pod/perlfaq5.pod
      How can I output my numbers with commas added?

              This subroutine will add commas to your number:

                      sub commify {
                         local $_  = shift;
                         1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
                         return $_;
                         }

              This regex from Benjamin Goldberg will add commas to
              numbers:

                 s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1,/g;

              It is easier to see with comments:

                 s/(
                     ^[-+]?            # beginning of number.
                     \d{1,3}?          # first digits before first comma
                     (?=               # followed by, (but not included 
in the match) :
                        (?>(?:\d{3})+) # some positive multiple of three 
digits.
                        (?!\d)         # an *exact* multiple, not x * 3 
+ 1 or whatever.
                     )
                    |                  # or:
                     \G\d{3}           # after the last group, get three 
digits
                     (?=\d)            # but they have to have more 
digits after them.
                 )/$1,/xg;



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

Date: Mon, 25 Jul 2005 14:46:06 GMT
From: axel@white-eagle.invalid.uk
Subject: Linux distribs lacking perldoc
Message-Id: <OW6Fe.29376$Pf3.2323@fe2.news.blueyonder.co.uk>

Having recently installed Linux Mandrake 10.1 onto a very cheap ex-M$
XP system I had purchased a couple of years ago to give myself
Internet access over Christmas and Hogmanay, I was quite surprised
to see that 'perldoc' was not installed.

Perhaps it was just the version of Mandrake I had... or are the
Linux distros starting to mess around with even more meddling in
what should be straight-forward and full installations? [OT]

This is not an idle thought - it may just be possible that many
people do not have working 'perldoc perlX' on their system, although
'man perlX' works, albeit not for modules.

[OT] Off-topic rant. Why cannot the newer linux distros be content
to let standards remain standards.

I don't want to waste more than half-an-hour figuring out how to
disable vim perl language specific plugins which make it impossible
to cut-and-paste. Maybe good to have them... if and only if I want
them.

Nor do I do not want my rm, cp, mv commands aliased to anything else in
any way, least of all in such a way that I have to waste time
finding where they are aliased and then disabling that.


Axel



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

Date: Mon, 25 Jul 2005 11:43:49 -0400
From: Sherm Pendley <sherm@dot-app.org>
Subject: Re: Linux distribs lacking perldoc
Message-Id: <m2br4qki16.fsf@Sherm-Pendleys-Computer.local>

axel@white-eagle.invalid.uk writes:

> Perhaps it was just the version of Mandrake I had... or are the
> Linux distros starting to mess around with even more meddling in
> what should be straight-forward and full installations? [OT]

Why should a full installation of Perl be the default? Few computer users
know what Perl is or need its documentation. Most just want to send email
and surf the web - for those folks, the full pods directory and perldoc tool
is just wasted HD space.

For that reason, many Linux distros choose to provide perldoc and pods as a
separate package. Debian, for instance, has packages called "perl-base" and
"perl-doc".

Many distros also ask upon installation what the machine will be used for -
Server, Desktop, Developer, etc. I haven't checked, by presumably the Developer
configuration should install the relevant docs package by default.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Mon, 25 Jul 2005 18:31:43 +0200
From: Alexandre Jaquet <""alexjaquet\"@[no spam]msn.com">
Subject: Re: paging page trouble
Message-Id: <42e51403$0$1150$5402220f@news.sunrise.ch>

samwyse a écrit :
> Alexandre Jaquet > wrote:
> 
>> Hi
>>
>> I got a little trouble while trying to create index of pages
>>
>> I want to to something like :
>>
>> <0-> <-1-> <-2-> <-3->
>> once user click <-3-> new page counter start with
>>
>> <4-> <-5-> <-6-> <-7->  ..
>>
>> I do like that :
>>
>>     local our  $nb_page = arrondi ($total / 4, 1);
>>     local our  $min_index = $query->param("min_index") || '0';
>>     local our  $max_index = $query->param("max_index") || '4';
>>     local our  $page_nbr = $query->param("pagenbr") ;
>>     local our  $page_start = $query->param("page_start") || '0';;
>>     local our  $page_end = $query->param("page_end") || '4';;
> 
> [snip]
> 
> It looks to me like your params are getting out of sync.  Instead of 
> passing everything each time, why not calculate it all from the current 
> page number?  This is untested code, but I think it does what you intend.
> 
>   use constant PAGESPAN => 4;
>   use constant ITEMSPERPAGE => 4;
>   my $nb_page = arrondi ($total / ITEMSPERPAGE, 1);
>   my $page_nbr = $query->param('pagenbr');
>   my $page_start = max(0, $page_nbr - PAGESPAN )
>   my $page_end = min(nb_page, $page_nbr + PAGESPAN )
>   my $min_index = ITEMSPERPAGE  * $page_nbr;
>   my $max_index = $min_index + ITEMSPERPAGE - 1;
> 
> BTW, why the 'local our' in your code?  Is that your own convention, or 
> just something I've not seen before?  Also, it's a good idea to not use 
> any constants other than 0 or 1 in your code.  You seem to be using 4 
> for two distinct things; you've just made trouble for yourself if you 
> ever want to change one and not the other.

I use mod_perl 2.00 and I don't want to share that datas between queries

anyway thx for your help


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

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


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