[27922] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9286 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 12 14:06:06 2006

Date: Mon, 12 Jun 2006 11:05:06 -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, 12 Jun 2006     Volume: 10 Number: 9286

Today's topics:
        ANNOUNCE: CGI::Session::ExpireSessions V 1.08 <ron@savage.net.au>
    Re: best method to perform operations on word lists <massion@gmx.de>
    Re: best method to perform operations on word lists <rvtol+news@isolution.nl>
        Can't find syntax error <nomail@domain.tld>
    Re: Can't find syntax error <simon.chao@fmr.com>
    Re: Can't find syntax error <mritty@gmail.com>
    Re: Determining lvalue context xhoster@gmail.com
    Re: Determining lvalue context xhoster@gmail.com
        GD text positioning <whoever@whereever.com>
    Re: GD text positioning <daveandniki@ntlworld.com>
    Re: GD text positioning <whoever@whereever.com>
    Re: GD text positioning <daveandniki@ntlworld.com>
    Re: Help - Inline::C arrayref deref? xhoster@gmail.com
    Re: Help - Inline::C arrayref deref? xhoster@gmail.com
    Re: I received eBay Star Developer Award <tadmc@augustmail.com>
    Re: I received eBay Star Developer Award <redleg510@comcast.net>
    Re: I received eBay Star Developer Award (Hrundi V. Bakshi)
    Re: memory efficiency - for loop with reverse list <DJStunks@gmail.com>
    Re: Question: Inline::C module packaging? xhoster@gmail.com
        read a webpage with username/password jiehuang001@hotmail.com
    Re: read a webpage with username/password <mritty@gmail.com>
    Re: script to find the files with very long names <tadmc@augustmail.com>
        setting linux display for Cron <yg_blah_@this_domain.bla>
    Re: setting linux display for Cron delfin_soft@homoludens.elte.hu
    Re: setting linux display for Cron <yg_blah_@this_domain.bla>
    Re: Using tee with Perl's system command <jgibson@mail.arc.nasa.gov>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 12 Jun 2006 02:19:38 GMT
From: Ron Savage <ron@savage.net.au>
Subject: ANNOUNCE: CGI::Session::ExpireSessions V 1.08
Message-Id: <J0r0tp.1oox@zorch.sf-bay.org>

The pure Perl module CGI::Session::ExpireSessions V 1.08
is available immediately from CPAN,
and from http://savage.net.au/Perl-modules.html.

On-line docs, and a *.ppd for ActivePerl are also
available from the latter site.

An extract from the docs:

1.08  Mon Jun 12 11:32:00 2006
	- Version 1.07 was never uploaded to CPAN. It was just available from my site,
and was meant for testing the proposed callback mechanism in CGI::Session::find.
That mechanism was changed before CGI::Session 4.14 was released, so my module's
code now changes to match.
		Also, since CGI::Session has been patched so its sub find() no longer updates
the session's access time, my module now uses atime instead of ctime when
checking for expiry
		
1.07  Wed Apr 12 14:36:00 2006
	- Add method expire_sessions() which uses CGI::Session's V 4.14 method find()
to find all sessions, 	and then expires sessions if appropriate.
All this without evaling the contents of the session and which therefore
resolves RT bug 16069
	- Document the new method and the new parameters to new()
	- Add test t/03-delete-via-find.t to test the new code
	- Add examples/expire-set.pl to demonstrate and document further ways of using
the new method
	- Make CGI::Session V 4.13 a prerequisite




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

Date: 12 Jun 2006 07:21:39 -0700
From: "Francois Massion" <massion@gmx.de>
Subject: Re: best method to perform operations on word lists
Message-Id: <1150122098.978994.242780@j55g2000cwa.googlegroups.com>

I have come up with something which seems to work (partially). For my
current purpose it'll do the trick but any suggestion for optimization
is welcome:

(=2E..)
chomp(my $prev =3D <TERMS>);

my @reducedlist =3D $prev;

while ( <TERMS> ) {
   chomp;
push @reducedlist, $_ unless (/^$prev/ && length ($_)- length($prev)<3)
; # I can set the maximum lenth of a suffix here
   $prev =3D $_;
}
print "$_\n" for @reducedlist;

[Amazing to see how much time people can invest in a few lines of code
when they are no professionals ;-)! ]

Francois

Bart Van der Donck schrieb:

> Francois Massion wrote:
>
> > [...]
> > >   #!perl
> > >   use strict; use warnings;
> > >   my $list =3D
> > >   "=FCberzeugt
> > >   =FCberzeugt,
> > >   =FCberzogen
> > >   =FCberzogen,
> > >   =FCberzogen.
> > >   =FCblich
> > >   =FCbliche
> > >   =FCblichen
> > >   =FCblicherweise";
> > >   my @terms =3D split /\n/, $list;
> > >   my $prev =3D 'nonesuch584685542256RANOM58544';
> >
> > This didn't modify the list.
>
> I didn't mean to modify $list; the new content is in @terms. If you
> want $list to contain the new words, you can use something like this at
> the end of the program.
>
>    $list =3D join "\n", @terms;
>
> > Maybe the reason is the $prev definition.
>
> $prev has no direct importance here, it's only required that it should
> not be present in @terms, because it is used to delete double entries
> from @terms.
>
> > >   s/(\.|,|e|en|e,|en,|e\.|en\.)$// for @terms;
> > I also tried Dr. Ruud's regex but it would have to be rewritten for
> > each language.
>
> That is correct, hence my thoughts about language files. My code is a
> very brute algorithm - it only strips out the following from the end of
> each line:
>
>    . , e en e en, e. en.
>
> If you are planning to use this for different languages, you would
> obviously need to modify those patterns each time.
>=20
> --=20
>  Bart



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

Date: Mon, 12 Jun 2006 17:40:46 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: best method to perform operations on word lists
Message-Id: <e6k95k.e0.1@news.isolution.nl>

Francois Massion schreef:

> I have come up with something which seems to work (partially). For my
> current purpose it'll do the trick but any suggestion for optimization
> is welcome:
>
> (...)
> chomp(my $prev = <TERMS>);
>
> my @reducedlist = $prev;
>
> while ( <TERMS> ) {
>    chomp;
> push @reducedlist, $_ unless (/^$prev/ && length ($_)-
> length($prev)<3) ; # I can set the maximum lenth of a suffix here
>    $prev = $_;
> }
> print "$_\n" for @reducedlist;
>
> [Amazing to see how much time people can invest in a few lines of code
> when they are no professionals ;-)! ]


#!/usr/bin/perl
  use strict ;
  use warnings ;

  my @reducedlist ;
  my $prev = quotemeta '......' ;

  while ( <> )
  {
    s/\W+$// ;  # chop-chop

    next if / \A $prev .{0,3} \z /x ;

    push @reducedlist, $_ ;
    $prev = quotemeta ;
  }
  print "$_\n" for @reducedlist;

(untested)

-- 
Affijn, Ruud

"Gewoon is een tijger."




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

Date: Mon, 12 Jun 2006 11:18:06 -0400
From: Eric <nomail@domain.tld>
Subject: Can't find syntax error
Message-Id: <128r1gb7vh2rib6@corp.supernews.com>

I've been looking at my script for a day now, and I cannot find my
syntax error.  It says its on line 34, and 45.

syntax error at ./test.pl line 28, near ") {"
syntax error at ./test.pl line 39, near "}"
Execution of ./test.pl aborted due to compilation errors.


Any ideas?

#!/usr/bin/perl -w
use strict;
use LWP::UserAgent;

 my $ua = LWP::UserAgent->new;
 $ua->timeout(10);
 $ua->agent("Stress Test/0.1");
 $ua->cookie_jar({ file => "./cookies.txt", AutoSave => 1 });
 $ua->protocols_forbidden( ['mailto'] );



parse_config("./test1.conf");






sub parse_config () {
    my $conf = shift;
    my $response;
    open FILE, "< " . $conf || die("Cannot open $conf. " . $!);
    while(<FILE>)  {
        print $_;
        my @commands = split("=",$_);
        print $commands[0] . " - " . $commands[1];
        switch ($commands[0]) {
             case URL {
                 $response = $ua->get($commands[1]);
                 if ($response->is_success) {
                     print_response();
                 }else{
                     die("GET " . $commands[1] . " failed. " .
$response->status_line);
                 } # end if
             } # end case
        } # end switch

    } # end while
    close(FILE);
} # end parse_config






sub print_response {
    #print "Response-content....: " . $response->content     . "\n";
    print "Response-code.......: " . $response->code        . "\n";
    print "Response-message....: " . $response->message     . "\n";
    #print "Response-header.....: " . $response->header      . "\n";
    print "Response-request....: " . $response->request     . "\n";
    print "Response-previous...: " . $response->previous    . "\n";
    print "Response-status_line: " . $response->status_line . "\n";
    print "Response-base.......: " . $response->base        . "\n";
    print "Response-is_info....: " . $response->is_info     . "\n";
    print "Response-is_success.: " . $response->is_success  . "\n";
    print "Response-is_redirect: " . $response->is_redirect . "\n";
    print "Response-is_error...: " . $response->is_error    . "\n";
    #print "Response-as_string..: " . $response->as_string   . "\n";
}


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

Date: 12 Jun 2006 08:28:34 -0700
From: "it_says_BALLS_on_your forehead" <simon.chao@fmr.com>
Subject: Re: Can't find syntax error
Message-Id: <1150126114.064981.148120@g10g2000cwb.googlegroups.com>


Eric wrote:
> I've been looking at my script for a day now, and I cannot find my
> syntax error.  It says its on line 34, and 45.
>

why do you say 34 and 45, when Perl tells you 28 and 39 below?

> syntax error at ./test.pl line 28, near ") {"
> syntax error at ./test.pl line 39, near "}"
> Execution of ./test.pl aborted due to compilation errors.
>
>
> Any ideas?
>
> #!/usr/bin/perl -w

instead of using the -w switch:
use warnings;

> use strict;
> use LWP::UserAgent;
>
>  my $ua = LWP::UserAgent->new;
>  $ua->timeout(10);
>  $ua->agent("Stress Test/0.1");
>  $ua->cookie_jar({ file => "./cookies.txt", AutoSave => 1 });
>  $ua->protocols_forbidden( ['mailto'] );
>
>
>
> parse_config("./test1.conf");
>
>
>
>
>
>
> sub parse_config () {

remove the parens here.

>     my $conf = shift;
>     my $response;
>     open FILE, "< " . $conf || die("Cannot open $conf. " . $!);

use a lexical file handle, and after the "<", you are concatenating.
try using a comma operator.

open my $fh, '<', $conf or die "Cannot open $conf: $!\n";

>     while(<FILE>)  {
>         print $_;

print by itself is sufficient here.

>         my @commands = split("=",$_);

no need to explicitly split $_ here.

my @commands = split /=/;

>         print $commands[0] . " - " . $commands[1];
>         switch ($commands[0]) {
>              case URL {

switch and case...is this Perl? i haven't researched this yet. looks
more like javascript to me...

could be more, but that's what i noticed off the bat. HTH

>                  $response = $ua->get($commands[1]);
>                  if ($response->is_success) {
>                      print_response();
>                  }else{
>                      die("GET " . $commands[1] . " failed. " .
> $response->status_line);
>                  } # end if
>              } # end case
>         } # end switch
>
>     } # end while
>     close(FILE);
> } # end parse_config
>
>
>
>
>
>
> sub print_response {
>     #print "Response-content....: " . $response->content     . "\n";
>     print "Response-code.......: " . $response->code        . "\n";
>     print "Response-message....: " . $response->message     . "\n";
>     #print "Response-header.....: " . $response->header      . "\n";
>     print "Response-request....: " . $response->request     . "\n";
>     print "Response-previous...: " . $response->previous    . "\n";
>     print "Response-status_line: " . $response->status_line . "\n";
>     print "Response-base.......: " . $response->base        . "\n";
>     print "Response-is_info....: " . $response->is_info     . "\n";
>     print "Response-is_success.: " . $response->is_success  . "\n";
>     print "Response-is_redirect: " . $response->is_redirect . "\n";
>     print "Response-is_error...: " . $response->is_error    . "\n";
>     #print "Response-as_string..: " . $response->as_string   . "\n";
> }



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

Date: 12 Jun 2006 08:30:10 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Can't find syntax error
Message-Id: <1150126210.300306.156750@g10g2000cwb.googlegroups.com>

Eric wrote:
> I've been looking at my script for a day now, and I cannot find my
> syntax error.  It says its on line 34, and 45.
>
> syntax error at ./test.pl line 28, near ") {"
> syntax error at ./test.pl line 39, near "}"
> Execution of ./test.pl aborted due to compilation errors.
>
>
> Any ideas?
>
> #!/usr/bin/perl -w
> use strict;
> use LWP::UserAgent;
<snip>

>         switch ($commands[0]) {
>              case URL {
>                  $response = $ua->get($commands[1]);
>                  if ($response->is_success) {
>                      print_response();
>                  }else{
>                      die("GET " . $commands[1] . " failed. " .
> $response->status_line);
>                  } # end if
>              } # end case
>         } # end switch


Two problems.  One, you forgot to actually *use* the Switch module.
'switch' and 'case' are not Perl built-ins.  You need to use the Switch
module in order to access them.  Second, 'URL' is a bareword.  That's
not allowed under use strict.

Paul Lalli



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

Date: 12 Jun 2006 16:51:48 GMT
From: xhoster@gmail.com
Subject: Re: Determining lvalue context
Message-Id: <20060612125157.375$g9@newsreader.com>

"Ferry Bolhar" <bol@adv.magwien.gv.at> wrote:
> Xho:
>
> > Why not $docid->next_vtx_page()?
>
> Because the object $docid does not provide methods. When a said
> "object", I meant just a hash reference with some internal values used
> by the VTX system. next_vtx_page() isn't a method, it's just a normal
> function.
>
> > You have to return something magical.  If the magical thing you return
> gets
> > assigned to, you were called in a lvalue context.  Otherwise, you
> > weren't.
>
> What do you mean with "something magical"?

I'm not familiar with all the magic in Perl.  A tied scalar is the one
that pops to mind in this case, but there may be others.

>
> >> Does someone have already experience with lvalue
> >> subroutines like this one?
> >
> > Yes, but not good ones.
>
> Why not?

It seemed like one of those things better in theory than in practise,
with the "How do I know if it is assinged to or not?" problem being
one of the reasons.

I've just found that resorting to either the separate getter/setter
methods, or one method which if given N arguments is a getter, or
if given N+1 arguments is a setter+getter, to be easier.

Maybe now that I am more familiar with tied objects, I would have a better
experience.

Xho

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


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

Date: 12 Jun 2006 17:05:45 GMT
From: xhoster@gmail.com
Subject: Re: Determining lvalue context
Message-Id: <20060612130554.505$Co@newsreader.com>

"Ferry Bolhar" <bol@adv.magwien.gv.at> wrote:
> Ben Morrow:
>
> >> next_vtx_page($docid) = $new_index;
> >
> > This is probably bad design. You would be better with separate get/set
> > functions.
>
> Do you think that Perl's "keys" function is badly designed?

I certainly wouldn't argue that it is exceptionally well designed.
The results of assigning to it are certainly not intuitive.  On the
other hand, it is an advanced feature almost never actually needed,
so hiding it into some little nook isn't that bad, and it does avoid the
introduction of yet another keyword, which for a general purpose language
is not an unworthy goal.  You don't seem to be writing a general purpose
language, so that doesn't apply to you.

> It works the
> same way as I hope to get my next_vtx_page() function working: when
> used on the right-hand side, it returns somewhat; on the left side; it
> sets somewhat. Where is the bad design here?

Well, the thing that it gets and thing that it sets are almost, but not
quite, entirely unrelated.  That isn't such a great design.

Xho

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


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

Date: Mon, 12 Jun 2006 14:17:47 +0100
From: "IanW" <whoever@whereever.com>
Subject: GD text positioning
Message-Id: <e6jphr$kv3$1@blackmamba.itd.rl.ac.uk>

I am writing some text on an image like this:

$im->stringFT($colour,"c:/winnt/fonts/verdana.ttf",8,0,10,10,"Processor 
Usage");

The problem is the positioning. It seems to start 10 pixels from the left of 
the image OK, but only 2 pixels down on the y coordinate. In fact, the 
coords of the bottom left edge of the "P" in "Processor" is 10,10. Does it 
really render it starting from there? That isn't even the bottom-left edge 
of the bounding box either, because there's the tail of the "g" to consider.

Any ideas how can I accurately position the text?

Ian 




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

Date: Mon, 12 Jun 2006 15:55:54 +0200
From: "Dave" <daveandniki@ntlworld.com>
Subject: Re: GD text positioning
Message-Id: <448d727b$0$864$ba4acef3@news.orange.fr>


"IanW" <whoever@whereever.com> wrote in message 
news:e6jphr$kv3$1@blackmamba.itd.rl.ac.uk...
>I am writing some text on an image like this:
>
> $im->stringFT($colour,"c:/winnt/fonts/verdana.ttf",8,0,10,10,"Processor 
> Usage");
>
> The problem is the positioning. It seems to start 10 pixels from the left 
> of the image OK, but only 2 pixels down on the y coordinate. In fact, the 
> coords of the bottom left edge of the "P" in "Processor" is 10,10. Does it 
> really render it starting from there? That isn't even the bottom-left edge 
> of the bounding box either, because there's the tail of the "g" to 
> consider.
>
> Any ideas how can I accurately position the text?
>
> Ian
>

Yes it does start from there. It also returns the bounding box but you are 
throwing away the return value, try:

my $bounds = 
$im->stringFT($colour,"c:/winnt/fonts/verdana.ttf",8,0,10,10,"Processor 
Usage");

and you will find that:
 @bounds[0,1]  Lower left corner (x,y)
 @bounds[2,3]  Lower right corner (x,y)
 @bounds[4,5]  Upper right corner (x,y)
 @bounds[6,7]  Upper left corner (x,y)(see the man page of GD for further 
details)Dave 




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

Date: Mon, 12 Jun 2006 15:58:34 +0100
From: "IanW" <whoever@whereever.com>
Subject: Re: GD text positioning
Message-Id: <e6jveq$nfn$1@blackmamba.itd.rl.ac.uk>

"Dave" <daveandniki@ntlworld.com> wrote in message 
news:448d727b$0$864$ba4acef3@news.orange.fr...

> Yes it does start from there. It also returns the bounding box but you are 
> throwing away the return value, try:
>
> my $bounds = 
> $im->stringFT($colour,"c:/winnt/fonts/verdana.ttf",8,0,10,10,"Processor 
> Usage");

that gives:

9,0-------------101,0
|                               |
|                               |
9,13-----------101,13

but the bottom-left edge of the P isn't the same as the bottom left edge of 
the bounding box, partly because of the tail on the "g" but also because the 
bounding box seems to add an extra pixel or two padding round the text, even 
accounting for the anti-aliasing. So I'm still stuck on how to position it 
accurately.

Regards
Ian 




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

Date: Mon, 12 Jun 2006 17:43:54 +0200
From: "Dave" <daveandniki@ntlworld.com>
Subject: Re: GD text positioning
Message-Id: <448d8bc4$0$1030$ba4acef3@news.orange.fr>


"IanW" <whoever@whereever.com> wrote in message 
news:e6jveq$nfn$1@blackmamba.itd.rl.ac.uk...
> "Dave" <daveandniki@ntlworld.com> wrote in message 
> news:448d727b$0$864$ba4acef3@news.orange.fr...
>
>> Yes it does start from there. It also returns the bounding box but you 
>> are throwing away the return value, try:
>>
>> my $bounds = 
>> $im->stringFT($colour,"c:/winnt/fonts/verdana.ttf",8,0,10,10,"Processor 
>> Usage");
>
> that gives:
>
> 9,0-------------101,0
> |                               |
> |                               |
> 9,13-----------101,13
>
> but the bottom-left edge of the P isn't the same as the bottom left edge 
> of the bounding box, partly because of the tail on the "g" but also 
> because the bounding box seems to add an extra pixel or two padding round 
> the text, even accounting for the anti-aliasing. So I'm still stuck on how 
> to position it accurately.
>
> Regards
> Ian
>

With a true type font your starting position is effectively x where the 
first character will start being drawn from and the y the baseline, the font 
metrics will determine the bounding rectangle (imagine an invisible box 
around each character and a line in the box showing where the baseline is).

The off-by-one issue you mention is not so related to fonts but is an 
inherant issue in the idea of bounding rectangles (inclusive or 
exclusive...) and is decided by convention in the tool you are using.

You should probably ignore the bounding box as such and just think in terms 
of where you want the baseline (rather than the top corner) of your string 
to start relative to the image.





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

Date: 12 Jun 2006 16:35:08 GMT
From: xhoster@gmail.com
Subject: Re: Help - Inline::C arrayref deref?
Message-Id: <20060612123517.233$mW@newsreader.com>

"Sisyphus" <sisyphus1@nomail.afraid.org> wrote:
> <xhoster@gmail.com> wrote in message
> .
> .
> >
> > I stopped the leaks by adding sv_2moral in two places:
> >
> >         AV* av_pcm=newAV() ;    // Dereferenced PCM input array
> >         sv_2mortal(av_pcm);
> > (Althought I don't particularly like this.  The only reason the newAV()
> > seems to here is to prevent errors in the case that the thing passed in
> > is not an array reference, which should probably be handled down in the
> > "if", not up here.
> >
>
> How does one conclusively detect the leakage ? I didn't really expect
> there to be any leaks (and couldn't detect any) - but on second thoughts
> perhaps there *is* a need to clean up av_pcm.

For the record, on Linux I just added this in the C code to detect
the leaks:

foreach (1..1_000) {
  foreach (1..10_000) {
    @amps=test(2,$x);
  }
  print +(`ps -p $$ -o rss `)[1];
};




> > And:
> >
> >         sv_2mortal(av_ret);
> >         return av_ret;
> >
>
> Looks to me that the C code (generated by xsubpp from the XS code)
> mortalises av_ret - so this should not achieve anything. Here's the
> relevant code from that C file:
>
> XS(XS_main_test); /* prototype to pass -Wmissing-prototypes */
> XS(XS_main_test)
> {
>     dXSARGS;
>     if (items != 2)
>  Perl_croak(aTHX_ "Usage: main::test(mode, rpcm)");
>     {
>  int mode = (int)SvIV(ST(0));
>  SV * rpcm = ST(1);
>  AV * RETVAL;
>
>  RETVAL = test(mode, rpcm);
>  ST(0) = newRV((SV*)RETVAL);
>  sv_2mortal(ST(0));

newRV increments the ref count, so this mortalization only accounts
for the reference held in ST(0), not the one held in av_ret,
which needs to be mortalized separately.


>     }
>     XSRETURN(1);
> }
>
> Also, I was puzzled by the SvREFCNT_inc() call in the original code.

You are right, that also shouldn't be there.  I had cleaned it up but
forgot to mention doing so.  That one is particularly pernicious, because
it causes the leak to occur in the regular Perl code.

This stub won't leak (much) because althougth the refcount on @$x increases
there is only ever one @$x to get leaked.

my $x=[2]
foreach (1..1_000) {
  foreach (1..10_000) {
    @amps=test2(2,$x);
  }
  print +(`ps -p $$ -o rss `)[1];
};

However, if you move the my $x=[2] to the inner most loop, then it will
leak unless you remove the SvREFCNT_inc()

Xho

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


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

Date: 12 Jun 2006 16:55:22 GMT
From: xhoster@gmail.com
Subject: Re: Help - Inline::C arrayref deref?
Message-Id: <20060612125531.081$C6@newsreader.com>

xhoster@gmail.com wrote:
> "Sisyphus" <sisyphus1@nomail.afraid.org> wrote:
> > <xhoster@gmail.com> wrote in message
> > .
> > .
> > >
> > > I stopped the leaks by adding sv_2moral in two places:
> > >
> > >         AV* av_pcm=newAV() ;    // Dereferenced PCM input array
> > >         sv_2mortal(av_pcm);
> > > (Althought I don't particularly like this.  The only reason the
> > > newAV() seems to here is to prevent errors in the case that the thing
> > > passed in is not an array reference, which should probably be handled
> > > down in the "if", not up here.
> > >
> >
> > How does one conclusively detect the leakage ? I didn't really expect
> > there to be any leaks (and couldn't detect any) - but on second
> > thoughts perhaps there *is* a need to clean up av_pcm.
>
> For the record, on Linux I just added this in the C code to detect
> the leaks:

Argh.  I added that in the Perl code, of course, not the C code.

>
> foreach (1..1_000) {
>   foreach (1..10_000) {
>     @amps=test(2,$x);
>   }
>   print +(`ps -p $$ -o rss `)[1];
> };
>

Xho

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


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

Date: Mon, 12 Jun 2006 08:00:08 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: I received eBay Star Developer Award
Message-Id: <slrne8qpao.r5k.tadmc@magna.augustmail.com>


[ F'ups set to comp.lang.perl.misc ]


redleg <redleg510@comcast.net> wrote:
> Lumpy wrote:
>> Ignoramus14786 wrote:
>> > I am at eBay developers conference right
>> > now, and they gave me a Star
>> > Developer Award for writing a Net::eBay perl module...
>>
>> You should have the perl appraised by a licensed
>> perlologist.


> You have Perl ?  Try a colon flush.


I knew that colons were buffered, so I tried:

   $| = ':';

but that Doesn't Work.

(I can tell because my face is still wearing its irregular expression.)



I'm off to CPAN to see if Bioperl or one of the IO::* modules
can help with this urgent problem...


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 12 Jun 2006 07:56:34 -0700
From: "redleg" <redleg510@comcast.net>
Subject: Re: I received eBay Star Developer Award
Message-Id: <1150124194.624201.7520@f6g2000cwb.googlegroups.com>


Chris Barts wrote:
> On Sun, 11 Jun 2006 10:30:00 -0700, caroball wrote:
>
> >
> > Chris Barts wrote:
> >> On Sat, 10 Jun 2006 17:09:21 -0700, caroball wrote:
> >>
> >> >
> >> > Congrats from a long long ago COBAL programmer
> >>
> >> That must have been frustrating: Hacking away at COBAL code while the
> >> COBOL programmers got all the glory. ;)
> >>
> >> --
> > MAYBE that's why my stuff always got kicked out with 9000 error
> > messages - I did some FORTRAIN & AUTOMOBILECODDER too
>
> Ha! Those are some good ones. :)
>
> --
> My address happens to be com (dot) gmail (at) usenet (plus) chbarts,
> wardsback and translated.
> It's in my header if you need a spoiler.

COBOL, PASCAL, and FORTRAN.   There's a Fortran street in Silicon
Valley, I think its in Santa Clara or Sunnyvale, north of Hwy 237.



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

Date: Mon, 12 Jun 2006 15:44:47 GMT
From: harley_davidonX@mailcity.com (Hrundi V. Bakshi)
Subject: Re: I received eBay Star Developer Award
Message-Id: <448d8c52.89432567@news.east.earthlink.net>

On Sat, 10 Jun 2006 19:32:37 GMT, Ignoramus14786
<ignoramus14786@NOSPAM.14786.invalid> wrote:

>I am at eBay developers conference right now, and they gave me a Star
>Developer Award for writing a Net::eBay perl module. That perl module
>allows developers to send queries to eBay API by making very simple
>perl calls. Useful for website developers or people like me who like
>to ist stuff on ebay without going to their website. 
>
>Apparently, I am one of about 8 or so people who received the award
>this year.
>
>Pictures will be provided after I get back home from conference.
>
>This module is described at my site www.net-ebay.org.
>
>i
>

Congratulations sir,

I would give anything to know just a fraction of what you know about
programming: Perl or whatever.

Only, I am not capable of learning such complicated tasks.

More good fortunes to come to you, yes.

Hrundi V. Bakshi


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

Date: 12 Jun 2006 09:16:26 -0700
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: memory efficiency - for loop with reverse list
Message-Id: <1150128985.996033.94990@c74g2000cwc.googlegroups.com>


tuser wrote:
> James wrote:
> > foreach (reverse 1 .. 1_000_000)
> > {
> >    sleep 5;
> > }
> >
> > Used 9.4% of my memory (second only to firefox), using perl 5.8.7
> >
> > ymmv
>
> Thanks very much for your answer.
>
> I am running activestate perl v5.8.7 (Windows XP), is there a utility
> under Windows XP with which I can test the memory usage myself ?

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/nt_command_perfmon.mspx?mfr=true

-jp



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

Date: 12 Jun 2006 16:43:36 GMT
From: xhoster@gmail.com
Subject: Re: Question: Inline::C module packaging?
Message-Id: <20060612124345.234$2v@newsreader.com>

"Lee" <leegee@gmail.com> wrote:
> Ben Morrow wrote:
> > Quoth "Lee" <leegee@gmail.com>:
> > > Is there a preferred method of packaging an Inline::C module, perhaps
> > > one that would compile the C in the correct place during the
> > > installation, rather than on first run?
> >
> > Read the docs for Inline.
>
> Me too, but it says:
>
>     Finally, you need to modify the Makefile.PL. Simply change:
>         use ExtUtils::MakeMaker;
>     to
>         use Inline::MakeMaker;
>
> Won't that upset machines and users that don't have Inline installed?
>
> Neither did the Iline docs help me solve errors along the lines of "No
> rule to make target ... needed by `pure_all'," for which I copied
> something from
> http://search.cpan.org/src/FXN/Algorithm-Combinatorics-0.10/Makefile.PL.
>
> And then there's the whole business of supplying NAME/VERSION and
> having to disable one to run make test, which is not something I would
> like to pass on to my end-users.

So why didn't you mention all this stuff in your original post?  If you
did, we wouldn't have to shame it out of you but suggesting that maybe you
should read the manual.

>
> I don't always find the "RTFM" response helpful, or even worth typing.

Then ask smart questions right up front.

Xho

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


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

Date: 12 Jun 2006 09:04:29 -0700
From: jiehuang001@hotmail.com
Subject: read a webpage with username/password
Message-Id: <1150128269.307177.149480@j55g2000cwa.googlegroups.com>

I am trying to use perl to extract the content of a webpage, such as an
online newspaper. For example, I might want to have the program to send
me any material with the word of "computer".

I know that I can use Get("url") > output.txt  to do that. But the
problem is that to reach to the "url", it needs a username/password to
login first. Of course, I know the username/password. My question is,
how to pass the username/password from perl?

Thank you very much!

JH



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

Date: 12 Jun 2006 09:17:53 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: read a webpage with username/password
Message-Id: <1150129073.613321.124550@f6g2000cwb.googlegroups.com>

jiehuang001@hotmail.com wrote:
> I am trying to use perl to extract the content of a webpage, such as an
> online newspaper. For example, I might want to have the program to send
> me any material with the word of "computer".
>
> I know that I can use Get("url") > output.txt  to do that

Assuming you mean the get() method of the LWP::Simple module, first
note that case matters.  Second note that LWP::Simple also provides
getstore() which puts the output in a file for you, rather than messing
with shell redirection.

> . But the
> problem is that to reach to the "url", it needs a username/password to
> login first. Of course, I know the username/password. My question is,
> how to pass the username/password from perl?

I don't think you can with LWP::Simple.  However, the lwpcook
documentation shows this example, using LWP::UserAgent ...
http://search.cpan.org/~gaas/libwww-perl-5.805/lwpcook.pod#ACCESS_TO_PROTECTED_DOCUMENTS

Does that help?

Paul Lalli



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

Date: Mon, 12 Jun 2006 08:08:36 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: script to find the files with very long names
Message-Id: <slrne8qpqk.r5k.tadmc@magna.augustmail.com>


pui ming Wong <s11976@net2.hkbu.edu.hk> wrote:
> My objective is to go down the current directory
> and have the system tells me which files have their names
> longer than say 26 characters


perl -MFile::Find -le 'find sub{print $File::Find::name if length > 26}, "."'


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 12 Jun 2006 15:05:36 +0200
From: "Y.G." <yg_blah_@this_domain.bla>
Subject: setting linux display for Cron
Message-Id: <e6jor0$mn0$1@info.science.uva.nl>

Another question from me then. I am writing my Gtk-program and I want to 
run it via a cronjob. I am already testing if I am logged in and so. Now 
I want the cron to display the window on my own display. For the moment 
I tried doing this using:

#!/usr/local/bin/perl -w

$ENV{DISPLAY}    = ":0.0";
$ENV{XAUTHORITY} = "/myhome/.Xauthority";

use IO::Handle;
use Gtk2 '-init' ; # load the Gtk-Perl module
use Glib;         # timeout...
use strict;       # a good idea for all non-trivial Perl scripts

(And here follows my program)

When I run it from command line it works. When cron runs it I get an 
e-mail which sais:

Gtk-WARNING **: cannot open display:   at 
perlpath/lib/site_perl/5.8.5/i686-linux/Gtk2.pm line 62.

Should I add a line which tells Gtk2 which displ;ay I am using?


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

Date: 12 Jun 2006 17:52:18 +0200
From: delfin_soft@homoludens.elte.hu
Subject: Re: setting linux display for Cron
Message-Id: <y6TK+gIEvMsI@ludens>

In article <e6jor0$mn0$1@info.science.uva.nl>, "Y.G." <yg_blah_@this_domain.bla> writes:
> Another question from me then. I am writing my Gtk-program and I want to 
> run it via a cronjob. I am already testing if I am logged in and so. Now 
> I want the cron to display the window on my own display. For the moment 
> I tried doing this using:
> 
> #!/usr/local/bin/perl -w
> 

# Try this hack

BEGIN {

$ENV{DISPLAY}    = ":0.0";
$ENV{XAUTHORITY} = "/myhome/.Xauthority";
 
};

> use IO::Handle;
> use Gtk2 '-init' ; # load the Gtk-Perl module
> use Glib;         # timeout...
> use strict;       # a good idea for all non-trivial Perl scripts
> 
> (And here follows my program)
> 
> When I run it from command line it works. When cron runs it I get an 
> e-mail which sais:
> 
> Gtk-WARNING **: cannot open display:   at 
> perlpath/lib/site_perl/5.8.5/i686-linux/Gtk2.pm line 62.
> 
> Should I add a line which tells Gtk2 which displ;ay I am using?


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

Date: Mon, 12 Jun 2006 19:38:36 +0200
From: "Y.G." <yg_blah_@this_domain.bla>
Subject: Re: setting linux display for Cron
Message-Id: <e6k8qs$6p0$1@info.science.uva.nl>

delfin_soft@homoludens.elte.hu wrote:
> In article <e6jor0$mn0$1@info.science.uva.nl>, "Y.G." <yg_blah_@this_domain.bla> writes:
>> Another question from me then. I am writing my Gtk-program and I want to 
>> run it via a cronjob. I am already testing if I am logged in and so. Now 
>> I want the cron to display the window on my own display. For the moment 
>> I tried doing this using:
>>
>> #!/usr/local/bin/perl -w
>>
> 
> # Try this hack
> 
> BEGIN {
> 
> $ENV{DISPLAY}    = ":0.0";
> $ENV{XAUTHORITY} = "/myhome/.Xauthority";
>  
> };
> 
>> use IO::Handle;
>> use Gtk2 '-init' ; # load the Gtk-Perl module
>> use Glib;         # timeout...
>> use strict;       # a good idea for all non-trivial Perl scripts
>>
>> (And here follows my program)
>>
>> When I run it from command line it works. When cron runs it I get an 
>> e-mail which sais:
>>
>> Gtk-WARNING **: cannot open display:   at 
>> perlpath/lib/site_perl/5.8.5/i686-linux/Gtk2.pm line 62.
>>
>> Should I add a line which tells Gtk2 which displ;ay I am using?

It works! Thank you very much!


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

Date: Mon, 12 Jun 2006 08:07:33 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Using tee with Perl's system command
Message-Id: <120620060807332518%jgibson@mail.arc.nasa.gov>

In article <1149992606.320988.108080@f6g2000cwb.googlegroups.com>,
<olson_ord@yahoo.it> wrote:

> Hi,
>  I want to call/run another program with a perl script - and I need
> to look at the current output on the screen and at the same time I need
> this output dumped to a file. Without using perl I would just use tee.
> However within perl it seems that its having some problem with the pipe
> symbol "|".
> 

[program snipped]

>  I know that tee and | are not arguments to ls. However if I execute
> this using back ticks then I don't get the output on the screen - so
> thats not an option.

Jürgen fixed your problem with system. However, I would like to point
out that another solution is to capture the output of the external
program using backticks and then write the lines to the screen and also
to a file from with your Perl program.

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

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


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