[12820] in Perl-Users-Digest
Perl-Users Digest, Issue: 230 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 22 20:07:16 1999
Date: Thu, 22 Jul 1999 17:05:08 -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, 22 Jul 1999 Volume: 9 Number: 230
Today's topics:
Re: ****Perl tutorials!!!!**** (Anno Siegel)
Re: ****Perl tutorials!!!!**** (I R A Darth Aggie)
Re: ****Perl tutorials!!!!**** (Larry Rosler)
Re: Aliasing long expresions (Anno Siegel)
Re: Better Question re:File Parsing Difficulty (Anno Siegel)
Getting closer.. (Was Re: Help requested with my "pagin <portboy@home.com>
Help please - running Perl/CGI scripts on MS NT Persona <zigouras@mail.med.upenn.edu>
Re: long explanations wearying (was Re: Top 10 response <jbc@shell2.la.best.com>
Parse::RecDescent <adm4@acsu.buffalo.edu>
perl Expert system shells? <mkabat@ibm.net>
Re: PGP and Mail (Anno Siegel)
Problem with s//g and matching what's been replaced <chrisw@shopnow.com>
Re: Problem with s//g and matching what's been replaced (Larry Rosler)
problem with sdarg.ph? <gilmanb@vuser.union.edu>
Re: reading files on IIS4.0 (Anno Siegel)
Re: regualr expression (Larry Rosler)
Re: Retrieving NT Services mussatto@my-deja.com
Re: Retrieving NT Services (Larry Rosler)
Re: Speeding up Perl (Larry Rosler)
TextArea fields lefkogt.xp@usafa.af.mil
Using GSM modems with perl... <sklivvz@tiscalinet.it>
XML::Parser::SAX handler classes daniel_chalef@my-deja.com
Re: XML::Parser::SAX handler classes <cw@dwc.ch>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 22 Jul 1999 22:20:11 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: ****Perl tutorials!!!!****
Message-Id: <7n85er$vbv$1@lublin.zrz.tu-berlin.de>
kurumi <kurumi@foad.org> wrote in comp.lang.perl.misc:
[snipparone]
>ObCLPM: when porting ICE code to CGI.pm, I ran into code equivalent to:
> grep ($tot += $vals{$_}, sort keys %hash);
>where values %vals are integers. There's an easy five strokes you can
>cut
>off that line...
Knowing the idioms is one thing. Knowing when they apply is another...
Anno
------------------------------
Date: 22 Jul 1999 22:47:22 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: ****Perl tutorials!!!!****
Message-Id: <slrn7pf800.vek.fl_aggie@thepentagon.com>
On Thu, 22 Jul 1999 16:39:57 -0500, kurumi <kurumi@foad.org>, in
<37978FAD.54C843E2@foad.org> wrote:
+ spamoflage
Wow. A new term.
James
------------------------------
Date: Thu, 22 Jul 1999 15:56:18 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: ****Perl tutorials!!!!****
Message-Id: <MPG.12014172d15f856f989d1f@nntp.hpl.hp.com>
In article <37978FAD.54C843E2@foad.org> on Thu, 22 Jul 1999 16:39:57 -
0500, kurumi <kurumi@foad.org> says...
...
> ObCLPM: when porting ICE code to CGI.pm, I ran into code equivalent to:
> grep ($tot += $vals{$_}, sort keys %hash);
> where values %vals are integers. There's an easy five strokes you can
> cut off that line...
Five strokes off wouldn't even qualify you for the Perl Golf Finals.
$tot += $vals{$_} for keys %hash;
It's not clear why the keys of %hash are being used to retrieve from
%vals, though. On the off chance that this is wrong, try this for a
golf experience:
$tot += $_ for values %vals; # or %hash; who knows?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 22 Jul 1999 22:12:13 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Aliasing long expresions
Message-Id: <7n84vt$van$1@lublin.zrz.tu-berlin.de>
Sergio Bruno Fedi de Oro <sfedi@dc.uba.ar> wrote in comp.lang.perl.misc:
>I want to alias a long dereferencing expresion, but it doesn't work...
>
>This sub receives a reference to a hash or references to arrays [of
>scalars].
>I want to iterate over the array's elements without using the long
>dereference expresion, that's why I want to alias it (and to make it
>more mantainable too).
Why alias? You can simply dereference the array ref and assign
to an array.
>This function is exported (in case this is an issue)
>
>package ConfigIO;
>use strict;
>
>sub purgar_config ($) {
> my($ref_paquetes) = shift;
> my($paquete_actual);
> my($archivo_actual);
> my($i);
> local(*files);
replace with
my @files;
>
> foreach $paquete_actual ( keys( %$ref_paquetes ) ) {
> print "paquete: $paquete_actual\n";
> $i = 0;
>
> # Here's where I alias the array
> *files = \@{$$ref_paquetes{$paquete_actual}};
replace with
@files = @{$$ref_paquetes{$paquete_actual}};
the rest (which I snipped) should work as is.
Anno
------------------------------
Date: 22 Jul 1999 22:58:37 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Better Question re:File Parsing Difficulty
Message-Id: <7n87mt$vgl$1@lublin.zrz.tu-berlin.de>
Brian Lojeck <lojeck@mizar.usc.edu> wrote in comp.lang.perl.misc:
>Learn as if you will live forever; live as if you will die tomorrow.
Translation: Don't learn that pesky stuff now. Tomorrow is another day.
Anno
------------------------------
Date: Thu, 22 Jul 1999 22:45:32 GMT
From: Mitch <portboy@home.com>
Subject: Getting closer.. (Was Re: Help requested with my "paging" script)
Message-Id: <37972F11.FE6B317E@home.com>
Okay, I'm getting a big closer to figuring out my "paging" script.
However, I'm still having some trouble. I'm turning to you guys for
more help. FYI, I'm running on a unix box (BSD). Currently the script
works just fine by calling it like this:
perl5 page.pl 25 filename
Where 25 is the number of lines you want to show, and filename is the
name of the file.
However, when I do something like:
'cat filename | ./page.pl'
It just simply cat's the file with no 'paging'. My guess is that for
some obscure reason, the module Term::ReadKey cannot cope with piped
information. I might be wrong here, but any guidance would be great.
Here's the code I have:
#!/usr/bin/perl5
use Term::ReadKey;
use strict;
my $STANDARD_L = 20;
my($lines, @data);
if(@ARGV == 2) {
$lines = shift;
my $file = shift;
die("first arg must be digit") unless ($lines =~ m/^\d+$/);
die("second arg must be file") unless (-e $file);
open(READ, $file) or die "can't open $file";
my @data = <READ>;
close(READ);
$lines ||=$STANDARD_L;
&print_out($lines, \@data);
} else {
@data = <STDIN>;
$lines = $STANDARD_L;
&print_out($lines, \@data);
}
exit (0);
sub print_out {
my($nr, $data_ref) = @_;
for (my $i = 0; $i < @{$data_ref}; $i++)
{
if (($i % $nr == 0) && ($i != 0))
{
exit(0) unless(&more_or_quit);
}
print ${$data_ref}[$i];
}
exit(0);
}
sub more_or_quit {
#print "--- (M)ore or (Q)uit ----\n";
ReadMode 'cbreak';
my $key_pressed = ReadKey(0);
ReadMode 'normal';
return(($key_pressed =~ m/q/i) ? 0 : 1);
}
------------------------------
Date: Thu, 22 Jul 1999 19:33:46 -0400
From: Nico Zigouras <zigouras@mail.med.upenn.edu>
Subject: Help please - running Perl/CGI scripts on MS NT Personal Web Server.
Message-Id: <3797AA5A.63CCFC24@mail.med.upenn.edu>
Hi:
I know this is also a web server question, but does anyone know if you
can run CGI sscripts on MS Personal Web Server for NT? I couldn't find
any mention of CGI/Perl in the docs, just Microsoft pushing ASP.
Thanks.
------------------------------
Date: 23 Jul 1999 00:03:13 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: long explanations wearying (was Re: Top 10 responses)
Message-Id: <3797b141$0$204@nntp1.ba.best.com>
Eric The Read <emschwar@rmi.net> wrote:
>> > To answer your question Mats, it's because many newbies will never use
>> > .newbie, because they want the real answers from the folks in
>> > .professional.
>>
>> Is this a proven fact?
> Yep. See the demise of comp.unix.wizards, just to name one.
I'm not convinced on this particular point. I think it might be worth
trying comp.lang.perl.newbie. No need to add
comp.lang.perl.professional; *.misc will do for them, as it does now.
Just because a bunch of rude people flooded *.wizards with low-level
postings doesn't mean a *.newbie group wouldn't work. The examples are
apples and oranges.
True, there'd be a fair amount of misinformation floating around, and
people who don't want to stoop to interacting with the unwashed
wouldn't be there to correct it. So what? That's the nature of Usenet.
And it's like saying schoolchildren shouldn't be allowed to write
stories until they can write in complete sentences. Somehow that
strikes me as a very unPerlish notion. I'm sure I'm not alone in my
belief that the embarrassingly clueless articles I've posted here, and
the interaction that followed, have played an important role in my
ongoing education about Perl. Why should newbies be denied a chance at
the same valuable learning experience?
TomC (and lots of other pros, I'm sure) already kills any article with
'newbie' in the subject line sight-unseen; in effect they've defined
the newbie posts as off-topic for this group already. There's a
dog-in-the-manger quality to telling newbies they don't deserve to post
here, while simultaneously telling them they don't deserve their own
group, either.
c.l.p.moderated was supposed to be the solution for this. Is it too
soon to point out that it has been less than spectacularly successful
in that regard? It has.
--
John Callender
jbc@west.net
http://www.west.net/~jbc/
------------------------------
Date: Thu, 22 Jul 1999 18:12:17 -0400
From: Andrew D Matuszak <adm4@acsu.buffalo.edu>
Subject: Parse::RecDescent
Message-Id: <Pine.GSO.4.05.9907221807160.14894-100000@hercules.acsu.buffalo.edu>
Wondering if someone could give me a good hint on the following. Have
data file that needs to be read in as a hash using the Parse::RecDescent
mod. Here is what I have done, but I would like any suggestions on how to
do it more efficently.
use Parse::RecDescent;
open (FH, "/root/ISC/t/dhcpd.leases") or die "Can't open File: $!\n";
my $ip;
local %::leasehash;
$grammar =
q{
startrule: "lease" /\d+\.\d+\.\d+\.\d+/ /\{/ {$::ip= $item[2];}
| "starts" /(.*)\;/{$::leasehash{$::ip}->{'start'} = $1;}
| "ends" /(.*)\;/{$::leasehash{$::ip}->{'end'} = $1;}
| "hardware" /(.*)\;/{$::leasehash{$::ip}->{'hardware'} = $1;}
| "dns forward" /(.*)\;/{$::leasehash{$::ip}->{'dns forward'} = $1;}
| "dns reverse" /(.*)\;/{$::leasehash{$::ip}->{'dns reverse'} = $1;}
| "uid" /(.*)\;/{$::leasehash{$::ip}->{'uid'} = $1;}
| "client-hostname" /(.*)\;/{$::leasehash{$::ip}->{'name'} = $1;}
| "abandoned" {$::leasehash{$::ip}->{'abandoned'} = 1;}
| "dynamic-bootp"{$::leasehash{$::ip}->{'bootp'} = 1;}
| /\}/
| /.*/ {print "$item[1]\n";}
};
$parser = new Parse::RecDescent ($grammar) or die "Bad grammar!\n";
while (<FH>){
chomp;
defined $parser->startrule($_) or print "Bad text!\n";
}
Any suggestions on making this code any leaner?
------------------------------
Date: 22 Jul 1999 22:37:49 GMT
From: "none" <mkabat@ibm.net>
Subject: perl Expert system shells?
Message-Id: <01bed491$2fd83ec0$27b3e120@default>
Anyone know of any Perl developed expert system shells or systems? What
I'm most interested in would be an expert system that can process "if then
type rule constructs."
------------------------------
Date: 22 Jul 1999 22:32:41 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: PGP and Mail
Message-Id: <7n8669$vd9$1@lublin.zrz.tu-berlin.de>
Scratchie <upsetter@ziplink.net> wrote in comp.lang.perl.misc:
>Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>:>
>:>This seems to work fine for my purposes. Am I missing something obvious by
>:>not using Open3?
>
>: Probably not. perdoc IPC::Open3 tells you
>
>: IPC::Open3, open3 - open a process for reading, writing,
>: and error handling
>
>: Now explain why you prefer reading this on a newsgroup to reading
>: it locally.
>
>Gee, thanks so much for your help. If you read my message, you read that I
>*already* read the documentation for IPC::Open3. My question was: "The
>documentation is unclear; what are the important differences between using
>this module vs. simply opening a pipe to the program in question?" The
>only answer I've gotten so far is that "Open3 does things that open
>doesn't" but no indication of what those things might be, or when they
>might be important.
The answer to that is in my reply. open() only allows you to write
to a process or read from a process. open3() gives you both, plus
error handling. Got it?
>Do you have anything useful to add, or do you just like sniping from the
>sidelines?
My reply was useful. If you demonstrate an inability to understand
what you claim to have read you'll have to expect a remark or two
about that. Such is life on usenet.
Anno
------------------------------
Date: Thu, 22 Jul 1999 22:32:30 GMT
From: Chris Wilkes <chrisw@shopnow.com>
Subject: Problem with s//g and matching what's been replaced
Message-Id: <7n865u$7j2$1@nnrp1.deja.com>
I'm printing out a time in hour:minute:sec format and would like to pad
it with zeros in case of a single digit. Normally I would do something
like this:
$sec = "0$sec" if (length($sec) < 2);
But I wanted to be a bit tricky and work on the whole string of $hour:
$min:sec. I'm running into a slight problem with s//g, here's an
example script:
#!/usr/bin/perl -w
my $i;
my @times = qw(1:2:3 01:2:3 1:02:3 1:2:03 01:2:03);
foreach (@times) {
printf "#%-2s %-8s %-8s\n", ++$i, $_, pad($_);
}
sub pad {
local $_ = shift;
s/(^|:)(\d)($|:)/${1}0$2$3/g;
# s/^(\d):/0$1:/; s/:(\d):/:0$1:/; s/:(\d)$/:0$1/;
return $_;
}
Which yields:
#1 1:2:3 01:2:03
#2 01:2:3 01:02:3
#3 1:02:3 01:02:03
#4 1:2:03 01:2:03
#5 01:2:03 01:02:03
Which isn't quite right as I really want 01:02:03.
What I think is happening in #1 is that the substitute is replacing the
trailing ":" after the 1, when the substitute runs again on the string
it starts from after the replaced : which won't match ":2:" as it is
seeing "2:" Is this right?
Chris
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 22 Jul 1999 16:07:59 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Problem with s//g and matching what's been replaced
Message-Id: <MPG.1201442d4650a82f989d20@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7n865u$7j2$1@nnrp1.deja.com> on Thu, 22 Jul 1999 22:32:30
GMT, Chris Wilkes <chrisw@shopnow.com> says...
> I'm printing out a time in hour:minute:sec format and would like to pad
> it with zeros in case of a single digit. Normally I would do something
> like this:
> $sec = "0$sec" if (length($sec) < 2);
Ugggh!
> But I wanted to be a bit tricky and work on the whole string of $hour:
> $min:sec. I'm running into a slight problem with s//g, here's an
> example script:
Snip of nonfunctional inappropriate regex solution.
#!/usr/bin/perl -w
use striict;
my @times = qw(1:2:3 01:2:3 1:02:3 1:2:03 01:2:03);
printf "%.2d:%.2d:%.2d\n", split /:/ for @times;
__END__
You know something about s?printf; now learn more. Also learn about
'split' (though a simple regex would do in this case).
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 22 Jul 1999 19:11:56 -0400
From: Brian Gilman <gilmanb@vuser.union.edu>
Subject: problem with sdarg.ph?
Message-Id: <3797A53B.FC9D66F8@vuser.union.edu>
Hello!
I am trying to compile an example program from the book "perl
annotated archives", it uses the call
use Sys::Syslog;
in this file there is a call to stdarg.ph.......perl complains that
"Constant subroutine __need_va_list is undefined......I don't have the
slightest clue how to fix this!!! Can someone help? Thanks in advance!
Brian Gilman
------------------------------
Date: 22 Jul 1999 22:51:47 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: reading files on IIS4.0
Message-Id: <7n87a3$vfc$1@lublin.zrz.tu-berlin.de>
G&K F <zotje@my-deja.com> wrote in comp.lang.perl.misc:
>Hi,
>
>I am a newbie to Perl. I wanted to read in a simple textfile from our
>server and print out the last line of the file on a web page. I got it
>to work on an apache server, but I can't seem to connect to the file on
>our IIS server. Does anybody have any ideas.
>
>Here is the code that works in unix:
It's valid perl, so it should continue to work if it ever has.
Looks more like a server configuration problem to me, which is
outside the scope of this group.
>#!/usr/local/bin/perl
You haven't switched on warnings, and you aren't using strict.
Those are the first things to do when you run into problems.
># Program to grab a stock quote from a file
>#
>open (INFO, "../investors/testfile.txt");
>@lines = <INFO>;
>close (INFO);
>$index = $#lines;
>$stock = $lines[$index];
>print $stock;
It is unnecessary and wasteful to read the whole file into
memory. Instead of the code above you could do
my $file = '../investors/testfile.txt';
my $stock;
open( INFO, $file) or die "Can't read $file: $!\n";
while ( <INFO> ) {
$stock = $_;
}
print $stock;
>print "Content-type: text/html\n\n";
>print "<HTML><HEAD><TITLE>Stock Ticker</TITLE></HEAD><BODY>\n";
>print "<h1>Today's stock value</h1><br><br>";
>print "index is \'$stock\'<HR>";
>print "</body></html>";
>
>exit;
Faisal has already pointed out some more problems with your code.
Anno
------------------------------
Date: Thu, 22 Jul 1999 16:24:00 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: regualr expression
Message-Id: <MPG.120147e8328c3230989d21@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7n7lqj$189$1@nnrp1.deja.com> on Thu, 22 Jul 1999 17:53:28
GMT, bernd1615@my-deja.com <bernd1615@my-deja.com> says...
> the following code needs improvment :
>
> foreach $gerrit (@welo) {
> $gerrit = /(^[a-zA-Z0-9].*)\s/ ;
> @welo = grep { !/$domain eq $gerrit/ } @welo; }
It sure does. The grep in the middle of the loop is totally bizarre.
Let's forget it and work from the specification.
> @welo contains strings. I want to delete all entries of
> @welo, where $domain is equal to the characters from the begining up to
> the first \s of the string.
I'll assume that any whitespace at the beginning of the string can be
ignored.
#!/usr/local/bin/perl -w
use strict;
my @welo = ( 'foo.bar baz', 'foo.bar. baz',
' foo.bar baz', ' foo.bar. baz' );
my $domain = 'foo.bar';
@welo = grep $domain ne (split)[0], @welo;
print "@welo\n";
__END__
perldoc -f split
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 22 Jul 1999 23:02:49 GMT
From: mussatto@my-deja.com
Subject: Re: Retrieving NT Services
Message-Id: <7n87ui$86t$1@nnrp1.deja.com>
In article <3782E103.7466C028@patriot.net>,
keydet89@yahoo.com wrote:
> Wow. I sent this Giovanni guy code for this
and other things
> that he wanted and haven't heard back from him
yet...
>
> I use Win32::Lanman to get not only the service
and it's status, but
Where did you find lanman? ppm doesn't find it.
At least I'm not going crazy, Service really is
empty. I figured there's a dll missing or
something.
Bill.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 22 Jul 1999 16:38:48 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Retrieving NT Services
Message-Id: <MPG.12014b611416e948989d23@nntp.hpl.hp.com>
In article <7n87ui$86t$1@nnrp1.deja.com> on Thu, 22 Jul 1999 23:02:49
GMT, mussatto@my-deja.com <mussatto@my-deja.com> says...
> In article <3782E103.7466C028@patriot.net>,
> keydet89@yahoo.com wrote:
> > Wow. I sent this Giovanni guy code for this
> and other things
> > that he wanted and haven't heard back from him
> yet...
> >
> > I use Win32::Lanman to get not only the service
> and it's status, but
> Where did you find lanman? ppm doesn't find it.
>
> At least I'm not going crazy, Service really is
> empty. I figured there's a dll missing or
> something.
>
> Bill.
>
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
Has anyone else noticed this rash of weirdly wrapped postings, with
ridiculously short line lengths? Is it a disease at Deja.com, or what?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 22 Jul 1999 16:36:18 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Speeding up Perl
Message-Id: <MPG.12014acfc696543d989d22@nntp.hpl.hp.com>
In article <7n7og5$4is$1@campus1.mtu.edu> on 22 Jul 1999 18:39:01 GMT,
Jason Stapels <jmstapel_n0spam@mtu.edu> says...
> I wanted to double check ona few things. I did some tests and came up with
> the following...
>
> grep blah($_), @array; # fastest
> for (@array) { blah($_); } # fast
> map { blah($_); } (@array); # slow
>
> blah can be anything really, but for some reason the grep command
> actually runs through the fastest which actually surprised me.
> Is there anything I should be weary of if I use the grep command
> for doing simple loop operations on large arrays?
Yes. You should be wary of building large lists and throwing them away.
As your assertions about grep totally contradict my expectations and my
benchmark, some more explanation would be appropriate, please.
#!/usr/local/bin/perl -w
use strict;
use Benchmark;
my @array = (('x' x 20) x 1000);
sub blah { shift }
timethese(1 << (shift || 0), {
For => sub { blah($_) for @array },
Grep => sub { grep blah($_), @array },
Map => sub { map blah($_), @array },
});
__END__
Benchmark: timing 1024 iterations of For, Grep, Map...
For: 6 wallclock secs ( 5.92 usr + 0.01 sys = 5.94 CPU)
Grep: 14 wallclock secs (14.34 usr + 0.33 sys = 14.67 CPU)
Map: 14 wallclock secs (13.03 usr + 0.47 sys = 13.50 CPU)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 22 Jul 1999 22:03:35 GMT
From: lefkogt.xp@usafa.af.mil
Subject: TextArea fields
Message-Id: <7n84fh$702$1@nnrp1.deja.com>
How can we use textarea fields in forms so that people can put hard
carriage returns to separate paragraphs in a textarea field? Everytime
we do it now it adds extra record(s) per physical carriage return. We
are on Unix-flavor server. Try it at www.home-bytes.com/stratplan/ .
Click on Mission Analysis link, notice record count, click Add, enter
info , enter hard carriage returns (enter key) in first textarea ONLY
for now. If you enter say three of them you will see four records were
generated when you return to the main database screen (look at new
count). The program is an iteration of a database (ASCII) program
built by Brent Michalski from www.webreview.com. If you need to see
code let me know and I will email it to you.
Gary
gary.lefko@usafa.af.mil
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Fri, 23 Jul 1999 00:51:56 +0200
From: "Marco Cecconi" <sklivvz@tiscalinet.it>
Subject: Using GSM modems with perl...
Message-Id: <7n8764$mo$1@aquila.tiscalinet.it>
I am writing a series of perl scripts to schedule, and send GSM SMSs through
a series of com ports.
Has anything like this been done before? Where can I find some reference or
source code? I'll gladly donate the results of my efforts to CPAN :)
Cheers
Marco Cecconi
Inferentia S.p.A.
perl -e 'use Standard::Disclaimer;'
------------------------------
Date: Thu, 22 Jul 1999 23:26:40 GMT
From: daniel_chalef@my-deja.com
Subject: XML::Parser::SAX handler classes
Message-Id: <7n89b6$8jo$1@nnrp1.deja.com>
Hello
I am attempting to write a handler class for the XML::Parser::SAX
module written by Ken MacLeod.
I essentially want a method (called xmlarray) in the class to return a
hash containing the XML "path" as key for the respective character data.
I've never written perl classes before but am familiar with OO concepts.
Firstly, the class does not work when I use strict - I get:
Can't use string ("CraftSrvXML") as a HASH ref while "strict refs" in
use at CraftSrvXML.pm line 52.
Line 52 is the first reference to $self->{CUR_ELEMENT} in
start_element. Why is it seeing $self as a string when in fact it is a
reference to an anonymous hash.
Secondly, when not using strict, the module works to a small extent.
I call the module as follows from a sub:
my $trans_handler = CraftSrvXML->new;
my $parser = XML::Parser::PerlSAX->new( Handler => $trans_handler );
$parser->parse(Source => { String => $xmlstring });
my %xmlarray = $trans_handler->xmlarray;
If I call the constructor CraftSrvXML->new from another sub, using
different object names, for example:
my $conf_handler = CraftSrvXML->new;
my $confparser = XML::Parser::PerlSAX->new( Handler =>
$conf_handler );
$confparser->parse(Source => { SystemId => $configfile });
my %xmlarray = $conf_handler->xmlarray;
The array $self->{XML_ARRAY} includes the previous keys and their
values...
I'm kind of confused - surely by constructing the objects local to the
subs this sort of thing shouldn't happen?
Help would _very_ much be appreciated!
Thanks
Daniel
-- begin package --
package CraftSrvXML;
use strict;
sub new {
my ($type) = @_;
my $self = {};
$self->{CUR_ELEMENT} = undef;
$self->{XML_ARRAY} = [];
return (bless($self), $type);
}
sub start_element {
my ($self, $element) = @_;
unless ($self->{CUR_ELEMENT}) {
$self->{CUR_ELEMENT} = $element->{Name};
} else {
$self->{CUR_ELEMENT} = $self->{CUR_ELEMENT} .".". $element->{Name};
}
}
sub characters {
my ($self, $element) = @_;
unless ($element->{Data} =~ /^\s+$/) {
$element->{Data} =~ s/!\#ampersand\#/&/;
$element->{Data} =~ s/!\#greaterthan\#/>/;
$element->{Data} =~ s/!\#lessthan\#/</;
push @{ $self->{XML_ARRAY} }, $self->{CUR_ELEMENT};
push @{ $self->{XML_ARRAY} }, $element->{Data};
}
}
sub end_element {
my ($self, $element) = @_;
$self->{CUR_ELEMENT} =~ s/^(.*)\.\w+$/$1/;
# print "end $element->{Name}\n";
}
sub xmlarray {
my ($self) = @_;
return(@{ $self->{XML_ARRAY} });
}
1;
-- end package --
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Fri, 23 Jul 1999 01:51:31 +0200
From: Christoph Wernli <cw@dwc.ch>
Subject: Re: XML::Parser::SAX handler classes
Message-Id: <3797AE82.F496CA9A@dwc.ch>
Just in case there is no answer, the list is at perl-xml@lyris.activestate.com
-w
daniel_chalef@my-deja.com wrote:
>
> Hello
>
> I am attempting to write a handler class for the XML::Parser::SAX
> module written by Ken MacLeod.
>
> I essentially want a method (called xmlarray) in the class to return a
> hash containing the XML "path" as key for the respective character data.
>
> I've never written perl classes before but am familiar with OO concepts.
>
> Firstly, the class does not work when I use strict - I get:
>
> Can't use string ("CraftSrvXML") as a HASH ref while "strict refs" in
> use at CraftSrvXML.pm line 52.
>
> Line 52 is the first reference to $self->{CUR_ELEMENT} in
> start_element. Why is it seeing $self as a string when in fact it is a
> reference to an anonymous hash.
>
> Secondly, when not using strict, the module works to a small extent.
>
> I call the module as follows from a sub:
>
> my $trans_handler = CraftSrvXML->new;
> my $parser = XML::Parser::PerlSAX->new( Handler => $trans_handler );
>
> $parser->parse(Source => { String => $xmlstring });
>
> my %xmlarray = $trans_handler->xmlarray;
>
> If I call the constructor CraftSrvXML->new from another sub, using
> different object names, for example:
>
> my $conf_handler = CraftSrvXML->new;
> my $confparser = XML::Parser::PerlSAX->new( Handler =>
> $conf_handler );
>
> $confparser->parse(Source => { SystemId => $configfile });
>
> my %xmlarray = $conf_handler->xmlarray;
>
> The array $self->{XML_ARRAY} includes the previous keys and their
> values...
>
> I'm kind of confused - surely by constructing the objects local to the
> subs this sort of thing shouldn't happen?
>
> Help would _very_ much be appreciated!
>
> Thanks
> Daniel
>
> -- begin package --
>
> package CraftSrvXML;
> use strict;
>
> sub new {
> my ($type) = @_;
> my $self = {};
> $self->{CUR_ELEMENT} = undef;
> $self->{XML_ARRAY} = [];
> return (bless($self), $type);
> }
>
> sub start_element {
> my ($self, $element) = @_;
>
> unless ($self->{CUR_ELEMENT}) {
> $self->{CUR_ELEMENT} = $element->{Name};
> } else {
> $self->{CUR_ELEMENT} = $self->{CUR_ELEMENT} .".". $element->{Name};
> }
> }
>
> sub characters {
> my ($self, $element) = @_;
>
> unless ($element->{Data} =~ /^\s+$/) {
>
> $element->{Data} =~ s/!\#ampersand\#/&/;
> $element->{Data} =~ s/!\#greaterthan\#/>/;
> $element->{Data} =~ s/!\#lessthan\#/</;
>
> push @{ $self->{XML_ARRAY} }, $self->{CUR_ELEMENT};
> push @{ $self->{XML_ARRAY} }, $element->{Data};
> }
> }
>
> sub end_element {
> my ($self, $element) = @_;
>
> $self->{CUR_ELEMENT} =~ s/^(.*)\.\w+$/$1/;
> # print "end $element->{Name}\n";
> }
>
> sub xmlarray {
> my ($self) = @_;
>
> return(@{ $self->{XML_ARRAY} });
> }
>
> 1;
>
> -- end package --
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V9 Issue 230
*************************************