[30049] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1292 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 20 03:09:40 2008

Date: Wed, 20 Feb 2008 00:09:06 -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           Wed, 20 Feb 2008     Volume: 11 Number: 1292

Today's topics:
        How do you track down the way to POST a form ? <telemach@go2.pl>
    Re: How do you track down the way to POST a form ? <ben@morrow.me.uk>
        How to save a webpage contents to a file ( with LWP ) <jack_posemsky@yahoo.com>
        new CPAN modules on Wed Feb 20 2008 (Randal Schwartz)
    Re: Number of days since 1/1/2000 <rvtol+news@isolution.nl>
    Re: Number of days since 1/1/2000 <mothra@nowhereatall.com>
    Re: Number of days since 1/1/2000 <noreply@gunnar.cc>
    Re: Number of days since 1/1/2000 <smallpond@juno.com>
    Re: Number of days since 1/1/2000 <noreply@gunnar.cc>
    Re: Number of days since 1/1/2000 <smallpond@juno.com>
    Re: Number of days since 1/1/2000 <noreply@gunnar.cc>
    Re: Number of days since 1/1/2000 <rvtol+news@isolution.nl>
        PerlCtrl and arrays of arrays <Bruce.Axtens@gmail.com>
    Re: PerlCtrl and arrays of arrays <rvtol+news@isolution.nl>
    Re: Website test module <ben@morrow.me.uk>
    Re: Website test module <ignoramus9014@NOSPAM.9014.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 19 Feb 2008 15:29:00 -0800 (PST)
From: Telemach <telemach@go2.pl>
Subject: How do you track down the way to POST a form ?
Message-Id: <b6a2bec2-c7ab-4f51-a1a4-73990261e121@i12g2000prf.googlegroups.com>


I'm wondering if there is a some kind of a tool or a way to easily
detect the forms and all needed data to later submit using LWP. For
example there is this page :

http://www.ivosoftware.com/ivonaonline.php

Firefox says there is a form but hidden, I can get some data but still
no luck in submitting.
Is it necessary to know all the details ? maybe there is a module that
I can instruct to find a second textarea form, fill with content and
then press a button.

BTW: After you click 'Read Now' a page is responding with mp3 file so
is it possible to get this downloaded via Perl ? or do I have to parse
in search for mp3 link and then wget ?

- Telemach -


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

Date: Wed, 20 Feb 2008 01:19:42 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: How do you track down the way to POST a form ?
Message-Id: <eqbs85-qvm2.ln1@osiris.mauzo.dyndns.org>


Quoth Telemach <telemach@go2.pl>:
> 
> I'm wondering if there is a some kind of a tool or a way to easily
> detect the forms and all needed data to later submit using LWP.

http://www.research.att.com/sw/tools/wsp/

Ben



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

Date: Tue, 19 Feb 2008 23:15:45 -0800 (PST)
From: Jack <jack_posemsky@yahoo.com>
Subject: How to save a webpage contents to a file ( with LWP )
Message-Id: <412be207-d043-4b9d-bd96-25294294d50e@u72g2000hsf.googlegroups.com>

Hi there, does anyone skilled in the art of LWP (or other perl module)
and screen scraping know how to do the equivalent of a "file", "save
as" html content ?  Some webpages arent scrapeable but when you save
down their content to a local file its available.  Any ideas would be
great.

Also, if there is a drop down + button to select content BUT in the
HTML source no "submit" entry at all, how does one remote control a
user selection without this post handle ?

Thanks in advance,

Jack


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

Date: Wed, 20 Feb 2008 05:42:17 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Wed Feb 20 2008
Message-Id: <JwIvuH.259@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Acme-PIA-Export-0.019
http://search.cpan.org/~chrwin/Acme-PIA-Export-0.019/
Export contacts, calendars or todos from Arcor's PIA messaging 
----
Algorithm-Line-Bresenham-C-0.1
http://search.cpan.org/~kenwu/Algorithm-Line-Bresenham-C-0.1/
it is a C version Algorithm::Line::Bresenham to speed up a bit. 
----
Algorithm-TokenBucket-0.32
http://search.cpan.org/~kappa/Algorithm-TokenBucket-0.32/
Token bucket rate limiting algorithm 
----
Bundle-POE-IRC-1.06
http://search.cpan.org/~bingos/Bundle-POE-IRC-1.06/
Bundle to install all POE related IRC modules. 
----
CPAN-Mini-0.567
http://search.cpan.org/~rjbs/CPAN-Mini-0.567/
create a minimal mirror of CPAN 
----
CPAN-Reporter-1.09
http://search.cpan.org/~dagolden/CPAN-Reporter-1.09/
Adds CPAN Testers reporting to CPAN.pm 
----
Class-DBI-Loader-Oracle-0.02
http://search.cpan.org/~naughton/Class-DBI-Loader-Oracle-0.02/
Class::DBI::Loader Oracle Implementation. 
----
Class-DBI-Pageset-0.14
http://search.cpan.org/~mgrimes/Class-DBI-Pageset-0.14/
A flexible pager utility for Class::DBI using Data::Pageset 
----
Class-Lego-Constructor-0.003
http://search.cpan.org/~ferreira/Class-Lego-Constructor-0.003/
Automated constructor generation 
----
Class-Lego-Constructor-0.004
http://search.cpan.org/~ferreira/Class-Lego-Constructor-0.004/
Automated constructor generation 
----
ClearPress-92
http://search.cpan.org/~rpettett/ClearPress-92/
Simple, fresh & fruity MVC framework 
----
DBD-Pg-2.1.1
http://search.cpan.org/~turnstep/DBD-Pg-2.1.1/
PostgreSQL database driver for the DBI module 
----
DBD-Pg-2.1.1_1
http://search.cpan.org/~turnstep/DBD-Pg-2.1.1_1/
PostgreSQL database driver for the DBI module 
----
DBD-Pg-2.1.2
http://search.cpan.org/~turnstep/DBD-Pg-2.1.2/
PostgreSQL database driver for the DBI module 
----
Data-Properties-YAML-0.01
http://search.cpan.org/~johnd/Data-Properties-YAML-0.01/
YAML-ized properties for your application 
----
Devel-Command-0.09
http://search.cpan.org/~mcmahon/Devel-Command-0.09/
Perl extension to automatically load and register debugger command extensions 
----
Devel-Command-0.10
http://search.cpan.org/~mcmahon/Devel-Command-0.10/
Perl extension to automatically load and register debugger command extensions 
----
Devel-PerlySense-0.0144
http://search.cpan.org/~johanl/Devel-PerlySense-0.0144/
Perl IDE with Emacs frontend 
----
Devel-TrackObjects-0.3
http://search.cpan.org/~sullr/Devel-TrackObjects-0.3/
Track use of objects 
----
LaTeX-TOM-0.8_01
http://search.cpan.org/~schubiger/LaTeX-TOM-0.8_01/
A module for parsing, analyzing, and manipulating LaTeX documents. 
----
Locale-Currency-Format-1.23
http://search.cpan.org/~tnguyen/Locale-Currency-Format-1.23/
Perl functions for formatting monetary values 
----
Locale-Currency-Format-1.24
http://search.cpan.org/~tnguyen/Locale-Currency-Format-1.24/
Perl functions for formatting monetary values 
----
Locale-Maketext-Gettext-1.23
http://search.cpan.org/~imacat/Locale-Maketext-Gettext-1.23/
Joins the gettext and Maketext frameworks 
----
Lyrics-Fetcher-AZLyrics-0.03
http://search.cpan.org/~bigpresh/Lyrics-Fetcher-AZLyrics-0.03/
Get song lyrics from www.azlyrics.com 
----
Lyrics-Fetcher-AstraWeb-0.31
http://search.cpan.org/~bigpresh/Lyrics-Fetcher-AstraWeb-0.31/
Get song lyrics from lyrics.astraweb.com 
----
MSN-PersonalMessage-0.01
http://search.cpan.org/~kenwu/MSN-PersonalMessage-0.01/
Perl extension for change MSN Personal Message 
----
Net-Dopplr-0.5
http://search.cpan.org/~simonw/Net-Dopplr-0.5/
interface with Dopplr.com's web service 
----
Net-MirrorDir-0.12
http://search.cpan.org/~knorr/Net-MirrorDir-0.12/
Perl extension for compare local-directories and remote-directories with each other 
----
Net-Write-1.02
http://search.cpan.org/~gomor/Net-Write-1.02/
a portable interface to open and send raw data to network 
----
OLE-Storage_Lite-0.16
http://search.cpan.org/~jmcnamara/OLE-Storage_Lite-0.16/
Simple Class for OLE document interface. 
----
Object-InsideOut-3.37
http://search.cpan.org/~jdhedden/Object-InsideOut-3.37/
Comprehensive inside-out object support module 
----
POE-Component-Archive-Any-0.001
http://search.cpan.org/~zoffix/POE-Component-Archive-Any-0.001/
a non-blocking wrapper around Archive::Any 
----
POE-Component-Client-DNSBL-0.04
http://search.cpan.org/~bingos/POE-Component-Client-DNSBL-0.04/
A component that provides non-blocking DNSBL lookups 
----
POE-Component-IRC-Plugin-YouTube-MovieFindStore-0.02
http://search.cpan.org/~zoffix/POE-Component-IRC-Plugin-YouTube-MovieFindStore-0.02/
plugin for finding, resolving .FLV, and optionally storing YouTube URIs. 
----
POE-Component-WWW-DoingItWrongCom-RandImage-0.02
http://search.cpan.org/~zoffix/POE-Component-WWW-DoingItWrongCom-RandImage-0.02/
non-blocking way to get URIs to random images from <http://www.doingitwrong.com> 
----
POE-Component-WebService-Validator-HTML-W3C-0.06
http://search.cpan.org/~zoffix/POE-Component-WebService-Validator-HTML-W3C-0.06/
a non-blocking POE wrapper around WebService::Validator::HTML::W3C 
----
POE-Component-Win32-ChangeNotify-1.08
http://search.cpan.org/~bingos/POE-Component-Win32-ChangeNotify-1.08/
A POE wrapper around Win32::ChangeNotify. 
----
POE-Component-Win32-EventLog-1.12
http://search.cpan.org/~bingos/POE-Component-Win32-EventLog-1.12/
A POE component that provides non-blocking access to Win32::EventLog. 
----
POE-Component-Win32-Service-1.10
http://search.cpan.org/~bingos/POE-Component-Win32-Service-1.10/
A POE component that provides non-blocking access to Win32::Service. 
----
POEIKC-0.00_04
http://search.cpan.org/~suzuki/POEIKC-0.00_04/
POE IKC daemon and client 
----
Proc-Exists-0.10
http://search.cpan.org/~brianski/Proc-Exists-0.10/
quickly check for process existence 
----
Sort-Key-OID-0.03
http://search.cpan.org/~salva/Sort-Key-OID-0.03/
sort OIDs very fast 
----
Temperature-Windchill-0.01
http://search.cpan.org/~jtrammell/Temperature-Windchill-0.01/
calculate effective temperature as 
----
Test-Run-0.0113
http://search.cpan.org/~shlomif/Test-Run-0.0113/
a new and improved test harness for TAP scripts. 
----
Test-Run-CmdLine-0.0107
http://search.cpan.org/~shlomif/Test-Run-CmdLine-0.0107/
Analyze tests from the command line using Test::Run 
----
Text-Markdown-1.0.13
http://search.cpan.org/~bobtfish/Text-Markdown-1.0.13/
Convert MultiMarkdown syntax to (X)HTML 
----
TextMate-JumpTo-0.05
http://search.cpan.org/~andya/TextMate-JumpTo-0.05/
Tell TextMate to jump to a particular file, line 
----
WWW-CPAN-0.008
http://search.cpan.org/~ferreira/WWW-CPAN-0.008/
CPAN as a web service 
----
WWW-PastebinCom-Create-0.001
http://search.cpan.org/~zoffix/WWW-PastebinCom-Create-0.001/
paste to <http://pastebin.com> from Perl. 
----
WebService-Yelp-0.03
http://search.cpan.org/~jdr/WebService-Yelp-0.03/
Yelp.com API Client Implementation 
----
autobox-2.10
http://search.cpan.org/~chocolate/autobox-2.10/
call methods on builtin types 
----
autobox-Closure-Attributes-0.01
http://search.cpan.org/~sartak/autobox-Closure-Attributes-0.01/
closures are objects are closures 
----
sofu-0.2.9
http://search.cpan.org/~maluku/sofu-0.2.9/


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Wed, 20 Feb 2008 00:01:22 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Number of days since 1/1/2000
Message-Id: <fpfqre.1h0.1@news.isolution.nl>

Mothra schreef:
> oprah.chopra:

>> I am using the following subroutine to calculate the  number of days
>> since 1/1/2000 . Is there any possible bug in it? I know  I can use
>> Date::Manip but it will slow down my program which is around 100 kb
>> long.
>
> You may want to take a look at the DateTime project
> http://datetime.perl.org/
>
> Many very smart people have spent many hours making sure DateTime
> calculations are correct. Why reinvent the wheel when you don't have
> to.
>
> use strict;
> use warnings;
> use DateTime;
>
> my $dt = DateTime->now;
>
>     my $base_date = DateTime->new(
>       year      => 2000,
>       month     => 1,
>       day       => 1,
>       time_zone => 'UTC',
>     );
>
>     print int( $dt->jd - $base_date->jd );

DateTime can surprise too:

perl -MData::Dumper -MDateTime -e'
     $dt = DateTime->new( safe =>1,
         year => 2008, month => 3, day => 25, time_zone =>
"Africa/Cairo",
     )->add(months => 1);
     print Dumper($dt)
' |less

perl -MData::Dumper -MDateTime -e'
     $dt = DateTime->new( safe => 1,
         year => 2008, month => 4, day => 26, time_zone =>
"Africa/Cairo",
     )->subtract(days => 1);
     print Dumper($dt)
' |less

perl -MData::Dumper -MDateTime -e'
     $dt = DateTime->new( safe => 1,
         year => 2008, month => 4, day => 25, time_zone =>
"Africa/Cairo",
     );
     print Dumper($dt)
' |less

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Tue, 19 Feb 2008 17:06:46 -0800
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: Number of days since 1/1/2000
Message-Id: <47bb8841$1@usenet.ugs.com>

Hi Dr. Ruud,

"Dr.Ruud" <rvtol+news@isolution.nl> wrote in message 
news:fpfqre.1h0.1@news.isolution.nl...
>> Mothra schreef:

(snipped)

>> You may want to take a look at the DateTime project
>> http://datetime.perl.org/
>>
>> Many very smart people have spent many hours making sure DateTime
>> calculations are correct. Why reinvent the wheel when you don't have
>> to.
>>
>> use strict;
>> use warnings;
>> use DateTime;
>>
>> my $dt = DateTime->now;
>>
>>     my $base_date = DateTime->new(
>>       year      => 2000,
>>       month     => 1,
>>       day       => 1,
>>       time_zone => 'UTC',
>>     );
>>
>>     print int( $dt->jd - $base_date->jd );
>
> DateTime can surprise too:
>
> perl -MData::Dumper -MDateTime -e'
>     $dt = DateTime->new( safe =>1,

Hmm, safe=>1,
I am not fimilar with that one.
In any event, looking at my previous post I should have done
my $dt = DateTime->now(time_zone => 'UTC'); To specify
a specific time zone instead of using a floating one (default)
when doing date/time math it is best to convert to UTC
do the math and convert back to the timezone of choice.
This would be the workaround for the problem that you have just
discribed.

Hope this helps

Mothra 




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

Date: Wed, 20 Feb 2008 02:28:04 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Number of days since 1/1/2000
Message-Id: <621dtjF215ibnU1@mid.individual.net>

smallpond wrote:
> On Feb 19, 4:42 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
>> smallpond wrote:
>>> On Feb 18, 2:20 pm, oprah.cho...@gmail.com wrote:
>>>> ... to calculate the  number of days since 1/1/2000
>> >
>>> The time on 1/1/2000 is unlikely to change.  You don't need to
>>> recalculate it.  Just set it as a constant in your program
>>> and you don't need any modules.
>>
>> In the code below I make use of a constant SUMMERNIGHT which contains
>> what time() will return 15 minutes after midnight at June, 20.
>>
>> C:\home>type test.pl
>> use Time::Local;
>> use constant Y2000       =>  946702800;
>> use constant Y2038       => 2145934800;
>> use constant SUMMERNIGHT => 1213913700;
>>
>> sub calc_days1 {  # smallpond's code
>>      my $diff = SUMMERNIGHT;
>>      warn "Is this still right?" if $diff > Y2038;
>>      $diff -= Y2000;
>>      int($diff / 86400);
>>
>> }
>>
>> sub calc_days2 {  # Gunnar's code
>>      my $start = timelocal 0, 0, 0, 1, 0, 2000;
>>      my $today = timelocal 0, 0, 0, (localtime SUMMERNIGHT)[3..5];
>>      sprintf '%.0f', ($today - $start) / 86400;
>>
>> }
>>
>> print 'calc_days1: ', calc_days1(), "\n",
>>        'calc_days2: ', calc_days2(), "\n";
>>
>> C:\home>test.pl
>> calc_days1: 3092
>> calc_days2: 3093
>>
>> Oops!!
>>
>> Not using any module seems to be bad advice.
> 
> oops indeed.  I get 3092 for both.  Perhaps you should
> investigate DST in your two conversions to see which is
> correct.  I'm pretty sure that Unix clock seconds are
> fairly constant.

The reason why you get the same result is that the SUMMERNIGHT constant 
was based on the CET timezone, while you seem to be running the code in 
the EST zone. (This illustrates that static time related constants make 
the code non-portable.)

If you set the constants like this, the different number of days will 
probably appear when you run the code too:

use constant Y2000       => timelocal 0,0,0,1,0,2000;
use constant Y2038       => timelocal 0,0,0,1,0,2038;
use constant SUMMERNIGHT => timelocal 0,15,0,20,5,2008;

The point I'm trying to make is that my code take DST into account, 
while your code doesn't. It would be very difficult to properly deal 
with DST without using any module.

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


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

Date: Tue, 19 Feb 2008 18:29:16 -0800 (PST)
From: smallpond <smallpond@juno.com>
Subject: Re: Number of days since 1/1/2000
Message-Id: <2e6cd82d-763c-496f-94d4-0aba90753ba8@28g2000hsw.googlegroups.com>

On Feb 19, 8:28 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> smallpond wrote:
> > On Feb 19, 4:42 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> >> smallpond wrote:
> >>> On Feb 18, 2:20 pm, oprah.cho...@gmail.com wrote:
> >>>> ... to calculate the  number of days since 1/1/2000
>
> >>> The time on 1/1/2000 is unlikely to change.  You don't need to
> >>> recalculate it.  Just set it as a constant in your program
> >>> and you don't need any modules.
>
> >> In the code below I make use of a constant SUMMERNIGHT which contains
> >> what time() will return 15 minutes after midnight at June, 20.
>
> >> C:\home>type test.pl
> >> use Time::Local;
> >> use constant Y2000       =>  946702800;
> >> use constant Y2038       => 2145934800;
> >> use constant SUMMERNIGHT => 1213913700;
>
> >> sub calc_days1 {  # smallpond's code
> >>      my $diff = SUMMERNIGHT;
> >>      warn "Is this still right?" if $diff > Y2038;
> >>      $diff -= Y2000;
> >>      int($diff / 86400);
>
> >> }
>
> >> sub calc_days2 {  # Gunnar's code
> >>      my $start = timelocal 0, 0, 0, 1, 0, 2000;
> >>      my $today = timelocal 0, 0, 0, (localtime SUMMERNIGHT)[3..5];
> >>      sprintf '%.0f', ($today - $start) / 86400;
>
> >> }
>
> >> print 'calc_days1: ', calc_days1(), "\n",
> >>        'calc_days2: ', calc_days2(), "\n";
>
> >> C:\home>test.pl
> >> calc_days1: 3092
> >> calc_days2: 3093
>
> >> Oops!!
>
> >> Not using any module seems to be bad advice.
>
> > oops indeed.  I get 3092 for both.  Perhaps you should
> > investigate DST in your two conversions to see which is
> > correct.  I'm pretty sure that Unix clock seconds are
> > fairly constant.
>
> The reason why you get the same result is that the SUMMERNIGHT constant
> was based on the CET timezone, while you seem to be running the code in
> the EST zone. (This illustrates that static time related constants make
> the code non-portable.)
>
> If you set the constants like this, the different number of days will
> probably appear when you run the code too:
>
> use constant Y2000       => timelocal 0,0,0,1,0,2000;
> use constant Y2038       => timelocal 0,0,0,1,0,2038;
> use constant SUMMERNIGHT => timelocal 0,15,0,20,5,2008;
>
> The point I'm trying to make is that my code take DST into account,
> while your code doesn't. It would be very difficult to properly deal
> with DST without using any module.
>
> --
> Gunnar Hjalmarsson
> Email:http://www.gunnar.cc/cgi-bin/contact.pl



I know what you meant, and I don't want to get into an argument
over what is the right answer.  The problem is not well
specified.  However, in most applications the number of
elapsed days over a given time interval should not change
depending on the timezone of the person running the code
and should be expected to increase monotonically with time.
-- S


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

Date: Wed, 20 Feb 2008 04:13:05 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Number of days since 1/1/2000
Message-Id: <621k2gF21kr8jU1@mid.individual.net>

smallpond wrote:
> On Feb 19, 8:28 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
>> The point I'm trying to make is that my code take DST into account,
>> while your code doesn't. It would be very difficult to properly deal
>> with DST without using any module.
> 
> in most applications the number of
> elapsed days over a given time interval should not change
> depending on the timezone of the person running the code

How would you avoid that when you count whole days between dates in the 
local time zone, and not some specific zone such as UTC? Are you 
claiming that "most applications" ignore the daylight savings issue?

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


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

Date: Tue, 19 Feb 2008 20:22:27 -0800 (PST)
From: smallpond <smallpond@juno.com>
Subject: Re: Number of days since 1/1/2000
Message-Id: <137d5120-9219-4433-b992-17fae3e28470@z17g2000hsg.googlegroups.com>

On Feb 19, 10:13 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> smallpond wrote:
> > On Feb 19, 8:28 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> >> The point I'm trying to make is that my code take DST into account,
> >> while your code doesn't. It would be very difficult to properly deal
> >> with DST without using any module.
>
> > in most applications the number of
> > elapsed days over a given time interval should not change
> > depending on the timezone of the person running the code
>
> How would you avoid that when you count whole days between dates in the
> local time zone, and not some specific zone such as UTC? Are you
> claiming that "most applications" ignore the daylight savings issue?
>
> --
> Gunnar Hjalmarsson
> Email:http://www.gunnar.cc/cgi-bin/contact.pl



Who says the problem was "counting whole days between dates in
the local time zone"?


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

Date: Wed, 20 Feb 2008 05:55:20 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Number of days since 1/1/2000
Message-Id: <621q27F21lempU1@mid.individual.net>

smallpond wrote:
> On Feb 19, 10:13 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
>> smallpond wrote:
>>> On Feb 19, 8:28 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
>>>> The point I'm trying to make is that my code take DST into account,
>>>> while your code doesn't. It would be very difficult to properly deal
>>>> with DST without using any module.
>>>
>>> in most applications the number of
>>> elapsed days over a given time interval should not change
>>> depending on the timezone of the person running the code
>>
>> How would you avoid that when you count whole days between dates in the
>> local time zone, and not some specific zone such as UTC? Are you
>> claiming that "most applications" ignore the daylight savings issue?
> 
> Who says the problem was "counting whole days between dates in
> the local time zone"?

Both you and I do. You do it implicitly with your code. ;-)

http://groups.google.com/group/comp.lang.perl.misc/msg/fd52bb54b4d3be81

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


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

Date: Wed, 20 Feb 2008 08:30:10 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Number of days since 1/1/2000
Message-Id: <fpgopn.16g.1@news.isolution.nl>

Mothra schreef:
> Dr.Ruud:

>> perl -MData::Dumper -MDateTime -e'
>>     $dt = DateTime->new( safe =>1,
>
> Hmm, safe=>1,
> I am not fimilar with that one.

Oops, no, it is a (to me obvious) mode I am supposing, but it isn't in
DateTime yet. (see datetime mailing list).

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Tue, 19 Feb 2008 22:44:06 -0800 (PST)
From: axtens <Bruce.Axtens@gmail.com>
Subject: PerlCtrl and arrays of arrays
Message-Id: <b93bd1f4-45fe-4711-a3fc-ad936c294cee@i29g2000prf.googlegroups.com>

G'day everyone

How would I return an array of arrays from perl, eg
    my @r = [1, 2, [3,4]];
such that VB/VBScript would think the data to be
    r = array(1,2,array(3,4))

This is PerlCtrl specific I know, and yes I should take it to the
ActiveState list, but I thought I'd ask here anyway, just in case.

Kind regards,
Bruce.


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

Date: Wed, 20 Feb 2008 08:32:31 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: PerlCtrl and arrays of arrays
Message-Id: <fpgopo.16g.1@news.isolution.nl>

axtens schreef:

> How would I return an array of arrays from perl, eg
>     my @r = [1, 2, [3,4]];
> such that VB/VBScript would think the data to be
>     r = array(1,2,array(3,4))
> 
> This is PerlCtrl specific I know, and yes I should take it to the
> ActiveState list, but I thought I'd ask here anyway, just in case.

Maybe you are looking for

     my @r = (
         1,
         2,
         [ 3, 4 ],
     );

or for

     my @r = (
         [ 1    ],
         [ 2    ],
         [ 3, 4 ],
     );

-- 
Affijn, Ruud

"Gewoon is een tijger."


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

Date: Tue, 19 Feb 2008 23:13:05 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Website test module
Message-Id: <1d4s85-47m2.ln1@osiris.mauzo.dyndns.org>


Quoth Ignoramus9014 <ignoramus9014@NOSPAM.9014.invalid>:
> On 2008-02-19, Ben Morrow <ben@morrow.me.uk> wrote:
> >
> > You should be able to subclass LWP::Protocol::http, override
> > ->_new_socket to map B->A and call SUPER::_new_socket, and then use
> > LWP::Protocol::implementor to set your new class as the implementation
> > to use for http. Then you should be able to just use WWW::Mech normally.
> > Something like (completely untested):
<snip>
> 
> Ben, thanks, it is a little over my head, but I spent some time
> trying. 
> 
> I got to the point of running queries, but the _new_socket function
> was never called. 
> 
> Here's my actual code:
> 
> ######################################################################
> 
> #!/usr/bin/perl
> 
> use LWP;
> use WWW::Mechanize;
> use Data::Dumper;
> 
> {
>   package My::LWP::Protocol::http;
>   use Data::Dumper;
>   use LWP::Protocol::http;
>   
>   our @ISA = 'LWP::Protocol::http';
>   
>   my %fake = (
>               'B' => '127.0.0.1',
>              );
>   
>   sub _new_socket {
>     my ($self, $host, $port, $timeout) = @_;
>     print STDERR "HOST=$host\n";
>     exit 0;
>     $fake{$host} and $host = $fake{$host};
>     return $self->SUPER::_new_socket($host, $port, $timeout);
>   }
> 
>   sub new {
>     return LWP::Protocol::http->new;
>   }

You don't want this sub. This, in fact, causes a LWP::Protocol::http
object to be returned instead, which completely defeats the point. Just
let ->new be inherited: it will construct the correct object.

However, having now tried the code, it seems you do need

    sub socket_class { 'LWP::Protocol::http::Socket' }

as otherwise LWP assumes you will be using My::L::P::h::Socket, which
doesn't exist. With this change it works for me.

Ben



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

Date: Tue, 19 Feb 2008 19:50:19 -0600
From: Ignoramus9014 <ignoramus9014@NOSPAM.9014.invalid>
Subject: Re: Website test module
Message-Id: <v-2dnQfSifPGGibanZ2dnUVZ_umlnZ2d@giganews.com>

On 2008-02-19, Ben Morrow <ben@morrow.me.uk> wrote:
>
> Quoth Ignoramus9014 <ignoramus9014@NOSPAM.9014.invalid>:
>> On 2008-02-19, Ben Morrow <ben@morrow.me.uk> wrote:
>> >
>> > You should be able to subclass LWP::Protocol::http, override
>> > ->_new_socket to map B->A and call SUPER::_new_socket, and then use
>> > LWP::Protocol::implementor to set your new class as the implementation
>> > to use for http. Then you should be able to just use WWW::Mech normally.
>> > Something like (completely untested):
><snip>
>> 
>> Ben, thanks, it is a little over my head, but I spent some time
>> trying. 
>> 
>> I got to the point of running queries, but the _new_socket function
>> was never called. 
>> 
>> Here's my actual code:
>> 
>> ######################################################################
>> 
>> #!/usr/bin/perl
>> 
>> use LWP;
>> use WWW::Mechanize;
>> use Data::Dumper;
>> 
>> {
>>   package My::LWP::Protocol::http;
>>   use Data::Dumper;
>>   use LWP::Protocol::http;
>>   
>>   our @ISA = 'LWP::Protocol::http';
>>   
>>   my %fake = (
>>               'B' => '127.0.0.1',
>>              );
>>   
>>   sub _new_socket {
>>     my ($self, $host, $port, $timeout) = @_;
>>     print STDERR "HOST=$host\n";
>>     exit 0;
>>     $fake{$host} and $host = $fake{$host};
>>     return $self->SUPER::_new_socket($host, $port, $timeout);
>>   }
>> 
>>   sub new {
>>     return LWP::Protocol::http->new;
>>   }
>
> You don't want this sub. This, in fact, causes a LWP::Protocol::http
> object to be returned instead, which completely defeats the point. Just
> let ->new be inherited: it will construct the correct object.
>
> However, having now tried the code, it seems you do need
>
>     sub socket_class { 'LWP::Protocol::http::Socket' }
>
> as otherwise LWP assumes you will be using My::L::P::h::Socket, which
> doesn't exist. With this change it works for me.
>
> Ben
>

Ben, your code works GREAT. I am thinking of submitting a patch for
Mechanize. But I will use it first. I will change it to suit my needs
better, but it is a great start. 

Here's the final snippet.

#!/usr/bin/perl

use LWP;
use WWW::Mechanize;
use Data::Dumper;

{
  package My::LWP::Protocol::http;
  use Data::Dumper;
  use LWP::Protocol::http;
  
  our @ISA = 'LWP::Protocol::http';
  
  my %fake = (
              'B' => '127.0.0.1',
              'www.algebra.com' => '127.0.0.1'
             );
  
  sub _new_socket {
    my ($self, $host, $port, $timeout) = @_;
    $fake{$host} and $host = $fake{$host};
    print STDERR "HOST=$host\n";
    #exit 0;
    return $self->SUPER::_new_socket($host, $port, $timeout);
  }

  #sub new {
  #  return LWP::Protocol::http->new;
  #}

  sub socket_class { 'LWP::Protocol::http::Socket' } 

  LWP::Protocol::implementor http => __PACKAGE__;
}

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

my $resp = $M->get( 'http://www.algebra.com/robots.txt' );

print $resp->content;


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

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


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