[29930] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1173 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 4 21:09:39 2008

Date: Fri, 4 Jan 2008 18: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           Fri, 4 Jan 2008     Volume: 11 Number: 1173

Today's topics:
        Announce: DBD::Unify 0.70 <h.m.brand@xs4all.nl>
        Forcefully release release to OS <nishant.031@gmail.com>
    Re: Forcefully release release to OS <joost@zeekat.nl>
        http://perldoc.perl.org/bigint.html#EXAMPLES Failing on <paddy3118@googlemail.com>
        Print a perl array to html textarea ... <motic.mail@gmail.com>
    Re: Print a perl array to html textarea ... <mritty@gmail.com>
    Re: problem when submitting a string through a form <RedGrittyBrick@SpamWeary.foo>
    Re: problem when submitting a string through a form <tzz@lifelogs.com>
        WWW::Mechanize : Is immediate caching of images possibl hikari.no.hohenheim@gmail.com
    Re: WWW::Mechanize : Is immediate caching of images pos <joost@zeekat.nl>
    Re: WWW::Mechanize : Is immediate caching of images pos <john@castleamber.com>
    Re: WWW::Mechanize : Is immediate caching of images pos <tadmc@seesig.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 4 Jan 2008 14:12:15 GMT
From: "H.Merijn Brand" <h.m.brand@xs4all.nl>
Subject: Announce: DBD::Unify 0.70
Message-Id: <Ju4qBp.1vn2@zorch.sf-bay.org>

This just took too long. Several other interresting projects,
like getting perl 5.10 out, snatched away all tuits.

The following report has been written by the PAUSE namespace indexer.
Please contact modules@perl.org if there are any open questions.
  Id: mldistwatch 925 2007-09-16 15:41:11Z k

               User: HMBRAND (H.Merijn Brand)
  Distribution file: DBD-Unify-0.70.tgz
    Number of files: 31
         *.pm files: 1
             README: DBD-Unify-0.70/README
           META.yml: DBD-Unify-0.70/META.yml
  Timestamp of file: Fri Jan  4 14:07:52 2008 UTC
   Time of this run: Fri Jan  4 14:09:24 2008 UTC

*** Release 0.70 - Fri 04 Jan 2008 <h.m.brand@xs4all.nl>

    - Added the dTHX; calls for threaded perls
    - Moved opt_v to dbd_verbose
    - Added/Aliassed uni_verbose to dbd_verbose
    - Made the first failure notices from Makefile.PL more verbose  (castaway)
    - Tested with DBI-1.59
      ** 0.66 never made it to production due to lack of tuits
    - Tested with DBI-1.601
    - Prevent segfault under Linux (tazervas)
    - Better support for SQLBINARY (tazervas) (adds t/25-binary.t)
    - DBD::Unify now under git
    - Upped copyright to 2008
    - Tested with perl-5.10.0
    - A few casts for 64bit perl
    - Moved DBIh_SET_ERR_CHAR () to DBIc_ERR () and DBIc_ERRSTR ()
    - Moved DBIc_TRACE_LEVEL (h) to dbis->debug where appropriate
    - Raised minimal perl to 5.6.x, also for Test::More

*** Release 0.65 - Mon 20 Aug 2007 <h.m.brand@xs4all.nl>

    - perlcritic OK
    - BAILOUT -> BAIL_OUT
    - BAIL_OUT () when table creation fails
    - Segfault fix for failing do () calls (tazervas@earthlink.net)
    - Split TEXT/BINARY for DS 9 (tazervas@earthlink.net) + test
    - Added an example to show record count(s)

*** Release 0.64 - Mon 14 May 2007 <h.m.brand@xs4all.nl>

    - Tested under DBI-1.56. Make sure to rebuild the DBD
    - Added t/15-uni-fail.t
    - Differentiate between carp (warnings) and croak (errors) better




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

Date: Fri, 4 Jan 2008 05:14:38 -0800 (PST)
From: Nishant <nishant.031@gmail.com>
Subject: Forcefully release release to OS
Message-Id: <a9efb59c-cc82-4b42-8eab-2380a377ba99@l58g2000hsa.googlegroups.com>

Hi ,
In my software, perl is using memory that it is not releasing and the
size of the memory that it has allocated is 100MB.
Is there any API with which I can forcefully do garbage collection so
that perl is forced to release memory to OS ?

Regards
Nishant


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

Date: Fri, 04 Jan 2008 14:39:44 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: Forcefully release release to OS
Message-Id: <87bq81d80v.fsf@zeekat.nl>

Nishant <nishant.031@gmail.com> writes:

> Hi ,
> In my software, perl is using memory that it is not releasing and the
> size of the memory that it has allocated is 100MB.
> Is there any API with which I can forcefully do garbage collection so
> that perl is forced to release memory to OS ?

It doesn't work that way.

Perl has a reference counting GC so all objects that are not available
anymore will be freed /immediately/. Unless you're dealing with circular
references, which you need to break before letting them go. 

_This may or may not actually free memory to the OS._ You'll have to
test it yourself.

/Sometimes/ undefining variables manually before letting them go out of 
scope frees the memory all the way to the OS even if they otherwise aren't.
But I already said that in your previous thread.

Note that all of this is dependent on you actually letting go of the
variables, just like it is in any language with automatic mememory
management. In other words, if the values are still accessible in any 
way they can't be collected.

Joost.



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

Date: Fri, 4 Jan 2008 10:11:50 -0800 (PST)
From: Paddy3118 <paddy3118@googlemail.com>
Subject: http://perldoc.perl.org/bigint.html#EXAMPLES Failing on Cygwin
Message-Id: <9ab6423d-574d-48ac-85a3-d9f4c83db37d@y5g2000hsf.googlegroups.com>

I just cut-n-pasted the Bigint examples into a cygwin window,
expecting them all to pass.

The result was:

bash$ perl -Mbigint -le 'print sqrt(33)'
5
bash$ perl -Mbigint -le 'print 2*255'
510
bash$ perl -Mbigint -le 'print 4.5+2*255'
514
bash$ perl -Mbigint -le 'print 3/7 + 5/7 + 8/3'
2
bash$ perl -Mbigint -le 'print 123->is_odd()'
1
bash$ perl -Mbigint -le 'print log(2)'
Can't use an undefined value as an ARRAY reference at /usr/lib/
perl5/5.8/Math/Bi
gInt/Calc.pm line 1338.
bash$ perl -Mbigint -le 'print 2 ** 0.5'
1
bash$ perl -Mbigint=a,65 -le 'print 2 ** 0.2'
1
bash$ perl -Mbignum=a,65,l,GMP -le 'print 7 ** 7777'
"l" is not exported by the bignum module
Can't continue after import errors at /usr/lib/perl5/5.8/bignum.pm
line 171
BEGIN failed--compilation aborted.
bash$

I guess GMP is missing but why did the 'print log(2)' example fail?


Perl information:

bash$ perl -V
Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
  Platform:
    osname=cygwin, osvers=1.5.18(0.13242), archname=cygwin-thread-
multi-64int
    uname='cygwin_nt-5.1 inspiron 1.5.18(0.13242) 2005-07-02 20:30
i686 unknown
unknown cygwin '
    config_args='-de -Dmksymlinks -Duse64bitint -Dusethreads -
Uusemymalloc -Dopt
imize=-O3 -Dman3ext=3pm -Dusesitecustomize'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define
usemultiplicity=de
fine
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -
pipe -I/usr
/local/include',
    optimize='-O3',
    cppflags='-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -pipe -I/usr/
local/inc
lude'
    ccversion='', gccversion='3.4.4 (cygming special) (gdc 0.12, using
dmd 0.125
)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define,
longdblsize=12
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8,
Off_t='off_t', lsee
ksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='ld2', ldflags =' -s -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lgdbm -ldb -lcrypt -lgdbm_compat
    perllibs=-lcrypt -lgdbm_compat
    libc=/usr/lib/libc.a, so=dll, useshrplib=true, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' -s'
    cccdlflags=' ', lddlflags=' -s -L/usr/local/lib'


Characteristics of this binary (from libperl):
  Compile-time options: MULTIPLICITY USE_ITHREADS USE_64_BIT_INT
                        USE_LARGE_FILES USE_SITECUSTOMIZE
                        PERL_IMPLICIT_CONTEXT
  Locally applied patches:
        SPRINTF0 - fixes for sprintf formatting issues - CVE-2005-3962
  Built under cygwin
  Compiled at Dec 30 2005 02:44:25
  %ENV:
    CYGWIN=""
  @INC:
    /usr/lib/perl5/5.8/cygwin
    /usr/lib/perl5/5.8
    /usr/lib/perl5/site_perl/5.8/cygwin
    /usr/lib/perl5/site_perl/5.8
    /usr/lib/perl5/site_perl/5.8/cygwin
    /usr/lib/perl5/site_perl/5.8
    /usr/lib/perl5/vendor_perl/5.8/cygwin
    /usr/lib/perl5/vendor_perl/5.8
    /usr/lib/perl5/vendor_perl/5.8/cygwin
    /usr/lib/perl5/vendor_perl/5.8
    .
bash$





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

Date: Fri, 4 Jan 2008 06:16:14 -0800 (PST)
From: Moti <motic.mail@gmail.com>
Subject: Print a perl array to html textarea ...
Message-Id: <289a116c-c347-449e-94bd-1d8daef95ad2@n20g2000hsh.googlegroups.com>

Hi Guys,
After I got my indigoperl to work I want to build an application that
get data from the html textarea parse it and then return it to the
same text area (deleting the original text).
My parser returns a perl array (@output_array) which I want to print
to the html text area.
Where can I find an example on how to perfrom this ?
Thanks in advance, Moti.


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

Date: Fri, 4 Jan 2008 06:47:38 -0800 (PST)
From: Paul Lalli <mritty@gmail.com>
Subject: Re: Print a perl array to html textarea ...
Message-Id: <7ffde049-9f40-4724-9e6d-e492951c3141@f10g2000hsf.googlegroups.com>

On Jan 4, 9:16=A0am, Moti <motic.m...@gmail.com> wrote:
> Hi Guys,
> After I got my indigoperl to work I want to build an application that
> get data from the html textarea parse it and then return it to the
> same text area (deleting the original text).
> My parser returns a perl array (@output_array) which I want to print
> to the html text area.
> Where can I find an example on how to perfrom this ?

perldoc CGI

as an example...
use CGI qw/:standard/;
print textarea(
   -name=3D>'mytext',
   -rows=3D>10,
   -columns=3D>50,
   -default=3D>join('', @output_array)
);


Paul Lalli


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

Date: Fri, 04 Jan 2008 12:31:40 +0000
From: RedGrittyBrick <RedGrittyBrick@SpamWeary.foo>
Subject: Re: problem when submitting a string through a form
Message-Id: <477e272e$0$21099$da0feed9@news.zen.co.uk>

Nikos wrote:
> Here is index.pl as it is now: you can view it at http://nikos.no-ip.org
> if you want

Really this is too complex for me to try because I don't want to have to 
set up a database and so on. Nevertheless I've made some comments below.


<snip code encoded in ISO-8859-7>
There's a lot of suspicious code there. At one point you use decode to 
convert from utf8 to perl's internal encoding and immediately use 
Encode::from_to to convert from utf8 to ISO-8859-7!

Are you sure glob returns filenames encoded in ISO-8859-7 when run by 
the web-server?

> 
> The problem is that when the user selects something from my popup
> menu(one string) and then submits it, the returned string being sent
> back to my index.pl ain't matching this line:  unless ( grep { $_ eq
> param('select') } @display_files )

As I suggested before, print the values of param('select) and @display 
files so that you can SEE what is wrong.

> and that fact led to believe that the browser or something else
> somehow malformes the original value(the one selected before
> submission)

AFAIK, most browsers (but not all) will return data encoded using the 
encoding specified in the HTTP headers for the form HTML.
http://www.intertwingly.net/blog/1761.html


> I though that this line would take care of the problem coverting it
> properly to utf8 but it doesnt :(
> $article = decode('utf8', param('select' ));

That doesn't convert TO utf8, it converts FROM utf8!



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

Date: Fri, 04 Jan 2008 07:23:30 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: problem when submitting a string through a form
Message-Id: <86wsqpsp0t.fsf@lifelogs.com>

On Thu, 3 Jan 2008 10:00:22 -0800 (PST) Nikos <nikos1337@gmail.com> wrote: 

N> The problem is that when the user selects something from my popup
N> menu(one string) and then submits it, the returned string being sent
N> back to my index.pl ain't matching this line:  unless ( grep { $_ eq
N> param('select') } @display_files )

What is the exact content of param('select') at this point?
What is the exact content of @display_files?

Use Firefox+Firebug to see the exact data being posted back to the
server.  What is the 'select' parameter's content?  Show the entire POST
operation's data load.

As an aside, you may want to look into CGI::FormBuilder to build forms
easily (or the Template Toolkit, or Mason, or any other such toolkit)
and Rose::DB::Object to get your DB data.

Ted


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

Date: Fri, 4 Jan 2008 14:12:30 -0800 (PST)
From: hikari.no.hohenheim@gmail.com
Subject: WWW::Mechanize : Is immediate caching of images possible?
Message-Id: <5b2f1377-c2a8-4ee2-a2ff-ec3bf7226614@l1g2000hsa.googlegroups.com>

Traditionally when using WWW::Mechanize to dl images I first fetch the
root page:
 my $mech = WWW::Mechanize->new();
 $mech->get($url);

then proceed to find all images and 'get' them one by one: (forgive
the crude code)

 my @links = $mech->find_all_images();
 foreach my $link (@links){
   my $imageurl = $link->url_abs();
   $imageurl =~ m/([^\/]+)$/;
   $mech->get($imageurl, ':content_file' => $1);
 }

My current problem with this is that I'm trying to dl an image
generated with information from the session of the original
get($url).  It's not a static *.jpg or something simple it's a black
box that displays an image relevant to the session.   Meaning, when I
fetch the image (http://www.domain.com/image/ which is embedded in the
page) as shown above, it's a new request and I get a completely random
image.

Is there a way to cache the images that are loaded during the initial
get($url) so that the image matches the content of the page
retrieved?  Or even to capture the session information transmitted to
the black box, domain.com/image/, so I can clone the information and
submit it with the get($imageurl)?

Ideally I would effectively like a routine like:  $mech-
>getComplete($url,$directory); which would save the source and images/
etc associate with the page.  Analogous to the Save-> Web page,
Complete in Firefox.

Thanks all.  I think I'm getting pretty proficient with WWW::Mechanize
but don't be afraid to respond like I am an idiot so that we know your
answer doesn't go over my head.

Hikari


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

Date: Fri, 04 Jan 2008 23:45:14 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: WWW::Mechanize : Is immediate caching of images possible?
Message-Id: <87y7b5qkg5.fsf@zeekat.nl>

hikari.no.hohenheim@gmail.com writes:

> Traditionally when using WWW::Mechanize to dl images I first fetch the
> root page:
>  my $mech = WWW::Mechanize->new();
>  $mech->get($url);
>
> then proceed to find all images and 'get' them one by one: (forgive
> the crude code)
>
>  my @links = $mech->find_all_images();
>  foreach my $link (@links){
>    my $imageurl = $link->url_abs();
>    $imageurl =~ m/([^\/]+)$/;
>    $mech->get($imageurl, ':content_file' => $1);
>  }

Ok...

> My current problem with this is that I'm trying to dl an image
> generated with information from the session of the original
> get($url).  It's not a static *.jpg or something simple it's a black
> box that displays an image relevant to the session.   Meaning, when I
> fetch the image (http://www.domain.com/image/ which is embedded in the
> page) as shown above, it's a new request and I get a completely random
> image.

Since an HTTP request only gets one resource at a time, how does the server
associate them? 

> Is there a way to cache the images that are loaded during the initial
> get($url) so that the image matches the content of the page
> retrieved?

The content of the page has no bearing of the content of the image. At
least not from the client's point of view.

>  Or even to capture the session information transmitted to
> the black box, domain.com/image/, so I can clone the information and
> submit it with the get($imageurl)?

I don't know what you mean. Session /IDs/ are usually handled either via
cookies or via additional URL parameters/substrings. Either case should
already work automatically with WWW::Mechanize. There is no way at all
that you can get at session information from a client unless the server
provides special mechanisms to do so, which they normally don't, since
one of the reasons to use sessions in the first place is to separate the
client from the session data.

> Ideally I would effectively like a routine like:  $mech-
>>getComplete($url,$directory); which would save the source and images/
> etc associate with the page.  Analogous to the Save-> Web page,
> Complete in Firefox.

That does more or less exactly what your script above does. But see below.

> Thanks all.  I think I'm getting pretty proficient with WWW::Mechanize
> but don't be afraid to respond like I am an idiot so that we know your
> answer doesn't go over my head.

It looks to me that the server generating the image does some kind of
hackish thing to associate the image with the original request. Since
WWW::Mechanize already handles session cookies automatically, I'd guess
you may need to get the image making sure that your referer header is
set to the same page. Everything else I can think of should already work
automatically. Usually, just using the back() method would suffice. 

Something like this:

$www->get($page_url);
foreach (link on that page) {
  $www->get($_);
  # do stuff
  $www->back(); # set originating page to $page_url
}

HTH,
Joost.


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

Date: 4 Jan 2008 23:24:36 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: WWW::Mechanize : Is immediate caching of images possible?
Message-Id: <Xns9A1BB11B4CB20castleamber@130.133.1.4>

Joost Diepenmaat <joost@zeekat.nl> wrote:
 
> I don't know what you mean. Session /IDs/ are usually handled either
> via cookies or via additional URL parameters

I guess you mean query string

> /substrings. 

I guess you mean path segements (path_info)

> Either case

There is a 3rd one: (hidden) fields in a form

-- 
John

Arachnids near Coyolillo - part 1
http://johnbokma.com/mexit/2006/05/04/arachnids-coyolillo-1.html


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

Date: Sat, 05 Jan 2008 01:00:58 GMT
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: WWW::Mechanize : Is immediate caching of images possible?
Message-Id: <slrnfntl8j.u61.tadmc@tadmc30.sbcglobal.net>

hikari.no.hohenheim@gmail.com <hikari.no.hohenheim@gmail.com> wrote:


> (forgive
> the crude code)


It is a bit too crude to let pass without comment...


>  my @links = $mech->find_all_images();
>  foreach my $link (@links){
>    my $imageurl = $link->url_abs();
>    $imageurl =~ m/([^\/]+)$/;
>    $mech->get($imageurl, ':content_file' => $1);


You should never use the dollar-digit variables unless you have
first ensured that the match *succeeded*.


> fetch the image (http://www.domain.com/image/ 


Your match will fail for that value of $imageurl for instance...


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


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

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


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