[28643] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 10007 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 25 18:06:05 2006

Date: Sat, 25 Nov 2006 15:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 25 Nov 2006     Volume: 10 Number: 10007

Today's topics:
    Re: a short non-working Perl script <noreply@gunnar.cc>
    Re: a short non-working Perl script <tbmoore9@verizon.net>
    Re: Compare UNIX file time with time in a variable <No_4@dsl.pipex.com>
    Re: die on "use of uninitialized value"? <nobull67@gmail.com>
    Re: die on "use of uninitialized value"? ivowel@gmail.com
        modPerl, Apache, and REMOTE_USER snakedjip@yahoo.com
    Re: modPerl, Apache, and REMOTE_USER <no@email.com>
    Re: modPerl, Apache, and REMOTE_USER snakedjip@yahoo.com
    Re: modPerl, Apache, and REMOTE_USER <no@email.com>
    Re: modPerl, Apache, and REMOTE_USER <spamtrap@dot-app.org>
        Perl and Online Banking <bradbrockman@yahoo.com>
    Re: Perl and Online Banking <no@email.com>
    Re: Perl and Online Banking <bradbrockman@yahoo.com>
    Re: Perl and Online Banking snakedjip@yahoo.com
    Re: Perl and Online Banking <benmorrow@tiscali.co.uk>
    Re: Perl and Online Banking <tadmc@augustmail.com>
    Re: prevent further hash auto-vivification <nobull67@gmail.com>
    Re: prevent further hash auto-vivification ivowel@gmail.com
    Re: prevent further hash auto-vivification <uri@stemsystems.com>
    Re: prevent further hash auto-vivification <benmorrow@tiscali.co.uk>
        print_r() <Mark.Fenbers@noaa.gov>
    Re: print_r() <nobull67@gmail.com>
    Re: print_r() <wahab@chemie.uni-halle.de>
    Re: print_r() <antispam@randometry.com>
    Re: print_r() <newsgroups@free.fr>
    Re: print_r() (reading news)
    Re: print_r() <jurgenex@hotmail.com>
    Re: print_r() <tadmc@augustmail.com>
    Re: Problem to compile Perl 5.8.8 <ar_nospam@free.fr>
    Re: speaking of forking -- parallel database fetches? <rcaputo@pobox.com>
    Re: speaking of forking -- parallel database fetches? <DJStunks@gmail.com>
    Re: the opposite of 'chop' <No_4@dsl.pipex.com>
    Re: the opposite of 'chop' <benmorrow@tiscali.co.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 25 Nov 2006 15:39:51 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: a short non-working Perl script
Message-Id: <4sr2trF114itkU1@mid.individual.net>

Mark Tarver wrote:
> Paul Lalli wrote:
>> Are you *reading* any of these replies?
> 
> Of course.
> ...
> But for my own education I would still like to know the answer to my
> question as to how $buffer can read the output of series of forms.

Boyd already answered that question. So again, _are_ you reading the 
replies you got?

> The original program works apart from this one line.  Here is an
> example where $buffer is set to a string.
> _________________________________________________________________
> #!/usr/bin/perl
> # Reads the input from a forms file and splits it into parts.
> 
> $buffer = "name=Mark&email=over the rainbow";

If submitted from a from, that would come in STDIN ( or in 
$ENV{QUERY_STRING} ) as "name=Mark&email=over+the+rainbow", so your code 
  would not complete the task.

I have emphasized the limitations of CGI.pm many times, and I don't 
always use it for my own CGI scripts. I'd still recommend that you 
follow the advice given to you: Use CGI.pm and drop that code. You have 
quite a few things to learn before you should consider anything else.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Sat, 25 Nov 2006 14:43:03 GMT
From: boyd <tbmoore9@verizon.net>
Subject: Re: a short non-working Perl script
Message-Id: <tbmoore9-44F5FB.09430325112006@news.verizon.net>

In article <1164463455.582753.107230@j72g2000cwa.googlegroups.com>,
 "Mark Tarver" <dr.mtarver@ukonline.co.uk> wrote:


> _______________________________________________________________
> But for my own education I would still like to know the answer to my
> question as to how $buffer can read the output of series of forms.
> cgi.pm is actually not part of Perl itself, but a package on top of
> Perl.
> 
> The original program works apart from this one line.  Here is an
> example where $buffer is set to a string.
> _________________________________________________________________
> #!/usr/bin/perl
> # Reads the input from a forms file and splits it into parts.
> 
> $buffer = "name=Mark&email=over the rainbow";
> $token = "";
> @tokens = ( );
 ...
> You don't have to answer the question, but the correct answer in Perl
> should not be too long.
> 
> Mark

Your script looks fine.  We repeat: when you write
   $buffer = read( $a, $buffer, $c), the $buffer variable gets the 
correct string (I assume), but then the read function returns a number, 
which then overwrites $buffer, and replaces the string with a number.

Your script would work, probably, if you did something like:

my $buffer_length = read( $a, $buffer, $c)

Boyd


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

Date: Sat, 25 Nov 2006 14:41:43 +0000
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: Compare UNIX file time with time in a variable
Message-Id: <a4-dnQ8oCu6uy_XYRVnyvg@pipex.net>

phynkel@gmail.com wrote:
>
>> Have a look at File::Find. Much easier to use from within a Perl script,
>> and allows you to write a callback function that can use whatever criteria
>> you want to filter out files you're not interested in.
>>
> TX - will look it up .

    And if you still decide to use command line find, use GNU find, which 
has  -amin, -cmin, -mmin options which allows you to find files accessed, 
(inode-)changed or modified before (+n), after (-n) or exactly at (n) n 
minutes ago.


-- 
              Just because I've written it doesn't mean that
                   either you or I have to believe it.


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

Date: 25 Nov 2006 07:30:50 -0800
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: die on "use of uninitialized value"?
Message-Id: <1164468650.401145.323090@45g2000cws.googlegroups.com>


Michele Dondi wrote:
> On 24 Nov 2006 11:00:21 -0800, ivowel@gmail.com wrote:
>
> >dear perl experts:  is it possible to instruct perl to die on run-time
> >if it accesses an undefined scalar ?  I would rather know right away
> >when I have committed a programming error.
>
> Yes, but that would be rather strange since that particular warning is
> probably the most common and reasonable one for which people
> consciously wants to temporarily disable warnings.

That does not follow.

The fact that one often wants to treat undef as "" or 0 without warning
is in now way mutually exclusive with the idea that there are other
times when you'd want that same warning promoted to an error.



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

Date: 25 Nov 2006 08:40:31 -0800
From: ivowel@gmail.com
Subject: Re: die on "use of uninitialized value"?
Message-Id: <1164472831.126104.242370@f16g2000cwb.googlegroups.com>


wonderful.  thank you.  regards, /iaw

DJ Stunks wrote:
> ivowel@gmail.com wrote:
> > dear perl experts:  is it possible to instruct perl to die on run-time
> > if it accesses an undefined scalar ?  I would rather know right away
> > when I have committed a programming error.
> 
>   use warnings FATAL => qw{ uninitialized };
> 
> -jp



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

Date: 25 Nov 2006 11:50:44 -0800
From: snakedjip@yahoo.com
Subject: modPerl, Apache, and REMOTE_USER
Message-Id: <1164484244.668276.166420@45g2000cws.googlegroups.com>

Hi,

I use Xampp for my apache-mysql-modperl setup.

I'm running a perl script from a directory that is protected with a
 .htaccess file.

I've setup apache to run as normal cgi if I access the file through
/cgi-bin/..., and to run as mod-perl if accessed from /perl/...

If I run the script as normal cgi, I have access to $ENV{REMOTE_USER}
to identify my user.

If I run the script as modPerl, that environment variable is not set.

Is that due to some Xampp configuration in httpd.conf or elsewhere, or
is it just me that should know that $ENV{REMOTE_USER} is not set in
modPerl ?

My question would then be : how do I know, in modPerl, what user is
accessing my script ? 

Thanks.



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

Date: Sat, 25 Nov 2006 20:29:28 +0000
From: Brian Wakem <no@email.com>
Subject: Re: modPerl, Apache, and REMOTE_USER
Message-Id: <4srnc3F10valiU1@mid.individual.net>

snakedjip@yahoo.com wrote:

> Hi,
> 
> I use Xampp for my apache-mysql-modperl setup.
> 
> I'm running a perl script from a directory that is protected with a
> .htaccess file.
> 
> I've setup apache to run as normal cgi if I access the file through
> /cgi-bin/..., and to run as mod-perl if accessed from /perl/...
> 
> If I run the script as normal cgi, I have access to $ENV{REMOTE_USER}
> to identify my user.
> 
> If I run the script as modPerl, that environment variable is not set.
> 
> Is that due to some Xampp configuration in httpd.conf or elsewhere, or
> is it just me that should know that $ENV{REMOTE_USER} is not set in
> modPerl ?
> 
> My question would then be : how do I know, in modPerl, what user is
> accessing my script ?
> 
> Thanks.


$ENV{REMOTE_USER} *is* set in mod_perl.


-- 
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png


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

Date: 25 Nov 2006 12:32:31 -0800
From: snakedjip@yahoo.com
Subject: Re: modPerl, Apache, and REMOTE_USER
Message-Id: <1164486751.692971.164990@j44g2000cwa.googlegroups.com>


Brian Wakem wrote:
> snakedjip@yahoo.com wrote:
>
> > Hi,
> >
> > I use Xampp for my apache-mysql-modperl setup.
> >
> > I'm running a perl script from a directory that is protected with a
> > .htaccess file.
> >
> > I've setup apache to run as normal cgi if I access the file through
> > /cgi-bin/..., and to run as mod-perl if accessed from /perl/...
> >
> > If I run the script as normal cgi, I have access to $ENV{REMOTE_USER}
> > to identify my user.
> >
> > If I run the script as modPerl, that environment variable is not set.
> >
> > Is that due to some Xampp configuration in httpd.conf or elsewhere, or
> > is it just me that should know that $ENV{REMOTE_USER} is not set in
> > modPerl ?
> >
> > My question would then be : how do I know, in modPerl, what user is
> > accessing my script ?
> >
> > Thanks.
>
>
> $ENV{REMOTE_USER} *is* set in mod_perl.
>
>
> --
> Brian Wakem
> Email: http://homepage.ntlworld.com/b.wakem/myemail.png

Thanks for the answer.  Good to know it is available.

Now, why isn't it available in my Xampp setup ?  Any ideas ?



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

Date: Sat, 25 Nov 2006 20:39:35 +0000
From: Brian Wakem <no@email.com>
Subject: Re: modPerl, Apache, and REMOTE_USER
Message-Id: <4srnv2F10uuouU1@mid.individual.net>

snakedjip@yahoo.com wrote:

> 
> Brian Wakem wrote:
>> snakedjip@yahoo.com wrote:
>>
>> > Hi,
>> >
>> > I use Xampp for my apache-mysql-modperl setup.
>> >
>> > I'm running a perl script from a directory that is protected with a
>> > .htaccess file.
>> >
>> > I've setup apache to run as normal cgi if I access the file through
>> > /cgi-bin/..., and to run as mod-perl if accessed from /perl/...
>> >
>> > If I run the script as normal cgi, I have access to $ENV{REMOTE_USER}
>> > to identify my user.
>> >
>> > If I run the script as modPerl, that environment variable is not set.
>> >
>> > Is that due to some Xampp configuration in httpd.conf or elsewhere, or
>> > is it just me that should know that $ENV{REMOTE_USER} is not set in
>> > modPerl ?
>> >
>> > My question would then be : how do I know, in modPerl, what user is
>> > accessing my script ?
>> >
>> > Thanks.
>>
>>
>> $ENV{REMOTE_USER} *is* set in mod_perl.
>>
>>
>> --
>> Brian Wakem
>> Email: http://homepage.ntlworld.com/b.wakem/myemail.png
> 
> Thanks for the answer.  Good to know it is available.
> 
> Now, why isn't it available in my Xampp setup ?  Any ideas ?


No idea, never used Xampp.

Try this in a script and see what happens:

print "$_ => $ENV{$_}<br>\n" foreach sort keys %ENV;



-- 
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png


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

Date: Sat, 25 Nov 2006 15:52:05 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: modPerl, Apache, and REMOTE_USER
Message-Id: <m2vel31c7e.fsf@Sherm-Pendleys-Computer.local>

snakedjip@yahoo.com writes:

> Brian Wakem wrote:
>>
>> $ENV{REMOTE_USER} *is* set in mod_perl.
>>
>
> Thanks for the answer.  Good to know it is available.
>
> Now, why isn't it available in my Xampp setup ?  Any ideas ?

One obvious question is whether the relevant directory is configured to use
some flavor of HTTP authentication, and whether there is actually a user
logged in.

Homemade user authentication schemes, where the user provides a login name
and password into an HTML form, instead of being prompted by a browser dialog,
generally don't set $ENV{REMOTE_USER} to a meaningful value.

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: 25 Nov 2006 10:54:56 -0800
From: "banker123" <bradbrockman@yahoo.com>
Subject: Perl and Online Banking
Message-Id: <1164480896.527861.142470@l39g2000cwd.googlegroups.com>

Can I access my banking account via the web using perl?  I have used
LWP and installed SSL and Crypt::SSLeay.  I am able to access https
pages that do not require a user name and password, however I am not
sure how to sign on to my banks homepage (start a session), and
navigate to the https site that list my account details.

Homepage
https://www.key.com/index.html

If I can access the data my plan is to use perl to extract the data and
create custom reports.  Direction, references, documentation,
suggestions, and prior experiences accessing data via a secure session
is appreciated.



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

Date: Sat, 25 Nov 2006 19:25:38 +0000
From: Brian Wakem <no@email.com>
Subject: Re: Perl and Online Banking
Message-Id: <4srjkdF10cud4U1@mid.individual.net>

banker123 wrote:

> Can I access my banking account via the web using perl?  I have used
> LWP and installed SSL and Crypt::SSLeay.  I am able to access https
> pages that do not require a user name and password, however I am not
> sure how to sign on to my banks homepage (start a session), and
> navigate to the https site that list my account details.
> 
> Homepage
> https://www.key.com/index.html
> 
> If I can access the data my plan is to use perl to extract the data and
> create custom reports.  Direction, references, documentation,
> suggestions, and prior experiences accessing data via a secure session
> is appreciated.


This wheel may have been invented already.
http://search.cpan.org/search?query=bank&mode=all


-- 
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png


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

Date: 25 Nov 2006 11:43:59 -0800
From: "banker123" <bradbrockman@yahoo.com>
Subject: Re: Perl and Online Banking
Message-Id: <1164483839.646282.223270@14g2000cws.googlegroups.com>

Brian Wakem wrote:

> This wheel may have been invented already.
> http://search.cpan.org/search?query=bank&mode=all

No module for my bank (KeyBank), looks like I will have to build the
wheel.



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

Date: 25 Nov 2006 11:47:40 -0800
From: snakedjip@yahoo.com
Subject: Re: Perl and Online Banking
Message-Id: <1164484060.112420.233150@14g2000cws.googlegroups.com>


Brian Wakem wrote:
> banker123 wrote:
>
> > Can I access my banking account via the web using perl?  I have used
> > LWP and installed SSL and Crypt::SSLeay.  I am able to access https
> > pages that do not require a user name and password, however I am not
> > sure how to sign on to my banks homepage (start a session), and
> > navigate to the https site that list my account details.
> >
> > Homepage
> > https://www.key.com/index.html
> >
> > If I can access the data my plan is to use perl to extract the data and
> > create custom reports.  Direction, references, documentation,
> > suggestions, and prior experiences accessing data via a secure session
> > is appreciated.
>
>
> This wheel may have been invented already.
> http://search.cpan.org/search?query=bank&mode=all
>
>
> --
> Brian Wakem
> Email: http://homepage.ntlworld.com/b.wakem/myemail.png

I've done a script from scratch, not knowing that there already are
banks that are programmed at CPAN (my bank wasn't there anyway)...

The session is usually opened through the use of cookies.  More
precisely, usually when you login successfully on your bank's web site,
the bank's server will send you a cookie with the response.  You just
need to keep that cookie (and all other cookies for that matter) in
your UserAgent object.  When you create your LWP::UserAgent object,
just do this :

my $ua = LWP::UserAgent->new();
$ua->cookie_jar(new HTTP::Cookies);

This way, LWP will take care of accepting new cookies from the server
with its responses, and also send them back to the server when new
requests are made.

Having had problems with my bank's last web site update, here are two
things to watch out for :

1- Many web sites use javascript to create cookies.  For example, the
server will send you an HTML page that contains javascript code.  This
javascript code is then executed by your browser (IE or firefox or
whatever).  When you use LWP, that javascript code is not executed.
This means that you have to figure out what the javascript code does,
and then set the cookie(s) (that it normally sets through your browser)
programmatically inside your perl script with
$ua->cookie_jar->set_cookie(...).

2- Sometimes the server will check that the request has its "Referer"
header set correctly.  When you navigate a web site with a regular
browser, the last page you visited is usually set as the Referer to the
next page you're going to visit.  It's possible that the server will
check the Referer from the HTTP header against the Referer string it's
expecting, and if they're not the same, it'll send you off to an error
page.

I use HTTP Analyzer by the way to help me write HTML scrapers of this
sort...  Google it.

Good luck



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

Date: Sat, 25 Nov 2006 19:19:23 +0000
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Perl and Online Banking
Message-Id: <rihm34-vre.ln1@osiris.mauzo.dyndns.org>

[perl.beginners trimmed as it's not a newsgroup]

Quoth "banker123" <bradbrockman@yahoo.com>:
> Can I access my banking account via the web using perl?  I have used
> LWP and installed SSL and Crypt::SSLeay.  I am able to access https
> pages that do not require a user name and password, however I am not
> sure how to sign on to my banks homepage (start a session), and
> navigate to the https site that list my account details.

Start by looking at WWW::Mechanize.

I shouldn't need to say this, but *BE* *CAREFUL*. You are potentially
messing around with yor money...

Ben

-- 
Raise your hand if you're invulnerable.
                                                  [benmorrow@tiscali.co.uk]


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

Date: Sat, 25 Nov 2006 16:53:27 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Perl and Online Banking
Message-Id: <slrnemhib7.hd0.tadmc@tadmc30.august.net>

snakedjip@yahoo.com <snakedjip@yahoo.com> wrote:
> Brian Wakem wrote:
>> banker123 wrote:
>>
>> > Can I access my banking account via the web using perl?

> just do this :
>
> my $ua = LWP::UserAgent->new();
> $ua->cookie_jar(new HTTP::Cookies);


Or just do this:

   my $ua = WWW::Mechanize->new();

as it already has cookies enabled.


> I use HTTP Analyzer by the way to help me write HTML scrapers of this
> sort...  Google it.


For those who prefer open source, and not being tied to the evil browser,
there is also:

   Web Scraping Proxy

      http://www.research.att.com/~hpk/wsp/


Which writes the logs in the form of Perl code that you can copy and modify.


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


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

Date: 25 Nov 2006 07:53:10 -0800
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: prevent further hash auto-vivification
Message-Id: <1164469990.488344.79200@f16g2000cwb.googlegroups.com>


Uri Guttman wrote:
> >>>>> "BM" == Ben Morrow <benmorrow@tiscali.co.uk> writes:
>
>   BM> Quoth ivowel@gmail.com:
>   >>
>   >> dear perl experts:  how can I stop perl from auto-vivifying new keys in
>   >> a hash?  this seems like something that everyone would want as an
>   >> optional feature in an object oriented context, isn't it?  sincerely,
>
>   BM> As of 5.8.0 you can use Hash::Util::lock_keys to prevent new hash keys
>   BM> from being added in any way (including autoviv). This feature was added
>   BM> to support OOP, IIRC (it is a replacement for the deprecated pseudohash
>   BM> semantics).
>
> i wouldn't say hash locking had anything to do with psuedo hashes.
> psuedos were intended to be a fast way to do object and look up their
> attributes. it was an unholy mess and was rightly ripped out of perl (i
> think it was finally removed in 5.8 after being deprecated for years).
>
> maybe the locked hashes are useful to various OO implementation styles
> (inside out object don't need that AFAIK) but they aren't similar to
> psuedo hashes in any way i can see.

 ...appart from the obvious similarity that pseudo-hashes had fixed keys
in exactly the same way as locked hashes have.



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

Date: 25 Nov 2006 08:38:32 -0800
From: ivowel@gmail.com
Subject: Re: prevent further hash auto-vivification
Message-Id: <1164472712.350221.53440@l39g2000cwd.googlegroups.com>


thank you, everybody.  Ben---this was exactly what I wanted.

Regards,

/iaw


Ben Morrow wrote:
> Quoth ivowel@gmail.com:
> >
> > dear perl experts:  how can I stop perl from auto-vivifying new keys in
> > a hash?  this seems like something that everyone would want as an
> > optional feature in an object oriented context, isn't it?  sincerely,
>
> As of 5.8.0 you can use Hash::Util::lock_keys to prevent new hash keys
> from being added in any way (including autoviv). This feature was added
> to support OOP, IIRC (it is a replacement for the deprecated pseudohash
> semantics).
>
> Ben
>
> --
> Raise your hand if you're invulnerable.
>                                                   [benmorrow@tiscali.co.uk]



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

Date: Sat, 25 Nov 2006 13:00:30 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: prevent further hash auto-vivification
Message-Id: <x7slg74da9.fsf@mail.sysarch.com>

>>>>> "BM" == Brian McCauley <nobull67@gmail.com> writes:

  BM> Uri Guttman wrote:
  >> >>>>> "BM" == Ben Morrow <benmorrow@tiscali.co.uk> writes:
  >> 
  BM> Quoth ivowel@gmail.com:
  >> >>
  >> >> dear perl experts:  how can I stop perl from auto-vivifying new keys in
  >> >> a hash?  this seems like something that everyone would want as an
  >> >> optional feature in an object oriented context, isn't it?  sincerely,
  >> 
  BM> As of 5.8.0 you can use Hash::Util::lock_keys to prevent new hash keys
  BM> from being added in any way (including autoviv). This feature was added
  BM> to support OOP, IIRC (it is a replacement for the deprecated pseudohash
  BM> semantics).
  >> 
  >> i wouldn't say hash locking had anything to do with psuedo hashes.
  >> psuedos were intended to be a fast way to do object and look up their
  >> attributes. it was an unholy mess and was rightly ripped out of perl (i
  >> think it was finally removed in 5.8 after being deprecated for years).
  >> 
  >> maybe the locked hashes are useful to various OO implementation styles
  >> (inside out object don't need that AFAIK) but they aren't similar to
  >> psuedo hashes in any way i can see.

  BM> ...appart from the obvious similarity that pseudo-hashes had fixed keys
  BM> in exactly the same way as locked hashes have.

but they weren't 'fixed'. you could always modify the hash in the 0 slot
of the psuedohash's array after creation. only the predefined keys would
be properly converted at compile time but keys added later could still
be looked up at runtime (and even more slowly than a regular hash!). so
psuedohashes didn't completely lock up the attributes anyhow.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Sat, 25 Nov 2006 14:39:08 +0000
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: prevent further hash auto-vivification
Message-Id: <c51m34-p5d.ln1@osiris.mauzo.dyndns.org>


Quoth Uri Guttman <uri@stemsystems.com>:
> >>>>> "BM" == Ben Morrow <benmorrow@tiscali.co.uk> writes:
> 
>   BM> Quoth ivowel@gmail.com:
>   >> 
>   >> dear perl experts:  how can I stop perl from auto-vivifying new keys in
>   >> a hash?  this seems like something that everyone would want as an
>   >> optional feature in an object oriented context, isn't it?  sincerely,
> 
>   BM> As of 5.8.0 you can use Hash::Util::lock_keys to prevent new hash keys
>   BM> from being added in any way (including autoviv). This feature was added
>   BM> to support OOP, IIRC (it is a replacement for the deprecated pseudohash
>   BM> semantics).
> 
> i wouldn't say hash locking had anything to do with psuedo hashes.
> psuedos were intended to be a fast way to do object and look up their
> attributes. it was an unholy mess and was rightly ripped out of perl (i
> think it was finally removed in 5.8 after being deprecated for years).

No, they were removed in 5.9.

> maybe the locked hashes are useful to various OO implementation styles
> (inside out object don't need that AFAIK) but they aren't similar to
> psuedo hashes in any way i can see.

As of 5.9 fields.pm is implemented in terms of locked hashes instead of
phashes. This is what they were added to perl for: to keep the
'attribute checking' nature of phashes, which was deemed to be a benefit
of using fields.pm.

IOO don't use locked hashes; but as of 5.10 they will (or can, anyway)
use Anno's new 'fieldhashes', which cope correctly with
threads/overloading/re-blessing.

Ben

-- 
  The cosmos, at best, is like a rubbish heap scattered at random.
                                                           Heraclitus
  benmorrow@tiscali.co.uk


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

Date: Sat, 25 Nov 2006 11:04:58 -0500
From: Mark <Mark.Fenbers@noaa.gov>
Subject: print_r()
Message-Id: <ek9pjb$hok$1@news.nems.noaa.gov>

Is there anything in Perl that does the equivalent of what print_r() 
does in PHP?

Mark


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

Date: 25 Nov 2006 08:10:40 -0800
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: print_r()
Message-Id: <1164471040.052835.137710@f16g2000cwb.googlegroups.com>

Mark wrote:

> Is there anything in Perl that does the equivalent of what print_r()
> does in PHP?

I suppose that would depend on what print_r() does in PHP.

If you can't be bothered to tell us or at least include a URL of a page
that explains what that is, then you shouldn't expect us to be bothered
to punch "PHP print_r" into Google to find out.



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

Date: Sat, 25 Nov 2006 17:31:42 +0100
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: print_r()
Message-Id: <ek9reg$kd1$1@mlucom4.urz.uni-halle.de>

Thus spoke Mark (on 2006-11-25 17:04):

> Is there anything in Perl that does the equivalent of what print_r() 
> does in PHP?

Yes.

It's in the Perl core distribution and
sounds like some 'construction machinery'.

Regards

M.


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

Date: Sat, 25 Nov 2006 17:34:16 +0100
From: Ric <antispam@randometry.com>
Subject: Re: print_r()
Message-Id: <ek9rgl$nsp$1@online.de>

Mark schrieb:
> Is there anything in Perl that does the equivalent of what print_r()
> does in PHP?
> 
> Mark

Yes:


use Data::Dumper;


print Dumper($yourvar);
print Dumper(%yourhash);

 ...


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

Date: Sat, 25 Nov 2006 17:38:56 +0100
From: Newsgroups <newsgroups@free.fr>
Subject: Re: print_r()
Message-Id: <1164472735.5639.4.camel@localhost>

Le samedi 25 novembre 2006 =E0 11:04 -0500, Mark a =E9crit :
> Is there anything in Perl that does the equivalent of what print_r()=20
> does in PHP?

I use this :

my $array_or_hash;
use Data::Dumper;
print Dumper($array_or_hash);



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

Date: Sat, 25 Nov 2006 17:08:02 GMT
From: "Mumia W. (reading news)" <paduille.4060.mumia.w@earthlink.net>
Subject: Re: print_r()
Message-Id: <SL_9h.3351$tM1.2692@newsread1.news.pas.earthlink.net>

On 11/25/2006 10:04 AM, Mark wrote:
> Is there anything in Perl that does the equivalent of what print_r() 
> does in PHP?
> 
> Mark

Yes, use Data::Dumper.

use Data::Dumper;
my @array = ({gander => 'goose', fox => 'vixen'}, 48,
    [ 39, 'steps', 'movie'  ]);
print Dumper(\@array);

-----------------
See the documentation:
Start->Run->"perldoc Data::Dumper"


-- 
paduille.4060.mumia.w@earthlink.net


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

Date: Sat, 25 Nov 2006 17:48:08 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: print_r()
Message-Id: <sl%9h.4102$Kw2.3647@trndny05>

Mark wrote:
> Is there anything in Perl that does the equivalent of what print_r()
> does in PHP?

What does print_r() do in PHP?

jue 




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

Date: Sat, 25 Nov 2006 16:43:13 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: print_r()
Message-Id: <slrnemhho1.hd0.tadmc@tadmc30.august.net>

Mark <Mark.Fenbers@noaa.gov> wrote:

> Is there anything in Perl that does the equivalent of what print_r() 
> does in PHP?


What does print_r() do in PHP?


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


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

Date: Sat, 25 Nov 2006 19:16:12 +0100
From: ar81 <ar_nospam@free.fr>
Subject: Re: Problem to compile Perl 5.8.8
Message-Id: <op.tjk3pa0m6hy138@pentium-d-830>


Adding '-lm' to the default linker flags worked perfectly. Thanks.

A. ROY


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

Date: Sat, 25 Nov 2006 16:53:22 GMT
From: Rocco Caputo <rcaputo@pobox.com>
Subject: Re: speaking of forking -- parallel database fetches?
Message-Id: <slrnemgt8f.2s9o.rcaputo@eyrie.homenet>

On 24 Nov 2006 11:23:27 -0800, DJ Stunks wrote:
>
> I have two straightforward SELECT statements, but both take about two
> minutes to complete.  I'd like to run them in parallel, but I obviously
> need access to all the rows - what's the best way to do so?
[...]
> Any ideas or maybe modules which could be handy? (I looked at both
> Acme::Spork and Parallel::ForkManager but neither are appropriate)

There are four ways to do this with POE.  Whether they're appropriate
is left as an exercise. :)

http://search.cpan.org/search?query=POE+DBI&mode=dist

-- 
Rocco Caputo - http://poe.perl.org/


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

Date: 25 Nov 2006 09:52:27 -0800
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: speaking of forking -- parallel database fetches?
Message-Id: <1164477147.085963.127290@45g2000cws.googlegroups.com>


Rocco Caputo wrote:
> On 24 Nov 2006 11:23:27 -0800, DJ Stunks wrote:
> >
> > I have two straightforward SELECT statements, but both take about two
> > minutes to complete.  I'd like to run them in parallel, but I obviously
> > need access to all the rows - what's the best way to do so?
> [...]
> > Any ideas or maybe modules which could be handy? (I looked at both
> > Acme::Spork and Parallel::ForkManager but neither are appropriate)
>
> There are four ways to do this with POE.  Whether they're appropriate
> is left as an exercise. :)
>
> http://search.cpan.org/search?query=POE+DBI&mode=dist

this looks great, time to start reading :-)

you know POE had occurred to me, my search terms must have been bad
choices.

Thanks to both who responded,
-jp



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

Date: Sat, 25 Nov 2006 14:44:23 +0000
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: the opposite of 'chop'
Message-Id: <a4-dnQ4oCu5Ny_XYRVnyvg@pipex.net>

Henry Law wrote:
> Paul Lalli wrote:
> 
>> my $first_char = substr($string,0,1, q{});
> 
> I thought this was a typo until I looked up perlop; I see that q{} is 
> synonymous with ''.   Is there a particular benefit from using q{} 
> rather than '' here?  I understand that it's very convenient when 
> single-quoting a string that contains a single quote.

    Why is there anything there at all?

  my $first_char = substr($string, 0, 1);

does the job without any confusion.

-- 
              Just because I've written it doesn't mean that
                   either you or I have to believe it.


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

Date: Sat, 25 Nov 2006 18:25:24 +0000
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: the opposite of 'chop'
Message-Id: <kdem34-q32.ln1@osiris.mauzo.dyndns.org>


Quoth Big and Blue <No_4@dsl.pipex.com>:
> Henry Law wrote:
> > Paul Lalli wrote:
> > 
> >> my $first_char = substr($string,0,1, q{});
> > 
> > I thought this was a typo until I looked up perlop; I see that q{} is 
> > synonymous with ''.   Is there a particular benefit from using q{} 
> > rather than '' here?  I understand that it's very convenient when 
> > single-quoting a string that contains a single quote.
> 
>     Why is there anything there at all?
> 
>   my $first_char = substr($string, 0, 1);
> 
> does the job without any confusion.

No, that's not the same as a 'reverse chop'. The version given deletes
the first char of the string, as well as returning it.

Ben

-- 
Musica Dei donum optimi, trahit homines, trahit deos. |
Musica truces mollit animos, tristesque mentes erigit.|benmorrow@tiscali.co.uk
Musica vel ipsas arbores et horridas movet feras.     |


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

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


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