[29175] in Perl-Users-Digest
Perl-Users Digest, Issue: 419 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 9 06:09:57 2007
Date: Wed, 9 May 2007 03:09:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 9 May 2007 Volume: 11 Number: 419
Today's topics:
Re: Action before clicking a link <lgt@invalid.com>
Re: Action before clicking a link <no@email.com>
Re: Can not add a scalar variable of path into @INC? <Michael.Yxf@gmail.com>
Re: Can not add a scalar variable of path into @INC? <sisyphus1@nomail.afraid.org>
Re: Can not add a scalar variable of path into @INC? <Michael.Yxf@gmail.com>
Re: Can not add a scalar variable of path into @INC? <Michael.Yxf@gmail.com>
Re: Can not add a scalar variable of path into @INC? <sisyphus1@nomail.afraid.org>
Re: Can not add a scalar variable of path into @INC? <Michael.Yxf@gmail.com>
Re: Converting 4 bytes to a float <nobull67@gmail.com>
Re: Converting 4 bytes to a float <nobull67@gmail.com>
Re: Converting 4 bytes to a float <rvtol+news@isolution.nl>
new CPAN modules on Wed May 9 2007 (Randal Schwartz)
Re: parsing a variable length record from a mixed forma <nobull67@gmail.com>
suggestions on intelligent processing of data sets in a alt.testing@{g}mail.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 09 May 2007 10:30:52 +0300
From: lg <lgt@invalid.com>
Subject: Re: Action before clicking a link
Message-Id: <r2u2435fe2urf7sfjuvpvlidkpc3d79rq3@4ax.com>
Brian Wakem <no@email.com> wrote:
>lg wrote:
>
>> I have the following code (scaled down from complete code):
>>
>>
>> [snip]
>> print "Press link below to go to next level";
>> print '<form action="http://thisandthat.com" method="post">';
>> print "</form>";
>> [snip]
>>
>> When user clicks the link he then goes to the page link point to.
>> I would like to save info that the user has clicked the link.
>> How do I do that?
>
>
>Point to a script which redirects after logging.
Thank for the tip.
How do I do the redirecting?
------------------------------
Date: Wed, 09 May 2007 09:54:59 +0100
From: Brian Wakem <no@email.com>
Subject: Re: Action before clicking a link
Message-Id: <5adgj3F2ohr2eU1@mid.individual.net>
lg wrote:
> Brian Wakem <no@email.com> wrote:
>
>>lg wrote:
>>
>>> I have the following code (scaled down from complete code):
>>>
>>>
>>> [snip]
>>> print "Press link below to go to next level";
>>> print '<form action="http://thisandthat.com" method="post">';
>>> print "</form>";
>>> [snip]
>>>
>>> When user clicks the link he then goes to the page link point to.
>>> I would like to save info that the user has clicked the link.
>>> How do I do that?
>>
>>
>>Point to a script which redirects after logging.
>
> Thank for the tip.
> How do I do the redirecting?
http://search.cpan.org/~lds/CGI.pm-3.29/CGI.pm#GENERATING_A_REDIRECTION_HEADER
--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
------------------------------
Date: 8 May 2007 21:57:17 -0700
From: Michael Yang <Michael.Yxf@gmail.com>
Subject: Re: Can not add a scalar variable of path into @INC?
Message-Id: <1178686636.914904.167750@n59g2000hsh.googlegroups.com>
Thanks so much, Tad!
Here is another problem after trying the BEGIN block statement:
my $mylib = undef;
BEGIN
{
$mylib = "/home/michael/mylib";
unshift @INC, $mylib;
}
print "\$mylib is $mylib.\n" ###########the value of $mylib is
empty.
The statement inside BEGIN is evaluated during compile time, seems not
in run time.
The $mylib value is set to undef outside the block.
How could make the codes inside BEGIN be evaluated both during compile
time and run time?
It's really appreciated of your answer!
On May 9, 11:19 am, Tad McClellan <t...@augustmail.com> wrote:
> Michael Yang <Michael....@gmail.com> wrote:
> > But it doesn't work when I passed mylib as a scalar variable:
> > my $libpath = "/home/michael/mylib";
>
> That statement happens at run time.
>
> > use lib $libpath;
>
> That statement happens at compile time.
>
> compile time comes before run time, so the "use" is evaluated
> before the variable has been given a value.
>
> Didn't you get an error message like:
>
> Empty compile time value given to use lib at ... ?
Yes, I got this error msg before and didn't get to it.
>
> > I need to use this scalar variable instead of hard-coded absolute
> > path.
>
> Why do you need to use this scalar variable instead of hard-coded
> absolute path?
To make my toolkit portable to different machines.
>
> > Is there any ways to do this?
>
> There is a way to force statements to be evaluated at compile time,
> read up on the BEGIN block in perlmod.pod.
>
> --
> Tad McClellan SGML consulting
> t...@augustmail.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Wed, 9 May 2007 15:17:35 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Can not add a scalar variable of path into @INC?
Message-Id: <46415965$0$32316$afc38c87@news.optusnet.com.au>
"Michael Yang" <Michael.Yxf@gmail.com> wrote in message
.
.
> The $mylib value is set to undef outside the block.
Why ?
> How could make the codes inside BEGIN be evaluated both during compile
> time and run time?
No need to evaluate the code that's in the BEGIN at runtime - $mylib will
retain the value it was assigned in the BEGIN{} block:
--------------------------
use warnings;
BEGIN {
$mylib = '/some/place';
unshift @INC, $mylib;
}
print "@INC\n", $mylib, "\n";
--------------------------
For me that produces:
/some/place C:/perl58_M/lib C:/perl58_M/site/lib .
/some/place
On the other hand, if you assign another value to $mylib during runtime (as
you have done) then, of course, $mylib will contain that new value (which
was undef in the example you provided).
Cheers,
Rob
------------------------------
Date: 8 May 2007 22:30:44 -0700
From: Michael Yang <Michael.Yxf@gmail.com>
Subject: Re: Can not add a scalar variable of path into @INC?
Message-Id: <1178688644.874483.311650@h2g2000hsg.googlegroups.com>
On May 9, 1:17 pm, "Sisyphus" <sisyph...@nomail.afraid.org> wrote:
> "Michael Yang" <Michael....@gmail.com> wrote in message
>
> .
> .
>
> > The $mylib value is set to undef outside the block.
>
> Why ?
>
> > How could make the codes inside BEGIN be evaluated both during compile
> > time and run time?
>
> No need to evaluate the code that's in the BEGIN at runtime - $mylib will
> retain the value it was assigned in the BEGIN{} block:
>
> --------------------------
> use warnings;
>
> BEGIN {
> $mylib = '/some/place';
> unshift @INC, $mylib;
>
> }
>
> print "@INC\n", $mylib, "\n";
> --------------------------
>
> For me that produces:
>
> /some/place C:/perl58_M/lib C:/perl58_M/site/lib .
> /some/place
>
> On the other hand, if you assign another value to $mylib during runtime (as
> you have done) then, of course, $mylib will contain that new value (which
> was undef in the example you provided).
>
> Cheers,
> Rob
Thank you so much, Rob!
Now I have got it works. I should not assign value to the $mylib, only
need to declare it.
Thanks again~
Michael.
------------------------------
Date: 8 May 2007 22:42:05 -0700
From: Michael Yang <Michael.Yxf@gmail.com>
Subject: Re: Can not add a scalar variable of path into @INC?
Message-Id: <1178689325.783563.139350@q75g2000hsh.googlegroups.com>
On May 9, 1:17 pm, "Sisyphus" <sisyph...@nomail.afraid.org> wrote:
> "Michael Yang" <Michael....@gmail.com> wrote in message
>
> .
> .
>
> > The $mylib value is set to undef outside the block.
>
> Why ?
>
> > How could make the codes inside BEGIN be evaluated both during compile
> > time and run time?
>
> No need to evaluate the code that's in the BEGIN at runtime - $mylib will
> retain the value it was assigned in the BEGIN{} block:
>
> --------------------------
> use warnings;
>
> BEGIN {
> $mylib = '/some/place';
> unshift @INC, $mylib;
>
> }
>
> print "@INC\n", $mylib, "\n";
> --------------------------
use warnings;
BEGIN {
$mylib = '/some/place';
unshift @INC, $mylib;
}
print "@INC\n", $mylib, "\n";
Is the new value of @INC be available to the sub-process of this
script?
for example, invoking another Perl script from here. Will the script
inherit this new @INC values, containing the extra search path of
$mylib?
>
> For me that produces:
>
> /some/place C:/perl58_M/lib C:/perl58_M/site/lib .
> /some/place
>
> On the other hand, if you assign another value to $mylib during runtime (as
> you have done) then, of course, $mylib will contain that new value (which
> was undef in the example you provided).
>
> Cheers,
> Rob
------------------------------
Date: Wed, 9 May 2007 17:59:26 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Can not add a scalar variable of path into @INC?
Message-Id: <46417f55$0$2888$afc38c87@news.optusnet.com.au>
"Michael Yang" <Michael.Yxf@gmail.com> wrote in message
news:1178689325.783563.139350@q75g2000hsh.googlegroups.com...
.
.
>
> Is the new value of @INC be available to the sub-process of this
> script?
> for example, invoking another Perl script from here. Will the script
> inherit this new @INC values, containing the extra search path of
> $mylib?
No - you can check as follows:
--- try.pl ---
use warnings;
BEGIN {
$mylib = '/some/place';
unshift @INC, $mylib;
}
print "@INC\n", $mylib, "\n";
system("perl try2.pl");
-----------
--- try2.pl ---
use warnings;
print "@INC\n";
--------------
When I run 'perl try.pl' I get:
/some/place C:/perl58_M/lib C:/perl58_M/site/lib .
/some/place
C:/perl58_M/lib C:/perl58_M/site/lib .
So clearly, the modified @INC is not inherited.
You need to rewrite try.pl and try2.pl something like:
--- try.pl ---
use warnings;
BEGIN {
$mylib = '/some/place';
unshift @INC, $mylib;
}
print "@INC\n", $mylib, "\n";
system("perl try2.pl $mylib");
-----------
--- try2.pl ---
use warnings;
BEGIN {
unshift @INC, $ARGV[0];
}
print "@INC\n";
--------------
Now when I run 'perl try.pl' I get:
/some/place C:/perl58_M/lib C:/perl58_M/site/lib .
/some/place
/some/place C:/perl58_M/lib C:/perl58_M/site/lib .
(The modified @INC has been successfully passed on to try2.pl.)
Cheers,
Rob
------------------------------
Date: 9 May 2007 02:54:21 -0700
From: Michael Yang <Michael.Yxf@gmail.com>
Subject: Re: Can not add a scalar variable of path into @INC?
Message-Id: <1178704461.599478.254540@o5g2000hsb.googlegroups.com>
On May 9, 3:59 pm, "Sisyphus" <sisyph...@nomail.afraid.org> wrote:
> "Michael Yang" <Michael....@gmail.com> wrote in message
>
> news:1178689325.783563.139350@q75g2000hsh.googlegroups.com...
> .
> .
>
>
>
> > Is the new value of @INC be available to the sub-process of this
> > script?
> > for example, invoking another Perl script from here. Will the script
> > inherit this new @INC values, containing the extra search path of
> > $mylib?
>
> No - you can check as follows:
>
> --- try.pl ---
> use warnings;
>
> BEGIN {
> $mylib = '/some/place';
> unshift @INC, $mylib;
>
> }
>
> print "@INC\n", $mylib, "\n";
>
> system("perl try2.pl");
> -----------
>
> --- try2.pl ---
> use warnings;
>
> print "@INC\n";
> --------------
>
> When I run 'perl try.pl' I get:
>
> /some/place C:/perl58_M/lib C:/perl58_M/site/lib .
> /some/place
> C:/perl58_M/lib C:/perl58_M/site/lib .
>
> So clearly, the modified @INC is not inherited.
>
> You need to rewrite try.pl and try2.pl something like:
>
> --- try.pl ---
> use warnings;
>
> BEGIN {
> $mylib = '/some/place';
> unshift @INC, $mylib;
>
> }
>
> print "@INC\n", $mylib, "\n";
>
> system("perl try2.pl $mylib");
> -----------
>
> --- try2.pl ---
> use warnings;
>
> BEGIN {
> unshift @INC, $ARGV[0];
>
> }
>
> print "@INC\n";
> --------------
>
> Now when I run 'perl try.pl' I get:
>
> /some/place C:/perl58_M/lib C:/perl58_M/site/lib .
> /some/place
> /some/place C:/perl58_M/lib C:/perl58_M/site/lib .
>
> (The modified @INC has been successfully passed on to try2.pl.)
>
> Cheers,
> Rob
Thank you so much for your reply!
It seems I have to assign the values to $ENV{'PERL5LIB'} , so that it
can be inherited.
Michael.
------------------------------
Date: 8 May 2007 23:32:06 -0700
From: Brian McCauley <nobull67@gmail.com>
Subject: Re: Converting 4 bytes to a float
Message-Id: <1178692326.790235.292820@p77g2000hsh.googlegroups.com>
On May 9, 1:35 am, "Larry.Mart...@gmail.com" <Larry.Mart...@gmail.com>
wrote:
> I have a situation where I have to read in 4 values from a text file,
> then convert that into a float that I can use for arithmetic.
>
> For example, the file contains "85,170,174,214" - I read this in, and
> split it into an array, @d
>
> In C, I would do something akin to this:
>
> union convert_float32 {
> float f; // float view
> unsigned int i; // uint32 view} c;
>
> unsigned char i[4];
> char *q;
>
> for (int j=0; j<4; j++) i[j] = (unsigned char)strtoul(d[j], &q, 10);
> c.i = ((unsigned int)i[0] << 24) | ((unsigned int)i[1] << 16) |
> ((unsigned int)i[2] << 8) | (unsigned int)i[3];
>
> and c.f would have the value I want (in this example
> 23458486419456.000000)
>
> Is there some way I can achieve the result with perl?
>
> TIA!
> -larry
>
> How can I do a similar conversion in perl?
------------------------------
Date: 8 May 2007 23:37:41 -0700
From: Brian McCauley <nobull67@gmail.com>
Subject: Re: Converting 4 bytes to a float
Message-Id: <1178692661.652023.143000@u30g2000hsc.googlegroups.com>
On May 9, 1:35 am, "Larry.Mart...@gmail.com" <Larry.Mart...@gmail.com>
wrote:
> I have a situation where I have to read in 4 values from a text file,
> then convert that into a float that I can use for arithmetic.
>
> For example, the file contains "85,170,174,214" - I read this in, and
> split it into an array, @d
>
> In C, I would do something akin to this:
>
> union convert_float32 {
> float f; // float view
> unsigned int i; // uint32 view
>} c;
> unsigned char i[4];
> char *q;
>
> for (int j=0; j<4; j++) i[j] = (unsigned char)strtoul(d[j], &q, 10);
> c.i = ((unsigned int)i[0] << 24) | ((unsigned int)i[1] << 16) |
> ((unsigned int)i[2] << 8) | (unsigned int)i[3];
>
> and c.f would have the value I want (in this example
> 23458486419456.000000)
Actually it would make more sense to get rid of the intermediate step.
union convert_float32 {
float f; // float view
unsigned char i[4]; // 4 byte view
} c;
> Is there some way I can achieve the result with perl?
You are looking for the pack() and unpack() functions.
------------------------------
Date: Wed, 9 May 2007 08:51:51 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Converting 4 bytes to a float
Message-Id: <f1s287.15s.1@news.isolution.nl>
Larry.Martell@gmail.com schreef:
> I have a situation where I have to read in 4 values from a text file,
> then convert that into a float that I can use for arithmetic.
First convert the values into a buffer of 4 bytes. Then use unpack().
See perldoc -f unpack.
$ perl -wle 'print length pack "f", 1.23'
4
$ perl -wle 'print ord for split "", pack "f", 1.23'
164
112
157
63
$ perl -wle 'print unpack "f", chr(164).chr(112).chr(157).chr(63)'
1.23000001907349
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Wed, 9 May 2007 04:42:17 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Wed May 9 2007
Message-Id: <JHrBqH.1sK8@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.
App-Build-0.63
http://search.cpan.org/~mbarbon/App-Build-0.63/
extends Module::Build to build/install/configure entire applications (i.e. web applications), not just modules and programs
----
Archive-Builder-1.10
http://search.cpan.org/~adamk/Archive-Builder-1.10/
File generation and archiving framework
----
Archive-Builder-1.11
http://search.cpan.org/~adamk/Archive-Builder-1.11/
File generation and archiving framework
----
CGI-Ex-2.11
http://search.cpan.org/~rhandom/CGI-Ex-2.11/
CGI utility suite - makes powerful application writing fun and easy
----
CGI-Ex-Template-XS-0.02
http://search.cpan.org/~rhandom/CGI-Ex-Template-XS-0.02/
XS version of key parts of CGI::Ex::Template
----
CPAN-1.9102
http://search.cpan.org/~andk/CPAN-1.9102/
query, download and build perl modules from CPAN sites
----
CPANPLUS-0.79_02
http://search.cpan.org/~kane/CPANPLUS-0.79_02/
API & CLI access to the CPAN mirrors
----
Cache-FastMmap-1.15
http://search.cpan.org/~robm/Cache-FastMmap-1.15/
Uses an mmap'ed file to act as a shared memory interprocess cache
----
Catalyst-Plugin-CRUD-0.18
http://search.cpan.org/~bayside/Catalyst-Plugin-CRUD-0.18/
CRUD (create/read/update/delete) Plugin for Catalyst
----
Class-Accessor-Grouped-0.05000
http://search.cpan.org/~claco/Class-Accessor-Grouped-0.05000/
Lets you build groups of accessors
----
Class-C3-0.17
http://search.cpan.org/~blblack/Class-C3-0.17/
A pragma to use the C3 method resolution order algortihm
----
Class-C3-XS-0.03
http://search.cpan.org/~blblack/Class-C3-XS-0.03/
XS speedups for Class::C3
----
DBIx-Class-Validation-0.01003
http://search.cpan.org/~claco/DBIx-Class-Validation-0.01003/
Validate all data before submitting to your database.
----
DJabberd-0.82
http://search.cpan.org/~bradfitz/DJabberd-0.82/
scalable, extensible Jabber/XMPP server.
----
DJabberd-0.83
http://search.cpan.org/~bradfitz/DJabberd-0.83/
scalable, extensible Jabber/XMPP server.
----
Danga-Socket-Callback-0.01
http://search.cpan.org/~dmaki/Danga-Socket-Callback-0.01/
Use Danga::Socket From Callbacks
----
Data-RefQueue-0.4
http://search.cpan.org/~asksh/Data-RefQueue-0.4/
Queue system based on references and scalars.
----
DateTime-TimeZone-0.6601
http://search.cpan.org/~drolsky/DateTime-TimeZone-0.6601/
Time zone object base class and factory
----
Desktop-Notify-0.01
http://search.cpan.org/~sacavilia/Desktop-Notify-0.01/
Communicate with the Desktop Notifications framework
----
File-MMagic-XS-0.09
http://search.cpan.org/~dmaki/File-MMagic-XS-0.09/
Guess File Type With XS (a la mod_mime_magic)
----
Gungho-0.07
http://search.cpan.org/~dmaki/Gungho-0.07/
Yet Another High Performance Web Crawler Framework
----
JE-0.009
http://search.cpan.org/~sprout/JE-0.009/
Pure-Perl ECMAScript (JavaScript) Engine
----
Language-Lisp-0.20
http://search.cpan.org/~vkon/Language-Lisp-0.20/
Perl extension for connecting to existing common lisp implementation
----
Locale-Maketext-1.11_01
http://search.cpan.org/~petdance/Locale-Maketext-1.11_01/
framework for localization
----
Mail-VRFY-0.57
http://search.cpan.org/~jkister/Mail-VRFY-0.57/
Utility to verify an email address
----
Metadata-ByInode-1.14
http://search.cpan.org/~leocharre/Metadata-ByInode-1.14/
Extend metadata in relation to file's inode using a database.
----
Metadata-ByInode-1.15
http://search.cpan.org/~leocharre/Metadata-ByInode-1.15/
Extend metadata in relation to file's inode using a database.
----
Modbus-Client-1.03
http://search.cpan.org/~dvklein/Modbus-Client-1.03/
----
Net-CascadeCopy-v0.0.10
http://search.cpan.org/~vvu/Net-CascadeCopy-v0.0.10/
efficiently copy files to many servers in multiple locations
----
Net-Rendezvous-Publish-Backend-Avahi-0.03
http://search.cpan.org/~jablko/Net-Rendezvous-Publish-Backend-Avahi-0.03/
Publish zeroconf data with the Avahi library.
----
Net-SMS-TMobile-UK-0.01
http://search.cpan.org/~benc/Net-SMS-TMobile-UK-0.01/
Send SMS Messages via the T-Mobile UK Website.
----
Object-Tiny-1.01
http://search.cpan.org/~adamk/Object-Tiny-1.01/
Class building as simple as it gets
----
POE-Component-CPAN-YACSmoke-0.22
http://search.cpan.org/~bingos/POE-Component-CPAN-YACSmoke-0.22/
bringing the power of POE to CPAN smoke testing.
----
POE-Component-Client-MPD-0.0.1
http://search.cpan.org/~jquelin/POE-Component-Client-MPD-0.0.1/
a full-blown mpd client library
----
POE-Component-IRC-5.30
http://search.cpan.org/~bingos/POE-Component-IRC-5.30/
a fully event-driven IRC client module.
----
Perl-Tidy-20070508
http://search.cpan.org/~shancock/Perl-Tidy-20070508/
Parses and beautifies perl source
----
Pugs-Compiler-Rule-0.23
http://search.cpan.org/~fglock/Pugs-Compiler-Rule-0.23/
Compiler for Perl 6 Rules
----
SQL-Interpolate-0.40
http://search.cpan.org/~markstos/SQL-Interpolate-0.40/
Interpolate Perl variables into SQL statements
----
Snowball-Norwegian-1.2
http://search.cpan.org/~asksh/Snowball-Norwegian-1.2/
----
Snowball-Swedish-1.2
http://search.cpan.org/~asksh/Snowball-Swedish-1.2/
----
Template-Parser-CET-0.01
http://search.cpan.org/~rhandom/Template-Parser-CET-0.01/
CGI::Ex::Template based parser for the TT2 engine
----
Test-HTTP-Server-Simple-0.05
http://search.cpan.org/~jesse/Test-HTTP-Server-Simple-0.05/
Test::More functions for HTTP::Server::Simple
----
Test-Unit-Lite-0.01
http://search.cpan.org/~dexter/Test-Unit-Lite-0.01/
Unit testing without external dependencies
----
Text-Sentence-Alignment-0.12
http://search.cpan.org/~clsung/Text-Sentence-Alignment-0.12/
Two Sentence Alignment
----
Time-Elapsed-0.20
http://search.cpan.org/~burak/Time-Elapsed-0.20/
Displays the elapsed time as a human readable string.
----
Tk-Clock-0.19
http://search.cpan.org/~hmbrand/Tk-Clock-0.19/
Clock widget with analog and digital display
----
Twitter-Shell-0.03
http://search.cpan.org/~dmaki/Twitter-Shell-0.03/
Twitter From Your Shell!
----
WWW-Mechanize-SpamCop-0.07
http://search.cpan.org/~adamowski/WWW-Mechanize-SpamCop-0.07/
SpamCop reporting automation.
----
WWW-Scraper-ISBN-TWSilkbook_Driver-0.02
http://search.cpan.org/~ijliao/WWW-Scraper-ISBN-TWSilkbook_Driver-0.02/
Search driver for TWSilkbook' online catalog.
----
WWW-Search-2.492
http://search.cpan.org/~mthurn/WWW-Search-2.492/
Virtual base class for WWW searches
----
WWW-Search-Jarit-1.002
http://search.cpan.org/~mthurn/WWW-Search-Jarit-1.002/
class for searching www.search.com
----
Web-Scraper-0.01
http://search.cpan.org/~miyagawa/Web-Scraper-0.01/
Web Scraping Toolkit inspired by Scrapi
----
Web-Scraper-0.02
http://search.cpan.org/~miyagawa/Web-Scraper-0.02/
Web Scraping Toolkit inspired by Scrapi
----
XML-RSS-LibXML-0.3001
http://search.cpan.org/~dmaki/XML-RSS-LibXML-0.3001/
XML::RSS with XML::LibXML
----
v6-alpha-0.017
http://search.cpan.org/~fglock/v6-alpha-0.017/
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: 9 May 2007 00:06:47 -0700
From: Brian McCauley <nobull67@gmail.com>
Subject: Re: parsing a variable length record from a mixed format file
Message-Id: <1178694407.562776.120080@n59g2000hsh.googlegroups.com>
On May 8, 4:41 pm, chad...@hotmail.com wrote:
> I have a flat file that had a mix of fixed length and variable length
> records. I am parsing through each record and determining if each
> field is accurate compared to the document. Dealing with the fixed
> length records was easy, but I'm having difficulting with the variable
> length records. Here is a snippet of my code and record 3
> (ACCT_CLUS_NM) is a variable length record. Since the record in my
> test file isn't 45 chars, my output file is incorrect. Since I know
> that the largest that record 3 will be is 45 chars, how do I code for
> it??
You cannot code for something you can't even describe. If you have a
record with a mix of fixed length and variable length fields you need
some property of the record that lets you determine how wide the
variable fields are. Since you've not described how you (a human)
could tell how long the ACCT_CLUS_NM field is in a given record
there's no way you can convert that lack of knowledge into working
code.
Sorry - I've just re-read this thread and realised this is a simple
tab delimited record, so you should simply split() it. (I was going to
tell you about unpack() and m//gc as approaches to mixed fixed/
variable with fields but neither of these are now relevant).
>
> #!/usr/bin/perl
>
> $loop=57;
> $ifname=$ARGV[0];
> $ofname=$ARGV[1];
>
> if("${ifname}" eq "" | "${ofname}" eq "")
> {
> print "\nUsage: $0 input_file output_file\n";
> exit;}
Please see other people's comments on cleaning up your Perl. In
particular decalre all variables as lexically scoped in the smallest
applicable scope unless there is a reason not to (this is not specific
to Perl). You can then tell perl to insist on explicit declaration. It
really will save you a lot of pain in future. When learning to climb
all those ropes do get in the way but after the first couple of slips
the effort pays off.
> if(!-f "$ifname" | !-r "$ifname")
> {
> print "$ifname doesn't exist or you do not have permission to read
> it.\n";
> exit 1;}
Remove that block of code - the error handling on open() already does
a better job of telling the user what's actually wrong.
> if(-f "$ofname")
> {
> print "$ofname already exists.\n";
> exit 1;
>
> }
> open(FBATCHF, ">> $ofname") or die "Open failed: $!\n";
Why are you trying to append to a file that you've just checked does
not already exist? This won't confuse the computer but it sure does
confuse any human who looks at your code.
> if($cnt==1){$reclength=4;$field="ACCOUNT_TYPE"};
> if($cnt==2){$reclength=1;$field="TAB"};
> if($cnt==56){$reclength=1;$field="TAB"};
> if($cnt==57){$reclength=10;$field="TIER_TYPE"};
If you are doing the same thing 3 times you are probably doing it
wrong. You are doing the same thing 57 times. The word "array" should
be burning so brightly in your mind's eye that smoke should be issuing
from your ears.
------------------------------
Date: Wed, 09 May 2007 18:58:14 +1000
From: alt.testing@{g}mail.com
Subject: suggestions on intelligent processing of data sets in a file
Message-Id: <cp1343106b28oql8kg6fgldvjpctv3vmv2@4ax.com>
Hi all,
I am writing a script to parse files, and insert data into mysql.
The task is simple enough with files containing "standard" fields.
However; there are many files, and this is not the case.
Some of the files even vary in the number of fields therein.
Example: (fields are email, name, postcode, phone)
email@email.com, Firstname Lastname
email@email.com, Firstname Lastname, 2004, 0412 321 512
email@email.com, Firstname Lastname, 0412 321 512
Now; other than the obvious and easy solution of breaking up the files
into chunks that are "known" and consistent in themselves, in terms of
data fields, I want to build a mechanism that can:
1. Autodetect the number of fields and "line-by-line" respectively
build the data structure as it goes.
2. Verify (or guess the "type" of field using regex)
I don't mind using modules, but would prefer to use ones shipped as
standard. Else, build my own, as I really want to start a bit of "OO",
and this could be a good start.
I have a felling, that creating a class, and building some methods
that can create objects (each respective to a different set) that
reference/manipulate the actual data structures (or something similar)
might be a good approach. This way operations can actually be built on
the fly? Mind you, I've not yet created a module, so this is my first
time. Best approach, or something else, perhaps?
Could anyone suggest some things, that I might try?
tia
Full Context (some rough ideas as a starting point)
===============================================================================
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
my $email_index;
my $name_index;
my $location_index;
my $mobile_index;
my $input_file = $ARGV[0];
my @working_data_array;
my $email;
my $mobile;
my $name;
my $location;
my $counter;
my $email_regex = qr/^
*[a-zA-Z0-9_.-]*@[a-zA-Z0-9_.-]*\.[a-zA-Z0-9_.-]*/;
my $mobile_regex = qr/^ *[04][0-9 ]{8,12}/;
my $name_regex = qr/^ *[a-z -]*/;
my $location_regex = qr/^ *[a-zA-Z0-9 ]*/;
&set_indexes;
open ( IN_FILE, "< $input_file" ) or die "$!";
while ( <IN_FILE> ) {
next unless ( /@/ );
chomp;
@working_data_array = split( /,/ );
$email = $working_data_array[$email_index];
$name = $working_data_array[$name_index];
$location = $working_data_array[$location_index];
$mobile = $working_data_array[$mobile_index];
print "$email";
print "$name";
print "$location";
print "$mobile\n";
}
close IN_FILE;
exit;
sub set_indexes() {
for $counter ( 0 .. $#ARGV ){
$email_index = $counter-1 if ( $ARGV[$counter] =~ /email/ );
$name_index = $counter-1 if ( $ARGV[$counter] =~ /name/ );
$location_index = $counter-1 if ( $ARGV[$counter] =~ /location/ );
$mobile_index = $counter-1 if ( $ARGV[$counter] =~ /mobile/ );
}
}
------------------------------
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 419
**************************************