[19358] in Perl-Users-Digest
Perl-Users Digest, Issue: 1553 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 17 18:09:34 2001
Date: Fri, 17 Aug 2001 15:05:15 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <998085914-v10-i1553@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 17 Aug 2001 Volume: 10 Number: 1553
Today's topics:
Re: Determining array length <johndporter@yahoo.com>
Re: eval and reading in a file <johndporter@yahoo.com>
FAQ: Why can't I use "C:\temp\foo" in DOS paths? What <faq@denver.pm.org>
form processing script <lalita@aquifer.geology.uiuc.edu>
Re: form processing script <glob@cableone.net>
Re: Free open source CMS's written in perl? (=?ISO-8859-1?Q?Morten_Tanger=E5s?=)
Help with Piped command, capturing output (Jonathan Cunningham)
Re: Help! Multiple line extract from file based on use <cberry@cinenet.net>
Re: Help! Multiple line extract from file based on use <joe+usenet@sunstarsys.com>
IO::Socket::INET - Setting Reset bit when closing TCP c (Jay McGavren)
Re: local exec via cgi <gnarinn@hotmail.com>
Re: Need Perl module or regexp to slurp specific XML re <mel2000@hotmaildot.com>
Re: Need Perl module or regexp to slurp specific XML re <mel2000@hotmaildot.com>
Re: OT: Why is there so much white space in perl docume <bart.lateur@skynet.be>
Re: OT: Why is there so much white space in perl docume <miscellaneousemail@yahoo.com>
Perl and E-mail function <john@cemnetwork.com>
Re: perldoc is like Greek to a beginner?? (Abigail)
Re: Processing a scalar in the same way of a filehandle <johndporter@yahoo.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 17 Aug 2001 21:13:36 GMT
From: John Porter <johndporter@yahoo.com>
Subject: Re: Determining array length
Message-Id: <3B7D886E.17C9DDB5@yahoo.com>
Craig Berry wrote:
> "G Harper" <admin@CLIPMEnova1.f2s.com> wrote in
> > open(DIN, "<dat/stats.txt") or die "Unable to load file";
>
> You get many bonus points for checking the result of open(), by the way.
Yes; but we'll dock a couple bonus points for not including
the filename and $! in the error message. ;-)
--
John Porter
------------------------------
Date: Fri, 17 Aug 2001 21:50:18 GMT
From: John Porter <johndporter@yahoo.com>
Subject: Re: eval and reading in a file
Message-Id: <3B7D9105.90E3C0AB@yahoo.com>
Jukka Juslin wrote:
>
> Why is this kind a thing not working in Perl 5.005:
>
> eval `cat eval.fis`;
Don't know. Why don't you just use "do"? --
do "eval.fis";
You could even use require --
require "eval.fis";
--
John Porter
------------------------------
Date: Fri, 17 Aug 2001 18:17:00 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: Why can't I use "C:\temp\foo" in DOS paths? What doesn't `C:\temp\foo.exe` work?
Message-Id: <wcdf7.197$V3.170972672@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
Why can't I use "C:\temp\foo" in DOS paths? What doesn't `C:\temp\foo.exe` work?
Whoops! You just put a tab and a formfeed into that filename! Remember
that within double quoted strings ("like\this"), the backslash is an
escape character. The full list of these is in the Quote and Quote-like
Operators entry in the perlop manpage. Unsurprisingly, you don't have a
file called "c:(tab)emp(formfeed)oo" or "c:(tab)emp(formfeed)oo.exe" on
your legacy DOS filesystem.
Either single-quote your strings, or (preferably) use forward slashes.
Since all DOS and Windows versions since something like MS-DOS 2.0 or so
have treated "/" and "\" the same in a path, you might as well use the
one that doesn't clash with Perl--or the POSIX shell, ANSI C and C++,
awk, Tcl, Java, or Python, just to mention a few. POSIX paths are more
portable, too.
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
05.31
--
This space intentionally left blank
------------------------------
Date: Fri, 17 Aug 2001 13:52:40 -0500
From: "Lalita Kalita" <lalita@aquifer.geology.uiuc.edu>
Subject: form processing script
Message-Id: <4Fdf7.6797$A3.49953@vixen.cso.uiuc.edu>
Hi,
I would like to look at any sample CGI script written in Perl which
gethers data from a form that user sends and put the data into a file. I am
new to this news group, as well as to Perl.
Thanks.
Lalita
------------------------------
Date: Fri, 17 Aug 2001 07:55:47 -0700
From: David Aslanian <glob@cableone.net>
Subject: Re: form processing script
Message-Id: <tnr4h5je85stc6@corp.supernews.com>
Lalita Kalita wrote:
> Hi,
> I would like to look at any sample CGI script written in Perl which
> gethers data from a form that user sends and put the data into a file.
Well, here's your options:
look at examples in books
look at examples on the web
look at programs that do this
....
or learn how to do it yourself.
I assume that you want to see a script of this sort either because 1. you
want to look at style, functionality, etc. or 2. you don't know how to do
it and you want to find out.
(It would help if you asked a question, rather than resorting to your own
ways of finding answers and then asking a question about them.)
Anyway, if you want to do this you need to know the basics of perl plus
the CGI module and file handling.
for CGI module (recommended):
http://www.devshed.com/Server_Side/Perl/CGIpmBasics/page2.html
for examples (these are kinda complex, but you'll get the idea:
http://www.devshed.com/Server_Side/Perl/Perl101_8/
> I am new to this news group, as well as to Perl.
> Thanks.
> Lalita
>
>
>
------------------------------
Date: Fri, 17 Aug 2001 18:56:36 GMT
From: morten@tangeraas.com (=?ISO-8859-1?Q?Morten_Tanger=E5s?=)
Subject: Re: Free open source CMS's written in perl?
Message-Id: <1eyavk4.1r1vllxaeaudcN%morten@tangeraas.com>
Ilya Martynov <ilya@martynov.org> wrote:
> MT> Are there any free and flexible open source content management systems,
> MT> similar to the OpenCMS project (opencms.org - it's written in java)?
>
> Maybe http://sourceforge.net/projects/mason-cm/ ?
Looks okay to people like us who knows programming and stuff, but not as
simple for "usual" people who doesn't know html, programming and stuff,
but want's to manage the content of they're webpages anyway.
Actually, it would be interesting to have a discussion on this subject.
Today, there are several ISP's and web system developers who's making
they're own CMS's, which in many cases are very good. But what does the
users of these systems (the customers, which may be newspapers, company
owner with they're own website, managed with a CMS-tool) do if the owner
of the system, eg. an ISP, runs out of business (and the CMS system
dissapares)?
If it could be an open source and free CMS tool what several ISPs
installed on they're servers, this would not be any problem. I also
think that by making an open source system, this CMS would be a very
good CMS (because of many developers).
To make this work, for the user the system should be:
- Easy and simple to use, even for people who only (and even barely)
know's how to surf on the web.
- Flexible enough for the user to manage allmost everything that has to
do with they're webpages and related
- Completly managed through a web based interface, no installation
required
- Compact, so that the user can manage more than only a webpage, but
also eg. they're e-mail accounts, read visitor statistics etc.
- Flexible, also in that way that it can be used to manage different
kinds of webpages; personal websites, news papers, Yahoo'alike websites,
business websites, both internal (password protected) and external
business websites etc.
For the ISP, it should be:
- Easy to install, as one standalone perlscript package
- Flexible enough to run on several servers with different
configurations. In my opinion, it should be made in perl with one main
script and different modules for different configurations and options.
In example, it could have optional database modules; one for flat text
file databases, one for MySQL databases etc.
- Also flexible enough so that the ISP could install different modules
as supplemental services.
- Appearance : The viewing script for the administration should not
contain any html tag; even the administration should be based on
templates (not only the site design, but also the stucture if possible)
so that a website designer or the ISP can make it look and appear in
"unique" ways
For the website designer, it should be:
- Easy to set up a complete website administration, based on website
templates, ready for the end user (eg. the customer) to manage
- Easy to change templates for the administration appearance
- ...and more
A project like this should involve website designer as well as
programmers, server maintainers etc., in other words, a wide spectre of
people which on a daily basis works with internet communication and
development, and who would like to work with a project like this for
free.
Is this of any interest? It would really be interesting to have a
discussion on this subject...
Regards,
Morten Tangeraas
------------------------------
Date: 17 Aug 2001 12:55:58 -0700
From: dawfun@seanet.com (Jonathan Cunningham)
Subject: Help with Piped command, capturing output
Message-Id: <4d6fd5fc.0108171155.126a57ae@posting.google.com>
Here's my little program called myPGP.pl running on W2k:
use strict;
my $passphrase = shift;
my $pubKey = shift;
my $message = shift;
open(OUTPUT,"|pgp -feast -m -z $passphrase $pubKey");
print OUTPUT $message;
close OUTPUT;
print "\n\nDONE\n";
I call this program from the command line, and pass to it my PGP
password, public key, and the message I want to encrypt (as a glob of
text).
For example:
perl -w myPGP.pl password someKey@someDomain.com "Encrypt this
text"
This does about 98% of what I'm trying to do, which is to pass text to
PGP and encrypt it. When this is run all output is printed to the
screen (STDOUT), including the encrypted message. This is fabulous,
however I'd also (or alternatively) like to capture the output to a
variable within this program and then do something else to it (TBD).
I've tried using open2() to do the bidirectional pipe thing, but that
left me thoroughly confused, and didn't even work. :P I've also
tried other things like using the pipe() function, but never made any
sense out of that either.
I've read, and experimented quite a bit, and feel as though I've
conspicuously missed something fairly obvious (for which I'll hang my
head in shame if that turns out to be the case).
Can anyone suggest a solution to this problem (with some anecdotal
example, please)? I know there has to be a way to do this.
Thanks,
Jonathan
------------------------------
Date: Fri, 17 Aug 2001 20:57:30 -0000
From: Craig Berry <cberry@cinenet.net>
Subject: Re: Help! Multiple line extract from file based on user input.
Message-Id: <Xns91008DFE74D75cberrycinenetnet1@207.126.101.92>
Bart Lateur <bart.lateur@skynet.be> wrote in
news:023qntknh8sioqlt1svstn4qlj2e9hkkc8@4ax.com:
> Craig Berry wrote:
>
>>(my $selStr = shift) =~ s/(\d+)-(\d+)/join ',', $1 .. $2/eg;
>
> I really like that one.
Thanks! Definitely had one of those Perl Moments when I thought of it.
> I do worry a bit in that the user supplied range selection string isn't
> tested for syntax.
Of course. In Real Life I'd do some syntax checking. Most good
hypercompact code eschews error checking.
>>print( ('dummy', <>)[split /,/, $selStr] );
>
> But this slurps in the whole file. I would populate a hash, and include
> the record if $. is in the hash.
>
> my %include; @include{/\d+/g} = ();
> while(<>) {
> print if exists $include{$.}
> }
Problem is that this loses the ability to select lines in arbitrary order
like "12,9". Doing that without slurping the file is tough.
--
Craig Berry <http://www.cinenet.net/~cberry/>
"That which is now known, was once only imagined." - William Blake
------------------------------
Date: 17 Aug 2001 17:52:10 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Help! Multiple line extract from file based on user input.
Message-Id: <m3d75u2w39.fsf@mumonkan.sunstarsys.com>
Craig Berry <cberry@cinenet.net> writes:
> Problem is that this loses the ability to select lines in arbitrary
> order like "12,9". Doing that without slurping the file is tough.
Golf?
% perl -pe '@b[grep{$.==$a[$_]}0..$#a]=($_)x@a}BEGIN{$_=shift;
s/-/../g;@a=eval}for(@b){' <string> <file>
--
Joe Schaefer "A man cannot be too careful in the choice of his enemies."
--Oscar Wilde
------------------------------
Date: 17 Aug 2001 11:20:41 -0700
From: sgarfunkle@hotmail.com (Jay McGavren)
Subject: IO::Socket::INET - Setting Reset bit when closing TCP connection?
Message-Id: <6bb557e1.0108171020.38c5016f@posting.google.com>
I'm trying to emulate another program's behavior over a TCP
connection, and it's going fairly well, except that I always leave
connections open on the server when I'm done. I eavesdropped on both
the program I'm emulating and my own script with Ethereal (a packet
sniffer), and it turns out I *should* have the reset bit set in my
disconnect request, but instead I have the 'Fin' bit set.
What I've got:
Source port: 4653 (4653)
Destination port: program-x (1682)
Sequence number: 13745973
Acknowledgement number: 421923
Header length: 20 bytes
Flags: 0x0011 (FIN, ACK)
0... .... = Congestion Window Reduced (CWR): Not set
.0.. .... = ECN-Echo: Not set
..0. .... = Urgent: Not set
...1 .... = Acknowledgment: Set
.... 0... = Push: Not set
.... .0.. = Reset: Not set
.... ..0. = Syn: Not set
.... ...1 = Fin: Set
Window size: 8760
Checksum: 0x88cf (correct)
What I need:
Source port: 3734 (3734)
Destination port: program-x (1682)
Sequence number: 13482128
Header length: 20 bytes
Flags: 0x0004 (RST)
0... .... = Congestion Window Reduced (CWR): Not set
.0.. .... = ECN-Echo: Not set
..0. .... = Urgent: Not set
...0 .... = Acknowledgment: Not set
.... 0... = Push: Not set
.... .1.. = Reset: Set
.... ..0. = Syn: Not set
.... ...0 = Fin: Not set
Window size: 0
Checksum: 0xb47c (correct)
Here's the simplest possible version of my script (tested, it does
leave connections open):
use strict;
#Open socket to gateway
use IO::Socket::INET;
my $gateway = new IO::Socket::INET(
PeerAddr => '255.255.255.2',
PeerPort => '1682',
LocalAddr => '255.255.255.1',
Proto => 'tcp'
);
close $gateway;
How can I specify that I want the 'Fin' bit off and the Reset bit on,
hopefully while still using IO::Socket::INET? Many thanks for any
help you can give!
------------------------------
Date: Fri, 17 Aug 2001 18:38:18 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: local exec via cgi
Message-Id: <998073498.838356931228191.gnarinn@hotmail.com>
In article <129rntscc67ecs5cm8hehf82cpet5618fi@4ax.com>,
GunneR <ds@ss.com> wrote:
>I know this is very insecure, and im not sure if its even perl
>related, but...
>
>Im trying to write a cgi script that executes local code (via system,
>exec, etc) on the system that visits the page.
do you mean that you want to use a browser on your PC to run cgi script
on a server that will somehow start local code on your PC ?
then i have 2 questions:
a) why on earth dont you just execute the the local code directly ?
b) what is your real question? tell us what you really need to do
>My alternative is to use socket (server, client) stuff to talk back
>and fourth (Linux, Windows) but that could get messy. Is there some
>funky module that does this or do I have to write some real shoddy cgi
>code?
it does not matter how shoddy your cgi code is, it willnever be able to do
what you want.
the only way to do this is to use IE on the PC, and implement the
secret microsoft back-door codes that give server control of the client
IE.
;-)
gnari
------------------------------
Date: Fri, 17 Aug 2001 12:01:13 -0700
From: "M.L." <mel2000@hotmaildot.com>
Subject: Re: Need Perl module or regexp to slurp specific XML records
Message-Id: <9ljpom$9pi2q$1@ID-19545.news.dfncis.de>
> SNIP
>
> > RECAP: Given the following fixed XML records format:
> >
> > <record id="012-8">
> > <name>John Doe</name>
> > <address>123 Main St.</address>
> > <city>Lake Elsinore</city>
> > <state>CA</state>
> > <phone>(123) 456-7890</phone>
> > <zip>12345</zip>
> > <email>jd@domain.com</email>
> > </record>
> >
> > objective: slurp into hash only records where, for example, <state> = NY
> SNIP
> > Taking all advice into consideration, as well as advice from Google
search
> > on Perl extraction techniques, could I do something like this?
>
> As other have said already ths approach takes the data structure for
> granted. This means that if it changes, even slightly, then use a
> propper parse.
>
When I originally posed my question I took shortcuts in my explanation in
order to get to the point. I left out a lot of code details that I thought
weren't critical to the mission of slurping XML. In fact, my coding will
allow for new elements to be added without changing the code since each
element name will be in an array:
for example, @recArr = qw(name address city state phone zip email);
> OTOH If its unlikely to change then youll need to correct a few bugs.
>
> Read up on context.
>
> SNIP
> > where: $user_parameter = 'NY';
>
> Uhm, not a good idea to mix comments and code in posts...
> In future probably the above should be written:
>
> my $user_parameter='NY';
>
Actually, the snippets I used were in pidgin Perl and not intended as
production code. Nothing has actually been written yet. In context of a
recap, did you really think I intended the "where:" to be included as part
of an instruction? Everything I typed was hurriedly copied from scratch
paper, Google, or a previous poster.
> But for maintainance pupose maybe you should do something like
>
> my $match_cond=qr/<state>\s*NY\s*<\/state>/;
>
> That way it is VERY clear what you are using for your match...
> I suppose there are other ways, but thats up to you.
Actually, I won't be using such literals in my final code. The states will
be assigned as loop variables; the the XML element names will be variables
pointing to their array position. No hard-coding.
> > local ($/) = '</record>';
> > local @ARGV = 'filename.xml';
>
> This line is just for testing purposes right? (local @argv)
> Also I believe you have muddled the list concept up a bit:
>
> local $/='</record>'; #scalar assignment
> local @ARGV=qw(filename.xml); #see perlop for qw() #list assignment
I copied the lines above from a Google thread. The author might have been
writing pidgin Perl too for all I know. Thanks for your correction though.
> > foreach (grep(/<state>\s*$user_parameter\s*<\/state>/i, <>))
>
> Hmm, if your file is very large and there are many records that will
> match then using a for might cause you problems. I would stick with
> a while personally...
>
> while (<>) {
> next unless /$match_cond/io; # see perlre for the o modifier
I don't understand why one example is more problematic than the other. I'll
use yours since you say so.
> > {
> > $id = m/\bid\s*=\s*"(.*?)"/i; # should have mentioned id not just
numeric
>
> Hmm. :-) Yes. You should have. The lizard is going to complain now..
Again, I was trying to save bandwidth and had no idea everything would be
scrutinized so much.
> But really the above line wont do... (minor really :-)
> Once again the issue is list context. (You really should read up on
> this idea.
> It is crucial to Perl and is not seen in many other languages so you
> need to grok
> it properly. :( Cant remember where to look though. Could be perlsyn)
>
> (my $id) = m/\bid\s*=\s*"(.*?)"/i;
>
> > $records{$id}{'id'} = $id;
> > $records{$id}{'state'} = $user_parameter;
> > $records{$id}{'name'} = m/<name>\s*(.*?)\s*<\/name>/i;
> > $records{$id}{'address'} = m/<address>\s*(.*?)\s*<\/address>/i;
>
> And once again the list context is the problem...
>
> ($records{$id}{'name'}) = m/<name>\s*(.*?)\s*<\/name>/i;
> ($records{$id}{'address'}) = m/<address>\s*(.*?)\s*<\/address>/i;
>
I'll have to do some research on that list context problem.
> > ...
> > $states{$user_parameter}[$i++] = $id; # need to store ids for each
state
> > }
>
> And that should work fine.
>
> Yves
Thanks for all your advice Yves; the time saved will be a big help..
M.L.
------------------------------
Date: Fri, 17 Aug 2001 12:21:02 -0700
From: "M.L." <mel2000@hotmaildot.com>
Subject: Re: Need Perl module or regexp to slurp specific XML records
Message-Id: <9ljqtr$9pkgt$1@ID-19545.news.dfncis.de>
> [snip]
>
> No, you shouldn't do it something like that. It depends strongly on the
> structure of your data, and if the structure of your XML changes, then
> you have to rewrite your parser almost entirely.
>
The example was shown as such for brevity. The final code will use variables
to allow new elements to be incorporated into the XML slurp without changing
the code. I was trying to be as brief as clarity would allow.
> Here's a parser I wrote which should be able to parse any XML data. It
> assumes that the contents of a tag will only be strings, or nested tags
> [not both]. This assumption is true for most real world XML [except
> when considering html as xml, which usually does have mixed tags and
> text].
>
> #!/usr/local/bin/perl -w
> use Text::Balanced qw(extract_tagged);
> use Tie::IxHash;
> use strict;
I hope this is a pure Perl solution.
> sub parse_xml_params {
> local ($_) = shift;
> m[<(\w+)\s*]g or die "Missing start tag\n";
> my $tagname = $1;
> tie my(%params), "Tie::IxHash";
> # this regex here isn't exactly the best, but it works
> # for the data given, if not the general case.
> while( m[\G(\w+)\s*(?:=\s*"([^"]*)")?\s*]g ) {
> $params{$1} = $2;
> }
> ( $tagname, \%params );
> }
>
> sub parse_xml_tree {
> local ($_) = @_;
> my @results;
> while( undef,$_,my($prefix,$open,$contents,$close))
> = extract_tagged ) {
> push @results, [parse_xml_params($open),
> parse_xml_tree($contents)];
> }
> @results ? \@results : $_[0];
> }
>
> =pod
>
> This produces the data structure:
> [ [ "xml-documentroot-tag", { key => value, key => value }, [
> [ "record", {id=>"012-8"}, [
> ["name", {}, "John Doe"],
> ["address", {}, "123 Main St."],
> ["city", {}, "Lake Elsinore"],
> ["state", {}, "CA"],
> ["phone", {}, "(123) 456-7890"],
> ["zip", {}, "12345"],
> ["email", {}, "jd@domain.com"],
> ] ],
> [ "record", {id=>...}, [
> ....
> ] ],
> ] ] ]
>
> Remember, proper XML docs have exactly one root, and may have many
> levels of nested tags within.
>
> =cut
>
> # this is the part which depends on the shape of <record> tags.
>
> my @roots = @{parse_xml_tree( do { local $/; <> } )};
> die "Only one document root allowed" if @roots > 1;
> my $root = $roots[0];
> print "The name of the root is $root->[0]\n";
>
> my $records = $root->[2];
>
> # turn our parsed tree into nested hashes.
> tie my (%records), "Tie::IxHash";
> foreach my $r ( @$records ) {
> my ($name,$params,$contents) = @$r;
> die "Expected only <record> things"
> unless $name eq "record";
> defined( my $id = $params->{id} )
> or die "Missing id";
> tie my (%rec), "Tie::IxHash";
> foreach my $rr ( @$contents ) {
> my ($n, $p, $c) = @$rr;
> die "Expected a string" if ref $c;
> $rec{$n} = $c;
> }
> next if( $rec{state} ne "NY" );
> $record{$id} = \%rec;
> }
>
> # modify %records.
>
> # print them to stdout:
> print qq[<$root->[0]>\n];
> while( my ($id, $rec) = each %records ) {
> print qq[\t<record id="$id">\n];
> while( my($field, $val) = each %$rec ) {
> print qq[\t\t<$field>$val</$field>\n];
> }
> print qq[\t</record>\n];
> }
> print qq[</$root->[0]>\n];
>
> The reason I tie all my hashes to Tie::IxHash is so that when retrieving
> the data via each(), they will be in the same order they were put in.
> You can omit this if you want, but your output data may now be in
> arbitrary order, unless you do a sort or somesuch.
>
Very impressive!! I'll certainly add that one to my snippet library. Not
that I understand your code right now, but if I need a generic parser I'll
certainly revisit it.
BTW, my records really really really are fixed. And even if I add new
elements to a record, my use of element variables will keep it from breaking
the code. I'd like to know why so many posters are averse to the idea of
fixed records. XML::Records is based on the assumption of fixed records, no?
Thanks for the code, it's likely I'll need to use it on another non-fixed
records project.
Regards,
M.L.
------------------------------
Date: Fri, 17 Aug 2001 20:07:18 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: OT: Why is there so much white space in perl documentation??
Message-Id: <ebuqntoasdl24obuv52tel0fl9l70tknhc@4ax.com>
Carlos C. Gonzalez wrote:
>Still I wish things were easier and simpler for a beginning Perl
>programmer trying to learn Perl and getting advice from a usenet group
>mainly working on Unix. I think I see a market niche here for a book on
>this.
There is one. It's called "Learning Perl on Win32 systems".
<http://www.oreilly.com/catalog/lperlwin/>
It's a Win32 version of one of the better books for learning Perl.
--
Bart.
------------------------------
Date: Fri, 17 Aug 2001 21:07:03 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Re: OT: Why is there so much white space in perl documentation??
Message-Id: <MPG.15e735152dc37c598977d@news.edmonton.telusplanet.net>
Bart Lateur at bart.lateur@skynet.be said...
> There is one. It's called "Learning Perl on Win32 systems".
>
> <http://www.oreilly.com/catalog/lperlwin/>
>
> It's a Win32 version of one of the better books for learning Perl.
I've looked at this book in a bookstore and at the time I looked, it
didn't seem like the kind of book I am talking about. It was essentially
the book I did buy "Learning Perl - 2nd Edition" with some Unixisms
converted into Windowxisms thrown in for good measure. It looked
like more of an attempt by O'Reilly (a great company) to re-wrap an
already existing book, give it a new title, add a few things like one new
chapter, and sell more copies. Much of it was the same as Learning Perl
- 2nd Edition. Word for word.
I was talking about a book devoted exclusively to explaining Unix
concepts in ways that a Windows programmer can easily understand. A book
that goes into the details of where to find things, how to use otherwise
Unix resources, what newsgroups to belong to, how to install a web server
on windows and develop on windows, cgywin use, Windows versions to not do
development on, database solutions and choices, how to choose a database
solution, and so on. A book not so much about Perl per se but on how to
get up to speed with Perl so as to begin programming in it in as little
time and frustration as possible. The nuts and bolts of developing a web
site with Perl scripts from a Windows platform. What to watch out for.
How to most efficiently do it.
I don't know how many times I have encountered stumbling blocks and other
things that aren't covered in most books I see. A lot of books (though
Learning Perl certainly is not one) seem to be written by technical
writers instead of programmers.
I am learning a great deal as I overcome these frustations (with the help
of everyone on CLPM of course). It is these things that I may end up
writing about. We will see....
If there was a book that could have taught me what I am learning as I go
and if I had known about it I would have considered paying $100.00+ US a
worthwhile investment to get it.
---
Carlos
www.internetsuccess.ca
*NOTE*: Internet Success is NOT yet fully operational so please don't
subscribe. Thanks.
------------------------------
Date: Fri, 17 Aug 2001 13:40:45 -0500
From: John Burris <john@cemnetwork.com>
Subject: Perl and E-mail function
Message-Id: <3B7D652D.AF28EDF1@cemnetwork.com>
I am a webmaster that has a problem. My boss wants a list server, but
the ISP we use does not allow them. We could switch ISP, but that is
not an option. My question is does anybody know of an e-mail/perl
totorial for me to read so I can write a perl program that will function
much like a list server. I need to know what modules are availabe and
if any good documentation is out there for the modules.
Thanks in advance
John Burris
webmaster
john@cemnetwork.com
------------------------------
Date: 17 Aug 2001 20:17:14 GMT
From: abigail@foad.org (Abigail)
Subject: Re: perldoc is like Greek to a beginner??
Message-Id: <slrn9nquus.ksf.abigail@alexandra.xs4all.nl>
Yves Orton (demerphq@hotmail.com) wrote on MMCMVIII September MCMXCIII in
<URL:news:74f348f7.0108170141.37eaee6b@posting.google.com>:
//
// Thanks Abigail. I'd like to have a look at this Cindarella book.
// Little problem, whats the full title? :-)
"Introduction to Automata Theory, Languages, and Computation", by John
Hopcroft and Jeffrey Ullman, (Addison-Wesley, 1979). So called because
the cover depicts a girl (putatively Cinderella) sitting in front of a
Rube Goldberg device and holding a rope coming out of it. On the back
cover, the device is in shambles after she has (inevitably) pulled on
the rope.
http://www.tuxedo.org/~esr/jargon/html/entry/Cinderella-Book.html
Abigail
--
$_ = "\112\165\163\1648\141\156\157\164\150\145\1628\120\145"
. "\162\1548\110\141\143\153\145\162\0128\177" and &japh;
sub japh {print "@_" and return if pop; split /\d/ and &japh}
------------------------------
Date: Fri, 17 Aug 2001 21:20:31 GMT
From: John Porter <johndporter@yahoo.com>
Subject: Re: Processing a scalar in the same way of a filehandle
Message-Id: <3B7D8A0D.D9F2E995@yahoo.com>
Miguel Manso wrote:
> I've a scalar with a bunch of text. I'd like to process it on the
> "paragraph" way. If it was a filehandle, I would do this:
>
> $/ = "";
> while(<FH>) {
> my $p = $_;
> }
>
> Now, I've $cnt and I'd like to be able to do the same thing.
Others have shown you how to do exactly what you asked, using
IO::Stringy. But maybe all you really wanted was this:
for my $p ( split /\n+/, $cnt ) {
...
}
--
John Porter
------------------------------
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 1553
***************************************