[23048] in Perl-Users-Digest
Perl-Users Digest, Issue: 5269 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 24 21:05:50 2003
Date: Thu, 24 Jul 2003 18:05:09 -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, 24 Jul 2003 Volume: 10 Number: 5269
Today's topics:
Re: Called as method or subroutine? (Jay Tilton)
Re: Called as method or subroutine? <uri@stemsystems.com>
Re: Can one control swap in Perl? (Sam Holden)
CGI module: getting cgi params from text file redirecte (fatted)
Re: Chomp temporarily nullifies my scalar variable. <jandellis@hotmail.com>
cpan problems with 02packages.details.txt.gz and 03modl <dpchrist@holgerdanske.com>
extract list from webpage (plb)
Re: extract list from webpage <asu1@c-o-r-n-e-l-l.edu>
Looking for Perl school <senior_citizen@alaska.com>
Lookup Country by IP Address 143.182.124.4 [Shameer Balasingam]
Re: OLE Excel Perl Coding Problems (John Porter)
Platform independant serial port access; does it exist? <spamblock@junkmail.com>
pod2usage verbose problem (Joshua Eliason)
Re: Q: Summarize/Condense already tight text string? <jaspax@u.washington.edu>
Re: Read the contents of a text file into an HTML page (Peter Stokes)
Re: reference symbol not found with UDUNITS (John Porter)
Re: reference symbol not found with UDUNITS (Tad McClellan)
Re: references help (Tad McClellan)
Re: Regex question <abigail@abigail.nl>
Re: Regex question (Tad McClellan)
Stumped by formatting - newbie plea (Peter Stokes)
Re: Stumped by formatting - newbie plea <noreply@gunnar.cc>
Re: Style question regarding subroutines and lexical va <jandellis@hotmail.com>
Re: Style question regarding subroutines and lexical va <jandellis@hotmail.com>
twig requires 5.004, I am using Windows v5.6.1, which t (Sherman Willden)
Re: twig requires 5.004, I am using Windows v5.6.1, whi <kalinabears@iinet.net.au>
XML or home-grown format? <jaspax@u.washington.edu>
Re: XML or home-grown format? <scriptyrich@yahoo.co.uk>
Re: XML or home-grown format? (MegaZone)
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 24 Jul 2003 22:11:14 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Called as method or subroutine?
Message-Id: <3f205954.13267082@news.erols.com>
ed <coo_t2-NO-LIKE-SPAM@yahoo.com> wrote:
: Hi is there a way to make a sub/method compatible with
: the two following calling methods?
:
: 1. MyClass::mySub();
: 2. MyClass->mySub();
The File::Spec::Functions module may be worth study. It wraps the
methods from the File::Spec class into plain subroutines that can be
exported to other packages. It's a pretty simple thing to do, and it
doesn't require the methods to have any magical awareness of whether
they're being called as subroutines.
------------------------------
Date: Thu, 24 Jul 2003 22:18:26 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Called as method or subroutine?
Message-Id: <x7vftrvaa5.fsf@mail.sysarch.com>
>>>>> "JT" == Jay Tilton <tiltonj@erols.com> writes:
JT> ed <coo_t2-NO-LIKE-SPAM@yahoo.com> wrote:
JT> : Hi is there a way to make a sub/method compatible with
JT> : the two following calling methods?
JT> :
JT> : 1. MyClass::mySub();
JT> : 2. MyClass->mySub();
JT> The File::Spec::Functions module may be worth study. It wraps the
JT> methods from the File::Spec class into plain subroutines that can be
JT> exported to other packages. It's a pretty simple thing to do, and it
JT> doesn't require the methods to have any magical awareness of whether
JT> they're being called as subroutines.
and i proposed a module for a TPF grant that would allow a module author
do have that feature with little effort. it would allow an OO module to
have a default object and it would export subs into the user space which
would do call the same methods on that default object. this is similar
to what cgi,pm does but it would be generic and support any OO
module. it would also allow prefixes or renaming of the subs by the user
code.
the grant was accepted but i have since been put on the TPF committee so
i can't take the funding. if someone wants to take this project on, i
will help out with the design (as i have done most of it already) and
they can earn some grant money. the grant was approved but not formally
issued. you have to have serious understanding of OO perl, closures,
exporting to do this. it is not for newbies or the faint of heart. :)
email me if you are interested.
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: 24 Jul 2003 22:15:16 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Can one control swap in Perl?
Message-Id: <slrnbi0mjk.p7h.sholden@flexal.cs.usyd.edu.au>
On Thu, 24 Jul 2003 17:23:40 GMT,
William Goedicke <goedicke@goedsole.com> wrote:
> Dear Irving -
>
>>>>>> "Irving" == Irving Kimura <irving_kimura@lycos.com> writes:
>
> Irving> For security reasons, I want the value of this variable to
> Irving> remain in memory throughout the daemon's run, and never be
> Irving> swapped out to disk.
>
> This sounds like the old "security through obscurity" fallacy. Hiding
> things isn't good security practice.
It really isn't.
It's essentially what programs like ssh-agent do, they trade a little
security for a lot of conveniance - and the trade off often results in
additional security because otherwise people can't accept the inconveniance.
> You'll be better served by devising a way of using encryption such
> that finding your "value" doesn't help a cracker access your private
> information. Look for procedural combinations of one-way hash
> algorithms like MD5 and public-key encryption like RSA2.
The program has to access the private data. To do so it needs the key.
There's a trade off of conveniance and security. For ultimate security I
should enter the key (or passphrase or password or whatever) every time I
need the data, but that is tedious and in fact may reduce security by
acting as an incentive to select a bad but easy to enter password.
Storing the key in memory means I only have to enter it once. Memory
is protected by the unix security model, so only me and those with
superuser priviledges should be able to access it. Since those with
superuser priviledges can just as easily snoop all my input they can
capture the password every time I enter it anyway.
If the key gets swapped to disk though, then security has been reduced,
now the key can be accessed by people who have access to the disk. This might
be people other than superusers (for example, a machine crash might result in
another person performing some disk recovery actions - or a cracker might get
access some time *after* my key is no longer in memory).
Plus when my progam exits it will most likely overwrite the key with garbage
data, that will not necessarily overwrite the key which has been swapped to disk
in the past.
--
Sam Holden
------------------------------
Date: 24 Jul 2003 15:18:59 -0700
From: fatted@yahoo.com (fatted)
Subject: CGI module: getting cgi params from text file redirected to script run on the commandline
Message-Id: <4eb7646d.0307240634.72e44c2@posting.google.com>
I have a simple program:
#!/usr/bin/perl
use warnings;
use strict;
use CGI;
my $q = new CGI;
my @array = $q->param;
map(print($_."\n"),@array);
If I call this from the command line as:
./simple.pl < a.req
On a linux machine running 5.6.0, this prints out the parameter keys
(taken from file a.req), preceded by "(offline mode: enter name=value
pairs on standard input)".
However on a linux machine running 5.8.0, the same program and
command line, prints nothing. (No parameters found). (And doesn't
print the line "ofline mode...")
What am I missing??
------------------------------
Date: Thu, 24 Jul 2003 23:06:52 GMT
From: Joseph Ellis <jandellis@hotmail.com>
Subject: Re: Chomp temporarily nullifies my scalar variable.
Message-Id: <fip0ivsvl9mcdhf3u5a1fsi1a1iu88l60k@4ax.com>
On 24 Jul 2003 06:35:44 GMT, "Tassilo v. Parseval"
<tassilo.parseval@rwth-aachen.de> wrote:
>Also sprach Joseph Ellis:
>
>> On Thu, 24 Jul 2003 04:22:11 GMT, Steve Grazzini <grazz@pobox.com>
>> wrote:
>
>>>What puzzled me was why the "\r" was there in the first place,
>>
>> It puzzled me as well.
>>
>>>but I guess CGI.pm has done "binmode STDIN".
>>
>> Um, ok. I don't know what that means, but remarking out CGI.pm did
>> the trick. Both lines print as expected. Can you elaborate on the
>> "binmode STDIN" bit, or tell me where I can learn more about it?
>
>See 'perldoc -f binmode'. It has something to do with how perl treats
>characters. It used to be related to newlines mainly, but nowadays in
>times of Unicode, this is no longer true (recent RedHats have gain some
>fame in that they might require binmode() in their default configuration
>as well).
>
>On Windows, the newline is represented by the two bytes \015\012, on
>most other platforms it is only one byte (unices usually \012,
>Macintoshs \015). So if you do not binmode a filehandle and read from it
>linewise on Windows, perl translates \015\012 to \012. Since this is the
>value of $/ (the $INPUT_RECORD_SEPARATOR that for instance chomp() uses
>as default-character to strip), chomp() later does the right thing.
>
>However, if you binmode() your filehandle, this translation does not
>happen, so chomp() still removes the \012 but the carriage-return
>character still exists so it turnes instances of \015\012 into \015.
>
>If you have ever used FTP, think of binmode() as the equivalent to
>binary transfer-mode, whereas the default (no binmode()) is text-mode.
>
>Tassilo
Thank you very much. That was a great explanation. I'll check out
perldoc though, too, as you've suggested.
Again, thanks.
Joseph
------------------------------
Date: Thu, 24 Jul 2003 23:11:12 GMT
From: "David Christensen" <dpchrist@holgerdanske.com>
Subject: cpan problems with 02packages.details.txt.gz and 03modlist.data.gz
Message-Id: <kIZTa.5050$dk4.225352@typhoon.sonic.net>
Hello, world!
I am having trouble with cpan on Cygwin:
dpchrist@w2k30g:~/.cpan/sources$ cpan
cpan shell -- CPAN exploration and modules installation (v1.70_54)
ReadLine support enabled
cpan> install Class::Base
Going to read /home/dpchrist/.cpan/sources/authors/01mailrc.txt.gz
Going to read
/home/dpchrist/.cpan/sources/modules/02packages.details.txt.gz
Warning: Your
/home/dpchrist/.cpan/sources/modules/02packages.details.txt.gz does not
contain a Line-Count header.
Please check the validity of the index file by comparing it to more than
one CPAN mirror. I'll continue but problems seem likely to happen.
Warning: Your
/home/dpchrist/.cpan/sources/modules/02packages.details.txt.gz does not
contain a Last-Updated header.
Please check the validity of the index file by comparing it to more than
one CPAN mirror. I'll continue but problems seem likely to happen.
Going to read /home/dpchrist/.cpan/sources/modules/03modlist.data.gz
Can't locate object method "data" via package "CPAN::Modulelist"
(perhaps you forgot to load "CPAN::Modulelist"?) at (eval 24) line 1.
CPAN::Index::rd_modlist('CPAN::Index','/home/dpchrist/.cpan/sources/modu
les/03modlist.data.gz') called at /usr/lib/perl5/5.8.0/CPAN.pm line 3113
CPAN::Index::reload('CPAN::Index') called at
/usr/lib/perl5/5.8.0/CPAN.pm line 674
CPAN::exists('CPAN=HASH(0x1049bbac)','CPAN::Module','Class::Base')
called at /usr/lib/perl5/5.8.0/CPAN.pm line 1841
CPAN::Shell::expandany('CPAN::Shell','Class::Base') called at
/usr/lib/perl5/5.8.0/CPAN.pm line 2077
CPAN::Shell::rematein('CPAN::Shell','install','Class::Base')
called at /usr/lib/perl5/5.8.0/CPAN.pm line 2164
CPAN::Shell::install('CPAN::Shell','Class::Base') called at
/usr/lib/perl5/5.8.0/CPAN.pm line 200
eval {...} called at /usr/lib/perl5/5.8.0/CPAN.pm line 200
CPAN::shell() called at /usr/bin/cpan line 193
cpan>
As best I can tell, cpan thinks the following file is corrupt:
~/.cpan/sources/modules/02packages.details.txt.gz
and then has trouble processing the following file:
~/.cpan/sources/modules/03modlist.data.gz'
I don't know how to "check the validity of the index file by comparing
it to more than one CPAN mirror".
I tried blowing the two files away, restarting cpan, and installing a
module, but cpan simply downloaded the files again and proceeded with
the same errors.
I STFW and came up with a message by a lady who had a same/similar
problem. She said that it was caused by a rogue "~" file or folder in
her directory tree. Removing it fixed the problem. I searched my
system, found "C:\~", and removed it, but no luck.
Any suggestions?
TIA,
David
------------------------------
Date: 24 Jul 2003 16:36:54 -0700
From: plb@linuxmail.org (plb)
Subject: extract list from webpage
Message-Id: <37aad647.0307241536.3554805@posting.google.com>
Hello All,
I'm just starting to learn perl. Here's what I'm trying to do:
I have a webpage setup that displays all 'active' vhosts that run on
my webserver. This page is generated in ASP. I would like to write a
perl script that takes the list of 'active' vhosts and writes them to
a text file. Then I would like to compare this list to the wwwroot
directory on the webserver so I can delete any vhosts that are not in
use. There is about a 300-400 difference between the webpage and
wwwroot directory.
Ideally I would like the script to:
1) compile a list of active vhosts
2) compare this list to the "wwwroot" directory
3) delete any directory that is not on the list of active vhosts
I'm hoping someone can help me out getting started.
Thank you for your help,
plb
------------------------------
Date: 24 Jul 2003 23:55:13 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: extract list from webpage
Message-Id: <Xns93C2CAA4DD380asu1cornelledu@132.236.56.8>
plb@linuxmail.org (plb) wrote in news:37aad647.0307241536.3554805
@posting.google.com:
> Here's what I'm trying to do:
>
> I have a webpage setup that displays all 'active' vhosts that run on
> my webserver. This page is generated in ASP. I would like to write a
> perl script that takes the list of 'active' vhosts and writes them to
> a text file.
Well, without some specific information regarding the format of the
information you are trying to parse, it is hard to make a good
recommendation. Have you looked at HTML::Parser?
Also, look at
"How do I compute the difference of two arrays? How do I compute the
intersection of two arrays?"
in the FAQ section 4.
Sinan.
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Fri, 25 Jul 2003 01:03:00 GMT
From: "Gerald Newton" <senior_citizen@alaska.com>
Subject: Looking for Perl school
Message-Id: <1059094979.834944@prawn>
I am looking for an onsite Perl school of 4 to 5 weeks. This school would
be for computer literate people who have previous programming experience,
but are not professional programmers. The school would have about 4 hours
in class and a daily workshop where students would use their own laptops or
school machines to practice with an instructor on hand. The cost would be
about $3 to $5 thousand not including board and room. Does anyone know of
such a program?
------------------------------
Date: Thu, 24 Jul 2003 22:33:14 GMT
From: 143.182.124.4 [Shameer Balasingam]
Subject: Lookup Country by IP Address
Message-Id: <2aab8f4caebb5fc151c21f60b6bfcae0@TeraNews>
There is a database to lookup all IP address space to country. Pretty cool... I used it for my web application and I believe it can be used by others tool.
http://www.location.com.my/products.asp
==================================
Poster's IP address: 143.182.124.4
Posted via http://nodevice.com
Linux Programmer's Site
------------------------------
Date: 24 Jul 2003 17:03:23 -0700
From: johndporter@yahoo.com (John Porter)
Subject: Re: OLE Excel Perl Coding Problems
Message-Id: <95f344ba.0307241603.1954d31b@posting.google.com>
"Peter Wilson" wrote:
>
> The macro:
>
> ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, _
> SourceData:="'wire-types'!R1C1:R3895C3").CreatePivotTable _
> TableDestination:="", TableName:="PivotTable2"
>
> The Perl:
>
> $Book->PivotCaches->Add(xlDatabase,$datarange})
> ->CreatePivotTable("","Wire Types");
O.k., you see how Add and CreatePivotTable take named arguments?
That means that the arguments have to be named, whether you're doing
OLE in VB or Perl. To do named arguments in Perl, you'd write
something like this:
$Book->PivotCaches->Add({ SourceType=>xlDatabase,
SourceData=>$datarange })->CreatePivotTable({
TableDestination=>"", TableName=>"Wire Types" });
Note how the named arguments (which look very hash-like, don't they?)
are enclosed in curly braces, which create an actual anonymous hash.
Be sure to read everything in the Win32::OLE documentation, though.
Hope this helps...
--
John Douglas Porter
------------------------------
Date: Thu, 24 Jul 2003 15:23:22 -0700
From: "David Oswald" <spamblock@junkmail.com>
Subject: Platform independant serial port access; does it exist?
Message-Id: <vi0n4i8nnphq86@corp.supernews.com>
Is there a module already created somewhere that provides a platform
independant set of tools for accessing the serial port? I realize that
access to the serial port differs from Unix systems, to Windows systems,
etc., as well as from device to device. But has anyone created a set of
tools that rises up above the details that make one platform different from
another, so that I can access the serial port on two different systems
through a common interface?
I apologize if this question has already been asked and answered. I've
searched the module lists on CPAN, and the FAQ's on www.perl.com already,
but this seems to be a question that I could search for all day and not
discover the answer to without a gentle nudge in the right direction.
Thanks!
Dave
--
DJO
------------------------------
Date: 24 Jul 2003 15:19:26 -0700
From: jelias1@evl.uic.edu (Joshua Eliason)
Subject: pod2usage verbose problem
Message-Id: <ce33c90b.0307240635.7886283b@posting.google.com>
hi,
i cannot get pod2usage to produce the associated output for verbose
levels 0 or 1 from the embedded pod. it prints nothing for verbose
level 0 and 1. verbose level 2 does produce a man page output though.
how can i get pod2uage to output the embedded pod info for verbose
level 0 and 1? i tested, and got the same problem, on cygwin with perl
5.8 and linux using perl 5.6. thanks in advance for any help.
josh
here's the script i tested:
#!/usr/bin/perl -w
use strict;
use Pod::Usage;
pod2usage(-verbose => 1);
__END__
=pod
=head1 NAME
podtest - test pod output using pod2usage
=head1 SYNOPSIS
B<podtest> [B<--help>] [B<--man>]
=head1 OPTIONS
=over 8
=item B<--help>
Print a brief help message and exits.
=item B<--man>
Prints the manual page and exits.
=back
=head1 DESCRIPTION
B<podtest> tests pod output using pod2usage.
=cut
------------------------------
Date: Thu, 24 Jul 2003 17:07:25 -0700
From: JS Bangs <jaspax@u.washington.edu>
Subject: Re: Q: Summarize/Condense already tight text string?
Message-Id: <Pine.A41.4.56.0307241649080.73652@dante18.u.washington.edu>
Brock Gunter-Smith sikyal:
> I'm dealing with a set of over 8,000 file that need to have their long
> filenames (up to 125 characters) reduced down to a maximum of 40
> characters. Right now I basically:
>
> if > maxlength remove all non alphanumeric characters
> if still too long, remove all vowels
> if still too long, trim from the middle to reduce length to maxlength
Assuming that your filenames are in English, I would suggest adding the
following at the *beginning* of your algorithm:
- Remove all words of 2 or less characters
- Remove all common prepositions and articles: the, with, and, from, for,
this, etc.
These items all carry little information, and can be pretty safely lost.
For a more esoteric solution, you could use Lingua::Soundchange and
implement the English-spelling algorithm at http://zompist.com/spell.html,
which will reduce English text by about 40%, but leave your filenames
littered with accented characters used in the makeshift phonetic alphabet.
The result will look like a mess, but it'll be pronounceable and pretty
intelligible with a little practice.
--
Jesse S. Bangs jaspax@u.washington.edu
http://students.washington.edu/jaspax/
http://students.washington.edu/jaspax/blog
Jesus asked them, "Who do you say that I am?"
And they answered, "You are the eschatological manifestation of the ground
of our being, the kerygma in which we find the ultimate meaning of our
interpersonal relationship."
And Jesus said, "What?"
------------------------------
Date: 24 Jul 2003 16:55:26 -0700
From: peterstokes@operamail.com (Peter Stokes)
Subject: Re: Read the contents of a text file into an HTML page
Message-Id: <10876b94.0307240739.216cc48@posting.google.com>
<snip>
> 1) Create an HTML page
> 2) Create a text file
> 3) Instead of editing the HTML, saving it then uploading it again I
> want to be able to just edit the text file on the server
> 4) When the browser visits the web page, the HTML reads the contents
> of the text file into a certian spot on the screen. I don't want it to
> just display the text file, i want it to display the contents in a
> pre-determined spot on the screen.
<snip>
As the others said, not a Perl issue. But as you've asked, you could
do worse than try an <iframe> - this will set aside a fixed space on
the web page and call into it the designated file. Another good way
would be a serverside include (SSI) as long as your server's set up to
handle this.
peter stokes
------------------------------
Date: 24 Jul 2003 16:44:04 -0700
From: johndporter@yahoo.com (John Porter)
Subject: Re: reference symbol not found with UDUNITS
Message-Id: <95f344ba.0307241544.4edec7e5@posting.google.com>
Randy Rokosz wrote:
> On a Solaris 7 machine, I had Perl 5.005_03 running with UDUNITS
> successfully.
> I then upgraded perl to 5.8.0 and placed this in /usr/local/bin/perl,
> I copied some of these files from the /opt/gnu/lib structure
> to the /usr/local/lib structure (perhaps incorrectly?), and now I get:
> ld.so.1: /usr/local/bin/perl: fatal: relocation error:
> /usr/local/lib/perl5/site_perl/5.8.0/sun4-solaris/auto/UDUNITS/UDUNITS.so:
> symbol perl_get_sv: referenced symbol not found
The two version of perl are not binary compatible.
That means that any modules with "binary" (i.e. compiled) code
won't work for both.
You'll need to re-compile UDUNITS for the 5.8 perl.
First, you should delete anything you copied from the 5.003 perl.
Even if a non-binary module from 5.003 works with 5.8, there's a
good chance it won't be the latest and greatest.
For maximum happiness, keep them separate!
--
John Douglas Porter
------------------------------
Date: Thu, 24 Jul 2003 18:51:07 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: reference symbol not found with UDUNITS
Message-Id: <slrnbi0s7b.99u.tadmc@magna.augustmail.com>
Randy Rokosz <rokosz@udel.edu> wrote:
> I had Perl 5.005_03
> I then upgraded perl to 5.8.0
> and now I get:
>
> ld.so.1: /usr/local/bin/perl: fatal: relocation error:
> /usr/local/lib/perl5/site_perl/5.8.0/sun4-solaris/auto/UDUNITS/UDUNITS.so:
> symbol perl_get_sv: referenced symbol not found
Does UDUNITS have an XS component?
Perl 5.8.0 is not binary compatible with earlier versions.
> How can I get the new Perl to call UDUNITS correctly?
Modules that use C code will need to be recompiled (reinstalled).
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 24 Jul 2003 18:33:05 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: references help
Message-Id: <slrnbi0r5h.99u.tadmc@magna.augustmail.com>
slash <satishi@gwu.edu> wrote:
> Thanks Tad!!
You're welcome.
You can pay me back by learning to quote your followups properly.
Soon.
Have you seen the Posting Guidelines that are posted here frequently?
> First, I
> want to know how to run this program on multiple input files.
^^^^^^^^^^^^
What program?
We are here to _help_ you program, not to actually do the programming
for you.
Did you try modifying the program for multiple input files?
What part did you get stuck on?
[ snip 100 lines of TOFU ]
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 24 Jul 2003 23:29:07 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Regex question
Message-Id: <slrnbi0qu3.19a.abigail@alexandra.abigail.nl>
Math55 (magelord@t-online.de) wrote on MMMDCXIV September MCMXCIII in
<URL:news:a2b8188a.0307240345.7f9acc1c@posting.google.com>:
?? hi, the regex .* should match everything but newline, right? but it
?? doesnt. sime time ago i read something that .* will not match
?? evrything? is that true?
If you'd think that '.*' doesn't match anything that isn't a newline,
please show us some proof.
Abigail
--
perl -Mstrict -we '$_ = "goto _.print chop;\n=rekcaH lreP rehtona tsuJ";_1:eval'
------------------------------
Date: Thu, 24 Jul 2003 18:34:21 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Regex question
Message-Id: <slrnbi0r7t.99u.tadmc@magna.augustmail.com>
Math55 <magelord@t-online.de> wrote:
> the regex .* should match everything but newline, right? but it
> doesnt.
Yes it does.
Show us code where it doesn't.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 24 Jul 2003 16:20:51 -0700
From: peterstokes@operamail.com (Peter Stokes)
Subject: Stumped by formatting - newbie plea
Message-Id: <10876b94.0307240716.75c2442d@posting.google.com>
I'm trying to use a list, created from an array, to build a dropdown
list in a web page form.
I start with a flatfile database, pipe delimited. The first field is
the county, then the name, then other info. The dropdown list is to be
of the counties.
I've got:
open (INFILE, "db1.dat");
while (<INFILE>) {
@things = split /\|/;
@counties = splice(@things,0,1);
This is fine, it generates my list, but of course it has duplicates in
it. So to get rid of the duplicates I've got:
@counties = grep( ( ($h{$_}++ < 1) || 0 ), @counties );
Which does indeed get rid of the duplicates.
This is where I'm having the problem. If I now:
print @counties;
I get a solid line of text. I need to format this. If I:
print "<option value=\"@counties\">@counties\n";
I get a list which includes formatting on the lines that have been
removed, so the result looks like:
<option value="Berkshire">Berkshire
<option value="Dorset">Dorset
<option value="">
<option value="">
<option value="Gloucestershire">Gloucestershire
...and so on.
Please can anyone suggest where I'm going wrong.
Thanks
Peter Stokes
------------------------------
Date: Fri, 25 Jul 2003 01:40:09 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Stumped by formatting - newbie plea
Message-Id: <bfpqnk$hi5s1$1@ID-184292.news.uni-berlin.de>
Peter Stokes wrote:
> So to get rid of the duplicates I've got:
> @counties = grep( ( ($h{$_}++ < 1) || 0 ), @counties );
> Which does indeed get rid of the duplicates.
<snip>
> If I:
> print "<option value=\"@counties\">@counties\n";
> I get a list which includes formatting on the lines that have been
> removed, so the result looks like:
> <option value="Berkshire">Berkshire
> <option value="Dorset">Dorset
> <option value="">
> <option value="">
> <option value="Gloucestershire">Gloucestershire
> ...and so on.
http://www.perldoc.com/perl5.8.0/pod/perlfaq4.html#How-can-I-remove-duplicate-elements-from-a-list-or-array-
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 24 Jul 2003 23:15:37 GMT
From: Joseph Ellis <jandellis@hotmail.com>
Subject: Re: Style question regarding subroutines and lexical variables
Message-Id: <0rp0ivo8iunuslcfml3qnj54o1470in0l9@4ax.com>
On Thu, 24 Jul 2003 11:00:42 -0500, tadmc@augustmail.com (Tad
McClellan) wrote:
>Joseph Ellis <jandellis@hotmail.com> wrote:
>> On Thu, 24 Jul 2003 08:51:28 -0500, tadmc@augustmail.com (Tad
>> McClellan) wrote:
>
>
>>>Using the ampersand is what allows cheating, so if you want to
>>>eliminate the possibility of cheating, then eliminate the use
>>>of ampersand on function calls.
>>
>> Ahh...I see. I was right though; I really don't know what I'm doing.
>
>
>If you are just starting with Perl, then your plate is already
>pretty full with things to look into.
Yeah no kidding...
>
>You should apply the Pareto Principle in your effort to learn Perl.
>
> Knowing 20% of Perl can get 80% of commmon programming tasks done.
>
>Concentrate on the most-important 20% first, move on to the others
>much later when you have time (and you'll have more time because
>the 20% you've learned is getting lots of your everyday work done).
>
>
>> I don't understand what prototypes and prototype checking are all
>> about.
>
>
>You probably don't need to (yet). Perl's prototypes are in the 80%.
>
>The 20%-part of prototypes is simply:
>
> Do not circumvent them if they are present.
>
>And you already know how to avoid circumventing them. :-)
>
>Prototypes have to to with argument checking, if they are present
>then you must call the functions with correct argument types.
>
>
>> I'll have to look that up.
>
>
>Save the time for something with a larger payback, like reading any
>of these end-to-end:
>
> perldoc perlrun
> perldoc perldata
> perldoc perlsyn
> perldoc perlop
> perldoc perlsub
>
>and maybe:
>
> perldoc perlintro
> perldoc perlrequick
> perldoc perlretut
> perldoc perlreftut
> perldoc perlvar
>
>and know to look things up as needed in:
>
> perldoc perldiag
> perldoc -f (perlfunc)
> perldoc -q (perlfaq1 - perlfaq9)
>
>
>:-)
Thanks for the direction...at this stage in learning Perl, deciding
what aspects to devote a lot of attention to vs. what to reserve for
later learning can be difficult.
I'd say I'm using 10% of Perl to get 60% of my programming done. The
other 40% is painfully assembled piecemeal from a hodge-podge of
suggestions and tidbits of information gleaned from cursory readings
of online documentation and the like. I've been treating perldoc more
like an index of topics rather than something to be read end-to-end.
I guess I'll now focus on the latter, as you've suggested.
Have nice days.
Joseph
------------------------------
Date: Thu, 24 Jul 2003 23:37:39 GMT
From: Joseph Ellis <jandellis@hotmail.com>
Subject: Re: Style question regarding subroutines and lexical variables
Message-Id: <u5r0ivcj0hrl4trndhouqb24oqif215k0l@4ax.com>
On Thu, 24 Jul 2003 16:18:46 +0200, Malte Ubl <ubl@schaffhausen.de>
wrote:
>A. Sinan Unur wrote:
>> Regardless of language, if I see a method/function/subroutine being
>> called with 30 arguments, I am inclined to think there is a design issue.
>
>Just to make it clear. The design issue is not solved by using global
>variables, which are only needed is a few corner cases of programming.
>
>malte
Of course.
I am sure that adhering to one extreme (having all global variables)
or another (passing around 30 arguments) is not a sound or efficient
way to program. I'm just still trying to learn where the best place
to be in that continuum is.
Thanks for the input everyone...you've all helped a great deal.
Joseph
------------------------------
Date: 24 Jul 2003 16:26:10 -0700
From: sherman.willden@hp.com (Sherman Willden)
Subject: twig requires 5.004, I am using Windows v5.6.1, which twig do I need
Message-Id: <3a80d8d6.0307240719.1cc633ce@posting.google.com>
I would like to use XML::Twig but use XML::Twig returns "Compilation
failed in require, BEGIN failed - compilation aborted." I downloaded
Twig-3.10 from cpan. Can you help me to obtain the correct Twig for
perl, v5.6.1 built for MSWin32-x86-multi-thread.
Thanks;
Sherman
------------------------------
Date: Fri, 25 Jul 2003 09:55:47 +1000
From: "Sisyphus" <kalinabears@iinet.net.au>
Subject: Re: twig requires 5.004, I am using Windows v5.6.1, which twig do I need
Message-Id: <3f207310$0$23596$5a62ac22@freenews.iinet.net.au>
"Sherman Willden" <sherman.willden@hp.com> wrote in message
news:3a80d8d6.0307240719.1cc633ce@posting.google.com...
> I would like to use XML::Twig but use XML::Twig returns "Compilation
> failed in require, BEGIN failed - compilation aborted."
This often means that you've tried to 'use' a module that you don't have
installed - and there's normally something in the error message to tell you
which module that was. I think you've only provided the last part of the
error message - best if you post (a copy'n'paste of) the entire output.
> I downloaded
> Twig-3.10 from cpan. Can you help me to obtain the correct Twig for
> perl, v5.6.1 built for MSWin32-x86-multi-thread.
>
That will be suitable. 'require 5.004' means 'require 5.004 or later'.
Cheers,
Rob
------------------------------
Date: Thu, 24 Jul 2003 15:00:22 -0700
From: JS Bangs <jaspax@u.washington.edu>
Subject: XML or home-grown format?
Message-Id: <Pine.A41.4.56.0307241439550.111292@dante03.u.washington.edu>
In the continuing development of Lingua::Phonology, I'm starting to
consider what the benefits would be of moving my file-parsing formats to
XML from the current custom format.
Currently, two of the sub-modules do some form of file-parsing, and the
formats they use are described at:
http://search.cpan.org/author/JASPAX/Lingua-Phonology-0.25/Phonology/Features.pm#loadfile
http://search.cpan.org/author/JASPAX/Lingua-Phonology-0.25/Phonology/Symbols.pm#loadfile
The existing formats are concise and human-readable, but completely
custom. As I'm thinking of adding file-parsing to Lingua::Phonology::Rules
(and perhaps other modules), I was looking for something more reusable,
general, and powerful (especially since the Rules submodule will require
some fairly complex parsing rules). If I use XML, I can pass parsing
duties off to XML::Whatever, but I'm concerned that the costs (in terms of
verbosity) will outweight the benefits of portability and extensibility.
For example, I can currently write the following line in a file to be
parsed by Lingua::Phonology::Symbols:
d +anterior -distributed voice
In XML, this might have to be as verbose as:
<symbol label="d`">
<feature name="anterior" value="+" \>
<feature name="distributed" value="-" \>
<feature name="voice" \>
</symbol>
Which is significantly heavier and less clear. I'm rather torn on this, so
I was wondering what insight the minds here have to offer. Many thanks--
--
Jesse S. Bangs jaspax@u.washington.edu
http://students.washington.edu/jaspax/
http://students.washington.edu/jaspax/blog
Jesus asked them, "Who do you say that I am?"
And they answered, "You are the eschatological manifestation of the ground
of our being, the kerygma in which we find the ultimate meaning of our
interpersonal relationship."
And Jesus said, "What?"
------------------------------
Date: Thu, 24 Jul 2003 23:41:01 +0000
From: Rich <scriptyrich@yahoo.co.uk>
Subject: Re: XML or home-grown format?
Message-Id: <bfpn7m$qth$1@newsg3.svr.pol.co.uk>
JS Bangs wrote:
snip
> In XML, this might have to be as verbose as:
>
> <symbol label="d`">
> <feature name="anterior" value="+" \>
> <feature name="distributed" value="-" \>
> <feature name="voice" \>
> </symbol>
>
> Which is significantly heavier and less clear. I'm rather torn on this, so
> I was wondering what insight the minds here have to offer. Many thanks--
I'd consider YAML whenever you need XML like structures that poor old humans
might have to read/edit.
The slight downer is that YAML seems to be developing at a pace similar to
p6, though in both cases it'll be worth the wait.
Cheers
--
Rich
scriptyrich@yahoo.co.uk
------------------------------
Date: 24 Jul 2003 23:51:03 GMT
From: usenet@megazone.org (MegaZone)
Subject: Re: XML or home-grown format?
Message-Id: <megazone.1059090662@sidehack.sat.gweep.net>
JS Bangs <jaspax@u.washington.edu> shaped the electrons to say:
>d +anterior -distributed voice
>
>In XML, this might have to be as verbose as:
>
><symbol label="d`">
> <feature name="anterior" value="+" \>
> <feature name="distributed" value="-" \>
> <feature name="voice" \>
></symbol>
<symbol label="d" anterior="+" distributed="-" voice="+" />
Something like that is just as valid in XML, and XML::LibXML works
well, I've been using it for a few months now and I'm really starting
to like it now that it has sunk into my brain so I don't have to keep
looking things up. :-)
Since XML requires attributes to have values I just used "+" for
voice, but you could do things like voice="voice", etc.
It really depends on what you're looking to use the data for - I just
created a file like:
<?xml version="1.0" encoding="UTF-8"?>
<CurrencyTable xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="pcCurrencyTable.xsd">
<Version>1.0</Version>
<CurrencyShift number="840" name="USD">2</CurrencyShift>
</CurrencyTable>
(there were a lot more CurrencyShift elements...)
Using XPath you can find the element based on one attribute and get
the value of another - as in this:
---
use strict;
use warnings;
use XML::LibXML 1.0053;
my $xmlFile;
my $parser = XML::LibXML->new();
open (XMLCONF, "<./pcCurrencyTable.xml") ||
die "Can't open table: $!";
while (<XMLCONF>) {
$xmlFile .= $_;
}
close (XMLCONF);
my $dom = $parser->parse_string($xmlFile);
$xpath = "//CurrencyTable/CurrencyShift[\@number='840']/\@name";
print( ($dom->findnodes($xpath))[0]->textContent() . "\n");
----
That prints "USD".
(And I make no claim that is the the most elegant way to do that, just
what came to me first.)
-MZ, CISSP #3762, RHCE #806199299900541
--
<URL:mailto:megazone@megazone.org> Gweep, Discordian, Author, Engineer, me..
"A little nonsense now and then, is relished by the wisest men" 508-755-4098
<URL:http://www.megazone.org/> <URL:http://www.eyrie-productions.com/> Eris
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
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.
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 5269
***************************************