[29178] in Perl-Users-Digest
Perl-Users Digest, Issue: 422 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 10 03:09:45 2007
Date: Thu, 10 May 2007 00:09:07 -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 Thu, 10 May 2007 Volume: 11 Number: 422
Today's topics:
Re: Action before clicking a link <lgt@invalid.com>
Re: Action before clicking a link <tadmc@augustmail.com>
Re: Action before clicking a link <joe@inwap.com>
Re: Can't spawn "cmd.exe" error while using system <spamtrap@dot-app.org>
Re: I'd like to create an array of unique values <wahab-mail@gmx.de>
Re: I'd like to create an array of unique values <wahab-mail@gmx.de>
Including executable files in a subdirectory <timdooling@qconline.com>
Re: Including executable files in a subdirectory <joe@inwap.com>
Re: Link Matching <tadmc@augustmail.com>
new CPAN modules on Thu May 10 2007 (Randal Schwartz)
Re: parsing a variable length record from a mixed forma <josef.moellers@fujitsu-siemens.com>
Re: parsing a variable length record from a mixed forma <josef.moellers@fujitsu-siemens.com>
perl module developer wanted for 'libmsgque' <aotto1968@onlinehome.de>
Re: Please give me a good "rule-of-thumb" for back-slas <tadmc@augustmail.com>
Re: Please give me a good "rule-of-thumb" for back-slas <stoupa@practisoft.cz>
Re: suggestions on intelligent processing of data sets <tadmc@augustmail.com>
Re: temp file creation in perl 5.0 <tadmc@augustmail.com>
variable question <wes.faul@gmail.com>
Re: variable question <jurgenex@hotmail.com>
Re: variable question usenet@DavidFilmer.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 10 May 2007 01:11:10 +0300
From: lg <lgt@invalid.com>
Subject: Re: Action before clicking a link
Message-Id: <smh4439g16k3od9ha2o69mbjlne5s261af@4ax.com>
Brian Wakem <no@email.com> wrote:
>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
Thank you. I got it working.
------------------------------
Date: Wed, 9 May 2007 05:54:06 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Action before clicking a link
Message-Id: <slrnf43a2e.hhc.tadmc@tadmc30.august.net>
lg <lgt@invalid.com> wrote:
> How do I do the redirecting?
Your Questions is Asked Frequently:
perldoc -q redirect
How do I redirect to another page?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 09 May 2007 22:05:42 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Action before clicking a link
Message-Id: <MrydnXwdQ9G6Nd_bnZ2dnUVZ_rTinZ2d@comcast.com>
lg wrote:
> 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?
Have the link invoke a CGI that does a re-direct.
That info will show up in your access_log.
http://www.inwap.com/mybin/list-files.pl?goto.cgi
-Joe
------------------------------
Date: Wed, 09 May 2007 16:12:14 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Can't spawn "cmd.exe" error while using system
Message-Id: <m2d519rc2p.fsf@local.wv-www.com>
k.sanjith@gmail.com writes:
> I am getting "Can't spawn "cmd.exe"" Error while trying to run a sytem
> call for starting my weblogic server.
Perhaps a silly question, but... Is your weblogic server running Windows?
If not, there's no way you're going to get the Windows command shell to
ever work. You'll have to translate your Windows shell commands to the
corresponding *nix shell commands instead.
This is one reason why built-ins are preferred over shelling out for moving
files around, creating directories, etc. - the built-ins work wherever Perl
does, while shell commands aren't very portable.
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Wed, 09 May 2007 18:26:52 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: I'd like to create an array of unique values
Message-Id: <f1tc9p$7b4$1@mlucom4.urz.uni-halle.de>
Mr P wrote:
> Starting with
> $_ =
> "cat
> man
> ...
> [cat man dog mouse]
>
> My approach is:
> ...
> My PREFERENCE is to not have to involve both a hash and an array, and
> also to not have to include a non-native lib module.
>
> Is there a syntax I can use to just work with the hash and populate
> the keys-only directly from the split? I don't really care what the
> values are. I don't even care if they are undef.
The closest I could come up with is
a simple match against a code assertion:
...
my %h;
$_ ='
cat
man
dog
mouse
man
man
';
() = /(\w+)(?{$h{$1}=undef})/g;
print " [@{[keys %h]}]";
...
but I couldn't get your correct order ;-)
Regards
M.
------------------------------
Date: Wed, 09 May 2007 18:28:50 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: I'd like to create an array of unique values
Message-Id: <f1tcla$7dh$1@mlucom4.urz.uni-halle.de>
Mirco Wahab wrote:
> print " [@{[keys %h]}]";
Stupid, because the hash slice *does*
already provide list context, so a simple:
@h{/(\w+)/g} = undef;
print " [@{[keys %h]}]";
would be all what's necessary.
(did too much php lately ;-)
Regards
M.
------------------------------
Date: Wed, 09 May 2007 22:01:03 -0500
From: "timdooling" <timdooling@qconline.com>
Subject: Including executable files in a subdirectory
Message-Id: <1178766063_831@sp12lax.superfeed.net>
I am trying to include a file in a subdirectory that contains code I want to execute from like a library.
I simply put the following code in my perl program:
require 'subdirectory/program.pl';
It doesn't work and I simply get an "internal server error" message.
What is wrong with doing this?
Tim
------------------------------
Date: Wed, 09 May 2007 21:52:32 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Including executable files in a subdirectory
Message-Id: <SYudnRa5LcOPON_bnZ2dnUVZ_jGdnZ2d@comcast.com>
timdooling wrote:
> I am trying to include a file in a subdirectory that contains code I want to execute from like a library.
>
> I simply put the following code in my perl program:
>
> require 'subdirectory/program.pl';
>
> It doesn't work and I simply get an "internal server error" message.
"Internal server error" means that your program output an unexpected
error message or died without outputting proper CGI headers.
Common causes:
The permissions on program.pl are such that the web server
(which runs as a userid other than your own) cannot read it.
Your program is not running inside the directory you think it is.
Have you tried this:
use CGI::Carp qw(fatals_to_browser);
http://www.perl.org/CGI_MetaFAQ.html
------------------------------
Date: Wed, 9 May 2007 18:20:52 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Link Matching
Message-Id: <slrnf44lqk.r1o.tadmc@tadmc30.august.net>
Taras_96 <taras.di@gmail.com> wrote:
[ Please provide a proper attribution when you quote someone,
like everybody else does...
]
>> You can do that if you want to match one particular string.
>>
>> If you want code that will work on different data, we would
>> need to understand what could be different...
>>
>
> Should have explained my question a bit more
I was hoping you'd say that after seeing my post. :-)
> (I thought with the
> previous discussion about HTML it would be clear).
Errr, so when you said:
forget that it's HTML we're parsing
we weren't really supposed to do that?
> Part 1)
>
> How do I construct a regex that matches any text that is in between
><open> and </close> strings, but the *shortest* (non-greedy matching)
> such string?
One of the ways I did it in the code that I gave you meets
that spec. Did you read and understand that code?
Or, since your Question is Asked Frequently:
perldoc -q greedy
What does it mean that regexes are greedy? How can I get around it?
> So in the above example,
There is no "above example".
If you want to discuss a piece of code, then please quote the piece
of code, like everybody else does...
> Part 2)
>
> Once we have the non-greedy matching, how can I construct a regex that
> would return any text in between <open> and </close>, but the text in
> between the tags must itself match a regex?
That is where managing the greediness will become difficult.
I'd stick with finding the delimiters first, and then applying
your regex to the list it returns:
my $inner_pat = 'o'; # lower case oh
my @x = grep /$inner_pat/, m#<open>(.*?)</close>#isg;
> eg: a search for o(.)* would return 'one' using my previous example,
> but not 'two'.
^^^^^^^^^^^^^
Why not?
This program makes output when it matches that pattern:
-------------------
#!/usr/bin/perl
use warnings;
use strict;
$_ = 'two';
print "matched\n" if /o(.)*/;
-------------------
Your regex will match the same strings as /o/
and it will fail to match the same strings.
Did you perhaps mean /o(.)+/ instead?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 10 May 2007 04:42:09 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu May 10 2007
Message-Id: <JHt6E9.1L0D@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-FizzBuzz-0.01
http://search.cpan.org/~yappo/Acme-FizzBuzz-0.01/
The FizzBuzz program can be written shortest
----
Brick-0.024_01
http://search.cpan.org/~bdfoy/Brick-0.024_01/
Complex business rule data validation
----
Bundle-HollyKing-1.01
http://search.cpan.org/~hollyking/Bundle-HollyKing-1.01/
Things HollyKing wants in a fresh Perl install.
----
CFPlus-0.98
http://search.cpan.org/~mlehmann/CFPlus-0.98/
undocumented utility garbage for our crossfire client
----
Class-Accessor-Ref-0.04
http://search.cpan.org/~gaal/Class-Accessor-Ref-0.04/
Access members by reference
----
Class-Component-0.01
http://search.cpan.org/~yappo/Class-Component-0.01/
pluggable component framework
----
Class-Component-0.02
http://search.cpan.org/~yappo/Class-Component-0.02/
pluggable component framework
----
Class-Rebless-0.07
http://search.cpan.org/~gaal/Class-Rebless-0.07/
Rebase deep data structures
----
Crossfire-0.98
http://search.cpan.org/~mlehmann/Crossfire-0.98/
Crossfire maphandling
----
DBD-Unify-0.62
http://search.cpan.org/~hmbrand/DBD-Unify-0.62/
DBI driver for Unify database systems
----
Danga-Socket-Callback-0.011
http://search.cpan.org/~dmaki/Danga-Socket-Callback-0.011/
Use Danga::Socket From Callbacks
----
Devel-Fail-MakeTest-1.007
http://search.cpan.org/~mthurn/Devel-Fail-MakeTest-1.007/
a distro that always fails the `make test` stage
----
Egg-Plugin-Cache-2.01
http://search.cpan.org/~lushe/Egg-Plugin-Cache-2.01/
cache for Egg plugin.
----
Egg-Release-2.02
http://search.cpan.org/~lushe/Egg-Release-2.02/
Version of Egg WEB Application Framework.
----
Exception-System-0.04
http://search.cpan.org/~dexter/Exception-System-0.04/
The exception class for system or library calls
----
File-HomeDir-0.65
http://search.cpan.org/~adamk/File-HomeDir-0.65/
Find your home and other directories, on any platform
----
GD-Icons-0.01
http://search.cpan.org/~pcanaran/GD-Icons-0.01/
Utility for generating series of icons of varying color and shapes
----
Gearman-Server-1.09
http://search.cpan.org/~bradfitz/Gearman-Server-1.09/
function call "router" and load balancer
----
HTML-GMap-0.01
http://search.cpan.org/~pcanaran/HTML-GMap-0.01/
Generic Perl infrastructure to build Google Maps displays
----
IO-Async-0.07
http://search.cpan.org/~pevans/IO-Async-0.07/
a collection of modules that implement asynchronous filehandle IO
----
IPC-Messaging-0.01_01
http://search.cpan.org/~gruber/IPC-Messaging-0.01_01/
process handling and message passing, Erlang style
----
IPC-Messaging-0.01_02
http://search.cpan.org/~gruber/IPC-Messaging-0.01_02/
process handling and message passing, Erlang style
----
Interpolation-0.71
http://search.cpan.org/~jenda/Interpolation-0.71/
Arbitrary string interpolation semantics (using tie())
----
JE-0.010
http://search.cpan.org/~sprout/JE-0.010/
Pure-Perl ECMAScript (JavaScript) Engine
----
JSON-Any-1.06
http://search.cpan.org/~perigrin/JSON-Any-1.06/
Wrapper Class for the various JSON classes.
----
JSON-XS-1.2
http://search.cpan.org/~mlehmann/JSON-XS-1.2/
JSON serialising/deserialising, done correctly and fast
----
JSON-XS-1.21
http://search.cpan.org/~mlehmann/JSON-XS-1.21/
JSON serialising/deserialising, done correctly and fast
----
KinoSearch-0.20_03
http://search.cpan.org/~creamyg/KinoSearch-0.20_03/
Search engine library.
----
Mail-Outlook-0.13
http://search.cpan.org/~barbie/Mail-Outlook-0.13/
mail module to interface with Microsoft (R) Outlook (R).
----
Module-CoreList-2.10
http://search.cpan.org/~rgarcia/Module-CoreList-2.10/
what modules shipped with versions of perl
----
Module-Install-0.67
http://search.cpan.org/~adamk/Module-Install-0.67/
Standalone, extensible Perl module installer
----
MozRepl-0.01
http://search.cpan.org/~zigorou/MozRepl-0.01/
Perl interface of MozRepl
----
MozRepl-0.02
http://search.cpan.org/~zigorou/MozRepl-0.02/
Perl interface of MozRepl
----
Number-Object-0.01
http://search.cpan.org/~yappo/Number-Object-0.01/
pluggable number object
----
Object-Tiny-1.02
http://search.cpan.org/~adamk/Object-Tiny-1.02/
Class building as simple as it gets
----
POE-Component-Client-MPD-0.0.2
http://search.cpan.org/~jquelin/POE-Component-Client-MPD-0.0.2/
a full-blown mpd client library
----
POE-Component-Server-SimpleContent-1.07
http://search.cpan.org/~bingos/POE-Component-Server-SimpleContent-1.07/
The easy way to serve web content with POE::Component::Server::SimpleHTTP.
----
POE-Component-Server-SimpleSMTP-1.03
http://search.cpan.org/~bingos/POE-Component-Server-SimpleSMTP-1.03/
A simple to use POE SMTP Server.
----
Params-Util-0.24
http://search.cpan.org/~adamk/Params-Util-0.24/
Simple, compact and correct param-checking functions
----
Taint-Util-0.05
http://search.cpan.org/~avar/Taint-Util-0.05/
Test for and flip the taint flag without regex matches or eval
----
Tcl-Tk-0.94
http://search.cpan.org/~vkon/Tcl-Tk-0.94/
Extension module for Perl giving access to Tk via the Tcl extension
----
Template-Filters-LazyLoader-0.05
http://search.cpan.org/~tomyhero/Template-Filters-LazyLoader-0.05/
Loading template filter modules by lazy way.
----
Text-CSV-Track-0.6
http://search.cpan.org/~jkutej/Text-CSV-Track-0.6/
module to work with .csv file that stores some value(s) per identificator
----
Thread-Pool-Simple-0.21
http://search.cpan.org/~jwu/Thread-Pool-Simple-0.21/
A simple thread-pool implementation
----
Thread-Stack-1.00
http://search.cpan.org/~kylesch/Thread-Stack-1.00/
thread-safe stacks adapted from Thread::Queue
----
Tk-Wizard-2.006
http://search.cpan.org/~lgoddard/Tk-Wizard-2.006/
GUI for step-by-step interactive logical process
----
Unix-Shebang-0.1
http://search.cpan.org/~asksh/Unix-Shebang-0.1/
Utility module for Unix shebang lines.
----
Unix-Shebang-0.3
http://search.cpan.org/~asksh/Unix-Shebang-0.3/
Utility module for Unix shebang lines.
----
Unix-Shebang-0.314
http://search.cpan.org/~asksh/Unix-Shebang-0.314/
Utility module for Unix shebang lines.
----
WWW-Mechanize-DecodedContent-0.01
http://search.cpan.org/~miyagawa/WWW-Mechanize-DecodedContent-0.01/
decode Mech content using its HTTP response encoding
----
WWW-Search-2.493
http://search.cpan.org/~mthurn/WWW-Search-2.493/
Virtual base class for WWW searches
----
WWW-Slides-0.0.8
http://search.cpan.org/~polettix/WWW-Slides-0.0.8/
serve presentations on the Web
----
Web-Scraper-0.03
http://search.cpan.org/~miyagawa/Web-Scraper-0.03/
Web Scraping Toolkit inspired by Scrapi
----
Web-Scraper-0.04
http://search.cpan.org/~miyagawa/Web-Scraper-0.04/
Web Scraping Toolkit inspired by Scrapi
----
Web-Scraper-0.05
http://search.cpan.org/~miyagawa/Web-Scraper-0.05/
Web Scraping Toolkit inspired by Scrapi
----
Web-Scraper-Config-0.01
http://search.cpan.org/~dmaki/Web-Scraper-Config-0.01/
Run Web::Scraper From Config Files
----
WebService-BuzzurlAPI-0.01
http://search.cpan.org/~holly/WebService-BuzzurlAPI-0.01/
Buzzurl WebService API
----
WebService-BuzzurlAPI-0.02
http://search.cpan.org/~holly/WebService-BuzzurlAPI-0.02/
Buzzurl WebService API
----
YAML-Tiny-1.05
http://search.cpan.org/~adamk/YAML-Tiny-1.05/
Read/Write YAML files with as little code as possible
----
mogilefs-server-2.16
http://search.cpan.org/~bradfitz/mogilefs-server-2.16/
----
v6-0.018
http://search.cpan.org/~fglock/v6-0.018/
An experimental Perl 6 implementation
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: Thu, 10 May 2007 08:26:49 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: parsing a variable length record from a mixed format file
Message-Id: <f1udvd$b2t$2@nntp.fujitsu-siemens.com>
chadmay@hotmail.com wrote:
[ ... ]
> Problem is solved now, Thanks John!
What was the reason to quote the entire thread just to add a single line?=
Just curious,
Josef
--=20
These are my personal views and not those of Fujitsu Siemens Computers!
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html
------------------------------
Date: Thu, 10 May 2007 08:27:28 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: parsing a variable length record from a mixed format file
Message-Id: <f1ue0k$b2t$3@nntp.fujitsu-siemens.com>
chadmay@hotmail.com wrote:
[ ... ]
Yes ... and?
Just curious,
Josef
--=20
These are my personal views and not those of Fujitsu Siemens Computers!
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html
------------------------------
Date: Thu, 10 May 2007 08:49:49 +0200
From: Andreas Otto <aotto1968@onlinehome.de>
Subject: perl module developer wanted for 'libmsgque'
Message-Id: <f1ufad$5i5$2@online.de>
Hi,
I'm a the maintainer for the new project 'libmsgque'
hosted at SF (see below for details) and need a volunteer
to develop the language bindings for perl.
Is somebody available to take over this job ?
An example language binding for tcl is allready available.
This is the initial announcement:
ANNOUNCE: libmsgque2.3-beta2
The libmsgque project is an infrastructure for linking applications together
to act like a single application. This is done using Unix or inet domain
sockets. The framework handles all aspects of setting up and maintaining
the link in addition to starting and stopping the different applications,
starting and stopping the communication interface, sending and receiving
packages, reading and writing data from or into packages, setting up and
maintaining the event handling for asynchronous transfers, and propagating
warnings or errors.
WHERE TO GET
============
As usual, it is available from:
http://libmsgque.sourceforge.net/
http://sourceforge.net/projects/libmsgque/
WHAT'S NEW
==========
This is the initial announcement
WHAT IS IT
==========
First of all it is a framework to link commands together to avoid
the traditional shell pipline using a similar approach as MS PowerShell.
To get more information's please use the following links:
1. an overview about the basic concept:
http://libmsgque.sourceforge.net/overview.htm
2. the man page of the tclmsgque extension:
http://libmsgque.sourceforge.net/tclmsgque.htm
Regards,
Andreas Otto (aotto1968)
------------------------------
Date: Wed, 9 May 2007 18:27:36 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Please give me a good "rule-of-thumb" for back-slashing in character classes
Message-Id: <slrnf44m78.r1o.tadmc@tadmc30.august.net>
Paul Lalli <mritty@gmail.com> wrote:
> Second, the characters ], -, and ^ are special in a character class.
> (Technically, ^ is only special if its the first character, however).
And - is only special if it is not the first or the last character.
And ] is only special if it is not first. ( /[][]/ looks good in code ;-)
And \ is always special (unless doubled).
> Those three therefore need to be backslashed as well.
That's probably easier to remember. :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 10 May 2007 04:12:05 +0200
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: Please give me a good "rule-of-thumb" for back-slashing in character classes
Message-Id: <f1tvi4$255c$1@ns.felk.cvut.cz>
"Paul Lalli" <mritty@gmail.com> píse v diskusním príspevku
news:1178723651.938407.63140@o5g2000hsb.googlegroups.com...
> On May 9, 11:06 am, Mr P <MisterP...@gmail.com> wrote:
> Second, the characters ], -, and ^ are special in a character class.
> (Technically, ^ is only special if its the first character, however).
Or ^ may be NOT in /abc[^abc]def/
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
------------------------------
Date: Wed, 9 May 2007 06:05:40 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: suggestions on intelligent processing of data sets in a file
Message-Id: <slrnf43ao4.hhc.tadmc@tadmc30.august.net>
alt.testing@{g}mail.com <alt.testing@{g}mail.com> wrote:
> 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
> 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)
------------------------
#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
while ( <DATA> ) {
chomp;
my %record;
foreach my $part ( split /,\s*/ ) {
if ( $part =~ /^\d+$/ ) # all digits
{ $record{postcode} = $part }
elsif ( $part =~ /^[\d\s]+$/ ) # digits with spaces
{ $record{phone} = $part }
elsif ( $part =~ /@/ ) # contains at-sign
{ $record{email} = $part }
else
{ $record{name} = $part }
}
print Dumper \%record;
}
__DATA__
email@email.com, Firstname Lastname
email@email.com, Firstname Lastname, 2004, 0412 321 512
email@email.com, Firstname Lastname, 0412 321 512
------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 9 May 2007 21:03:59 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: temp file creation in perl 5.0
Message-Id: <slrnf44vcf.r1o.tadmc@tadmc30.august.net>
KP <desiaashik@gmail.com> wrote:
> I have this perl code that is written in 5.8 but want to run in 5.0.
Why do you want to run it on a 1994 release of perl?
Life is too short for such things...
> The issue is that 5.0 don't have File::Temp module so, it fails. Here
> is the code.. Please let me know what to comment and what to change so
> that the script can be run smoothly.
> use File::Temp qw/ tempdir /;
Delete that line, and define a subroutine named "tempdir"
that makes a safe temporary directory.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 9 May 2007 16:04:35 -0700
From: wesf <wes.faul@gmail.com>
Subject: variable question
Message-Id: <1178751875.861563.288930@y80g2000hsf.googlegroups.com>
I'm new to Perl and have taken over a website built on the Interchange
framework. I have a problem that i tracked down to two variables $URL
$ and $EXPAND$. I know variables start with a $, but what's the
significance of the $ after the variable name?
Thanks,
Wes
------------------------------
Date: Wed, 09 May 2007 23:45:52 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: variable question
Message-Id: <Q2t0i.5040$rk5.3316@trndny06>
wesf wrote:
> I'm new to Perl and have taken over a website built on the Interchange
> framework. I have a problem that i tracked down to two variables $URL
> $ and $EXPAND$. I know variables start with a $, but what's the
> significance of the $ after the variable name?
As far as Perl is concerned: there is none. That trailing dollar sign does
not belong to the variable name.
Maybe it is some marker for the Interchange framework?
jue
------------------------------
Date: 9 May 2007 17:20:05 -0700
From: usenet@DavidFilmer.com
Subject: Re: variable question
Message-Id: <1178756405.169843.70000@h2g2000hsg.googlegroups.com>
On May 9, 4:04 pm, wesf <wes.f...@gmail.com> wrote:
> I have a problem that i tracked down to two variables $URL$
> and $EXPAND$
I suspect those are actually template placeholders; Interchange
(whatever that is) would substitute actual values as the page was
served.
--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 422
**************************************