[18436] in Perl-Users-Digest
Perl-Users Digest, Issue: 604 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 2 21:21:19 2001
Date: Mon, 2 Apr 2001 18:20:58 -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: <986260857-v10-i604@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 2 Apr 2001 Volume: 10 Number: 604
Today's topics:
Re: LWP & Content-Type nobull@mail.com
LWP; Response status 500: unexpected EOF before status <djmarcus@ex-pressnet.com>
Re: matrix multiplication <chrisw+usenet@dynamite.com.au>
Re: matrix multiplication (Gwyn Judd)
Re: Multidimensional Arrays? <goldbb2@earthlink.net>
RE: Multiple checkboxes <19wlr@globalnet.co.uk>
Re: Multiple checkboxes <wayne.keenan@ntlworld.com>
Re: mv - problem with renaming folder with spacing <wo_ah_ho@yahoo.com>
Re: mv - problem with renaming folder with spacing (Rafael Garcia-Suarez)
Re: Newbie: keep on matching until end of string <rick.delaney@home.com>
Re: Newbies welcome <mischief@velma.motion.net>
Opening a Textfile <jtjohnston@courrier.usherb.ca>
Re: parrot!?! <brondsem@my-deja.com>
Re: parrot!?! <chrisw+usenet@dynamite.com.au>
Re: Perl Database Question <tlav1@mediaone.net>
Re: Perl Database Question <projectobjects@earthlink.net>
Please Flame my Benchmark: open vs. cat <revjack@revjack.net>
Re: Problem with regular expression in IF statement! Pl <benpottinger@fuse.net>
Re: Problem with regular expression in IF statement! Pl <benpottinger@fuse.net>
Re: Problem with regular expression in IF statement! Pl nobull@mail.com
pseudo web browser <todd@designsouth.net>
Quark, Weird, Funky ... <hafateltec@hotmail.com>
Re: Quark, Weird, Funky ... (Tad McClellan)
Re: QUE: Serial port interrupt handling from perl <mtsouk@freemail.gr>
Re: Question: Addressing Strings? <goldbb2@earthlink.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 31 Mar 2001 12:20:22 +0100
From: nobull@mail.com
Subject: Re: LWP & Content-Type
Message-Id: <u9lmpm9ocp.fsf@wcl-l.bham.ac.uk>
I accidently answered this out-of-band. For completeness...
Andrea Maestrutti <maestrutti@libero.it> writes:
> I'd like to change the Contet-Type for the uploaded files.
> use HTTP::Request::Common;
> POST 'http://www.myhost.com/cgi-bin/receive.pl',
> Content_Type => 'form-data',
> Content => [communication => 'My documents.',
> file1 => ["/mypath/filename1",'File1.tar'],
file1 => ["/mypath/filename1",'File1.tar',Content_Type = > 'archive/tar' ],
[Note: archive/tar may not be a registered MIME type - I can't recall. ]
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Sun, 1 Apr 2001 17:10:28 -0400
From: "David J. Marcus" <djmarcus@ex-pressnet.com>
Subject: LWP; Response status 500: unexpected EOF before status line seen
Message-Id: <tcf69umqhjtc90@corp.supernews.com>
Hi
I'm using LWP to fetch a web page.
I'm doing a POST. Using Dumper($request), Dumper($agent) shows that
everything is properly set, including a timeout of 360 seconds.
Displaying the contents received, I find one line:
Client-Date: sun, ... GMT
Then the request terminates with:
Status: 500... unexpected EOF before status line seen
When I looked at the protocol handler code, it generates this message if the
read for the next line terminates with a zero-length.
What baffles me:
- the timeout of 360 seconds had not elapsed (by my stopwatch, the
elapsed time was in the neighborhood of a minute)
Dumper($agent) looks totally normal (cookies and all)
Another baffler:
- The Dumper($response) gets truncated. It shows:
bless( {
'_request' => bless( {
'_method' => 'POST',
'_headers' => bless( {
'user-agent' => ... #value ok
'accept-language' => ...
'cookie2' => '$Version=1',
'content-type' => ...
'cookie' => ....
and that is the last line. Somehow, I would have expected the rest of the
display... its as if, Dumper quit in the middle of the dump.
The output was directed into a file in append mode. Subsequent prints added
to the file correctly, so it is not a matter of not flushing the buffer.
I would appreciate any ideas:
- explanation
- how to handle/circumvent problem
-TIA
David Marcus
------------------------------
Date: Tue, 3 Apr 2001 09:04:53 +1000
From: "Chris W" <chrisw+usenet@dynamite.com.au>
Subject: Re: matrix multiplication
Message-Id: <sC7y6.4$lW5.96351@news.interact.net.au>
"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:9a9joe$9kg$2@mamenchi.zrz.TU-Berlin.DE...
> According to Gregory Toomey <gtoomey@usa.net>:
> > BTW, remember that a matrix A can represent a rotation iff det(A)=1.
> > Just look up "linear algebra" on google for reflections about a line.
>
> This is nonsense. A matrix with unit determinant can be all sorts of
> things besides a rotation. There's an additional condition required.
> Take your own advice and read up on linear algebra.
And you should read up on logical deduction. Gregory stated that all of
the matrices that represent rotation have a determinant of 1 NOT that all
matrices with a determinant of 1 respresentation rotations.
Whether this is correct or not is something I leave to those who care.
------------------------------
Date: Mon, 02 Apr 2001 23:41:59 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: matrix multiplication
Message-Id: <slrn9ci3i6.7ms.tjla@thislove.dyndns.org>
I was shocked! How could Chris W <chrisw+usenet@dynamite.com.au>
say such a terrible thing:
>"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
>news:9a9joe$9kg$2@mamenchi.zrz.TU-Berlin.DE...
>> According to Gregory Toomey <gtoomey@usa.net>:
>> > BTW, remember that a matrix A can represent a rotation iff det(A)=1.
>> > Just look up "linear algebra" on google for reflections about a line.
>>
>> This is nonsense. A matrix with unit determinant can be all sorts of
>> things besides a rotation. There's an additional condition required.
>> Take your own advice and read up on linear algebra.
>
>And you should read up on logical deduction. Gregory stated that all of
>the matrices that represent rotation have a determinant of 1 NOT that all
>matrices with a determinant of 1 respresentation rotations.
You should read up on mathematical notation. 'iff' means "if and only
if."
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Would you mind terribly much if I asked you to take your silly-assed
problem down the hall?
------------------------------
Date: Mon, 02 Apr 2001 22:14:52 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Multidimensional Arrays?
Message-Id: <3AC8FABA.A9C8A0A0@earthlink.net>
Milliwave wrote:
>
> I'm new to Perl, and have been reading about how to create a (n-row by
> 7 column) array?
> The book I have only shows me how to access a multidimensional array,
> but does not inform me how to go about creating one?
As others have said, Perl does not have true multidimensional array, but
it emulates them with references. That said, don't worry about it. The
arrays will spring into existance as needed.
For example:
my @x;
$x[$i][$j] = 4 foreach my $i (0..6) foreach my $j (0..3);
Magically makes x into a 7x4 array.
Another way of doing something like this is:
@$x[$i] = ($a, $b, $c, $d) foreach my $i (0..6);
--
Sometimes the journey *is* its own reward--but not when you're trying to
get to the bathroom in time.
------------------------------
Date: Mon, 2 Apr 2001 20:50:36 +0100
From: "John Plaxton" <19wlr@globalnet.co.uk>
Subject: RE: Multiple checkboxes
Message-Id: <tchlv9ctoi4t43@xo.supernews.co.uk>
Hi there,
A problem that I can't get my mind around!
I have got multiple checkboxes (50+) on a form with names pulled from a
datasource which means they could be anything.
How can I run through each element when the form is submitted and check if
they are checked or not?
I am using CGI.
I can do this if I know what their name properties
foreach $field (@fields) {
${$field} = $q->param($field);
}
where @fields contains a list of names, but I don't know what the names are
going to be.
Thanks in advance
John
------------------------------
Date: Mon, 02 Apr 2001 21:04:52 +0100
From: "wayne.keenan" <wayne.keenan@ntlworld.com>
Subject: Re: Multiple checkboxes
Message-Id: <3AC8DB64.A2B33295@ntlworld.com>
I'm pretty sure there's a way to enumerta the form items in CGI.
if thats not actually the case and I plucked that from the air, if you are
creating
the form in the first place, at the expense of space and time, why not
add a hidden element with the list of names?
John Plaxton wrote:
> Hi there,
>
> A problem that I can't get my mind around!
>
> I have got multiple checkboxes (50+) on a form with names pulled from a
> datasource which means they could be anything.
>
> How can I run through each element when the form is submitted and check if
> they are checked or not?
>
> I am using CGI.
>
> I can do this if I know what their name properties
>
> foreach $field (@fields) {
> ${$field} = $q->param($field);
> }
>
> where @fields contains a list of names, but I don't know what the names are
> going to be.
>
> Thanks in advance
>
> John
------------------------------
Date: Mon, 2 Apr 2001 11:31:30 -0400
From: "Jason Wong" <wo_ah_ho@yahoo.com>
Subject: Re: mv - problem with renaming folder with spacing
Message-Id: <9aa64m$ob8$1@bcrkh13.ca.nortel.com>
oh!!! Thanks
I thought rename() only works for files
Rafael Garcia-Suarez <rgarciasuarez@free.fr> wrote in message
news:slrn9ch66p.2aa.rgarciasuarez@rafael.kazibao.net...
> Jason Wong wrote in comp.lang.perl.misc:
> > I appeared to have problem with the following statement:
> > system (mv, "E:/option A", "E:/testing");
> >
> > and this seems to work fine on other directory without spacing.
> >
> > Is there alternative that I can use to rename a directory?
>
> The builtin rename() function ?
>
> --
> Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Mon, 02 Apr 2001 15:20:38 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: mv - problem with renaming folder with spacing
Message-Id: <slrn9ch66p.2aa.rgarciasuarez@rafael.kazibao.net>
Jason Wong wrote in comp.lang.perl.misc:
> I appeared to have problem with the following statement:
> system (mv, "E:/option A", "E:/testing");
>
> and this seems to work fine on other directory without spacing.
>
> Is there alternative that I can use to rename a directory?
The builtin rename() function ?
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Mon, 02 Apr 2001 12:51:12 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Newbie: keep on matching until end of string
Message-Id: <3AC86AF1.3AEA8231@home.com>
John Lin wrote:
>
> if(/START/) { pos = $+[0]; @results = /\G\s*(\w+)/g }
Another way to do this:
if(/START/g) { @results = /\G\s*(\w+)/g }
/g in scalar context prevents pos from being reset so you don't have to
explicitly set it.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Mon, 02 Apr 2001 17:32:49 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Newbies welcome
Message-Id: <tchdu1smdus5b@corp.supernews.com>
In comp.lang.perl.misc Tracy Coyle <tccoyle@chorus.net> wrote:
> Darren wrote in message
> <2xVp6.4139$t1.320148@news6-win.server.ntlworld.com>...
>>This is to all newbies on this and any other newsgroup.
>>
>>Do not ever be afraid of asking a question...
Except when it's already answered for you.
> decided in December to get back my skills. Started with C++ IDE....exactly
> who was the brain that thought giving programmers access to manipulating
> memory directly was a good idea??!! Moved to Java....someone recommended
Those who _need_ to access memory directly in programs, such as
driver programmers, OS programmers, embedded device programmers, etc
think dirct memory access is a good idea.
> This newsgroup, like the others crossposted are excellant places to learn
> and teach.
To learn and teach what is not already taught in the FAQs. When you
learn at a university, there arer these things called `prerequisite
courses', but I guess for you that means universities are bad places
to learn.
> To those that answer, thank you. To those that post, there are
> others just like you out here, to those that lurk and learn, no question is
> stupid to the 50 others with the same question...
The questions in the FAQs aren't stupid. No one says they are, otherwise
they'd probably not be in the FAQ. It's perfectly acceptable to not know
the answer to a question that's in a FAQ list. What's not acceptable is
to ask several hundred or a few thousand people to answer the same
question that was answered yesterday or that was answered on your hard
drive all along.
I have set followups to where this thread belongs: alt.dev.null;
I would have used alt.horse.dead.beating, but StuporNews doesn't
seem to carry that.
Chris
--
Christopher E. Stith
Disclaimer: Actual product may not resemble picture in ad in any way.
------------------------------
Date: Sat, 31 Mar 2001 01:45:21 -0500
From: jtjohnston <jtjohnston@courrier.usherb.ca>
Subject: Opening a Textfile
Message-Id: <3AC57D01.5D7EFF15@courrier.usherb.ca>
I want to read the first line of a text file.
$line of course can contain many lines. therefore, how can I just print
line 0 of $line?
Thanks,
John
An email post and reply would come in real handy! :o)
if (open(MYINIFILE, "$ENV{'WINDIR'}/eslcafe_smtp.txt"))
{
open(MYINIFILE, "$ENV{'WINDIR'}/eslcafe_smtp.txt");
$line=<MYINIFILE>;
print $line;
close(MYINIFILE);
exit 1;
}else{
print "nothing here";
}
------------------------------
Date: Mon, 02 Apr 2001 02:59:20 GMT
From: "Dave Brondsema" <brondsem@my-deja.com>
Subject: Re: parrot!?!
Message-Id: <cWRx6.127232$W05.24600690@news1.rdc1.mi.home.com>
"Logan Shaw" <logan@cs.utexas.edu> wrote in message
news:9a8ppd$5sj$1@boomer.cs.utexas.edu...
> In article <0vRx6.2$yi2.2520@vic.nntp.telstra.net>,
> Wyzelli <wyzelli@yahoo.com> wrote:
> >"Dave Brondsema" <brondsem@my-deja.com> wrote in message
> >news:DmRx6.127121$W05.24571769@news1.rdc1.mi.home.com...
> >> I would use dollar_underscore all the time!
> >>
> >
> >Is that pronounced "dollar underscore underscore" ?
> >
> >Just imagine talking someone through that..."No the second one is
> >spelled out, What?, NO, the first one is an underscore. NO There
> >aren't any spaces!... Just type dollar underscore underscore..." hehe
>
> From the BSD "fortune: program:
>
> "Wouldn't the sentence 'I want to put a hyphen between the words Fish
> and And and And and Chips in my Fish-And-Chips sign' have been clearer
> if quotation marks had been placed before Fish, and between Fish and
> and, and and and And, and And and and, and and and And, and And and
> and, and and and Chips, as well as after Chips?"
yes
>
> (It must be funny quotes day.)
>
> - Logan
> --
> whose? my your his her our their _its_
> who's? I'm you're he's she's we're they're _it's_
------------------------------
Date: Mon, 2 Apr 2001 15:05:40 +1000
From: "Chris W" <chrisw+usenet@dynamite.com.au>
Subject: Re: parrot!?!
Message-Id: <wOTx6.64$u15.15376@news.interact.net.au>
He he he
I guess they'll have to implement a Patch Seed Block to pass around.
------------------------------
Date: Mon, 02 Apr 2001 01:55:15 GMT
From: ted <tlav1@mediaone.net>
Subject: Re: Perl Database Question
Message-Id: <3AC806E4.43D80EA1@mediaone.net>
You could try reading all the file names into an array using the perl function
readdir. Then loop through the array to work on each file in sequence. This
has worked well for me in the past when confronted with this type of data
storage.
Hope this helps,
ted
Mike Wilson wrote:
> I have data that is being stored in cvs format, with a new file for every
> day with the date in
> the file extension.
> ALMLOG.MMDDYY.
> ie. ALMLOG.030101 ALMLOG.030201 ALMLOG.030301
> Anybody had any experience with data stored in this way.
> I was wondering if anyone knew of a DBI that would allow me to query all the
> files,
> or if I have to roll my own perl code to search through them.
> Any ideas on how to approach would be greatly appreciated.
> I have the Perl DBI book, but it only show how to query data stored in one
> CSV file.
> Thanks Mike
------------------------------
Date: Mon, 02 Apr 2001 03:54:46 GMT
From: "dkh" <projectobjects@earthlink.net>
Subject: Re: Perl Database Question
Message-Id: <aKSx6.17625$aP5.1621678@newsread2.prod.itd.earthlink.net>
I think DBMan , http://www.gossamer-threads.com, could support this kind of
searching. Also, DBD::RAM supports SQL-style queries on flat files.
regards,
dkh
http://projectperl.com
"Mike Wilson" <jmwjr@bellsouh.net> wrote in message
news:S4tx6.3835$aD4.240523@news2.atl...
> I have data that is being stored in cvs format, with a new file for every
> day with the date in
> the file extension.
> ALMLOG.MMDDYY.
> ie. ALMLOG.030101 ALMLOG.030201 ALMLOG.030301
> Anybody had any experience with data stored in this way.
> I was wondering if anyone knew of a DBI that would allow me to query all
the
> files,
> or if I have to roll my own perl code to search through them.
> Any ideas on how to approach would be greatly appreciated.
> I have the Perl DBI book, but it only show how to query data stored in one
> CSV file.
> Thanks Mike
>
>
>
------------------------------
Date: 2 Apr 2001 20:45:50 GMT
From: revjack <revjack@revjack.net>
Subject: Please Flame my Benchmark: open vs. cat
Message-Id: <9aaodu$eon$2@news1.Radix.Net>
Keywords: Hexapodia as the key insight
In order to demonstrate to my cow orkers that open() is a
wiser choice than `cat`, I ran this benchmark:
#!/usr/bin/perl
use Benchmark;
$count = 10_000;
timethese($count, {
'cat' => '$foo = `cat temp.txt`',
'open' => 'local $/; open IN, "<temp.txt"; $foo = <IN>; close IN',
});
But maybe that is not an equitable comparison. Does anyone
have any opinions as to a better set of code blocks to use
for such a comparison?
--
___________________
revjack@revjack.net
------------------------------
Date: Mon, 2 Apr 2001 20:02:34 -0700
From: "Ben P" <benpottinger@fuse.net>
Subject: Re: Problem with regular expression in IF statement! Please help!
Message-Id: <tci4tqqn3f15bb@corp.supernews.com>
Thanks for the info. After a couple of messages from here and some other
resources I found out what it was (exactly what your telling me in your
post). As far as the spelling mistakes, I only did that because I was a
little perturbed at the rude reply I got from Mr. Trammel. While helpful,
he could have been a little nicer about it (though he did end up steering me
in the correct direction, so I have to give him credit for that). thanks
again for all the answers guys..
Ben
Malcolm Dew-Jones <yf110@vtn1.victoria.tc.ca> wrote in message
news:3ac8c757@news.victoria.tc.ca...
> Ben P (benpottinger@fuse.net) wrote:
> : Actually, it returns exactly what I would see if I typed whois "insert
> : domain here" at the shell.
>
> No it doesn't. You just think it does because you have a
> misunderstanding.
>
> : What I'm curious about is why the IF always returns true.
>
> Because it's not true that system() returns what you think it does.
>
>
> I better not say more in case I make a spelling mistake.
>
>
> : Ben
>
------------------------------
Date: Sat, 31 Mar 2001 03:38:54 -0800
From: "Ben P" <benpottinger@fuse.net>
Subject: Re: Problem with regular expression in IF statement! Please help!
Message-Id: <tcb5vo9b5ujdf7@corp.supernews.com>
Actually, it returns exactly what I would see if I typed whois "insert
domain here" at the shell.
What I'm curious about is why the IF always returns true.
Ben
John Joseph Trammell <trammell@bayazid.hypersloth.invalid> wrote in message
news:slrn9c9mqv.rao.trammell@bayazid.hypersloth.net...
> On Fri, 30 Mar 2001 14:29:47 -0800, Ben P <benpottinger@fuse.net> wrote:
> > Hello everyone, sorry to make a stupid question my first post but I can
not
> > seem to figure this out (I know it has to be something simple too).
>
> To make matters worse -- you're asking the wrong question!
>
> [snip]
> > #!/usr/bin/perl -w
>
> use strict;
>
> [snip]
> > $results = system("whois $_");
> > if ($results =~ /No match for/) { print "$results\n\n\n"; }
>
> I do not think system() returns what you think it does.
>
------------------------------
Date: 31 Mar 2001 10:15:28 +0100
From: nobull@mail.com
Subject: Re: Problem with regular expression in IF statement! Please help!
Message-Id: <u9vgoqqonx.fsf@wcl-l.bham.ac.uk>
"Ben P" <benpottinger@fuse.net> jeoparpy quotes the whole of the message he's
replying to write:
> John Joseph Trammell <trammell@bayazid.hypersloth.invalid> wrote in message
> news:slrn9c9mqv.rao.trammell@bayazid.hypersloth.net...
> > On Fri, 30 Mar 2001 14:29:47 -0800, Ben P <benpottinger@fuse.net> wrote:
> > > $results = system("whois $_");
> > > if ($results =~ /No match for/) { print "$results\n\n\n"; }
> >
> > I do not think system() returns what you think it does.
> >
> Actually, it returns exactly what I would see if I typed whois "insert
> domain here" at the shell.
John's response was totally correct.
You are confusing what system() sends to STDOUT, with what it what it
returns. Please read the documentation on system(). You'll find it
not only describes the semantics of system() also mentions another Perl
builtin that actually does hve the semantics you seem to believe that
system() has.
Get into the habit of quoting the properly trimmed text you are
responding to in context. Not only does it make the overall thread
more readble and make you look less like an asshole but it also
increases the chance that you will actually read what is said carefully.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Mon, 02 Apr 2001 07:39:14 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: pseudo web browser
Message-Id: <C0Wx6.1789$C51.664600@news1.rdc1.tn.home.com>
I'm writing a program that plays bingo online for me. The url that the game
starts off with, which I need to send and get back the html so my program
can see the bingo boards, is very very long.
I tried "$result = `lynx -dump $url`, but a result never comes back. I've
tried LWP::UserAgent, but it says the site doesn't allow connections to it's
HTTP port, and sometimes i just get a "Connection timed out" error.
So my question is, how does a regular browser connect to a site and get back
a result so fast, and how can I do it the same way?
------------------------------
Date: Mon, 2 Apr 2001 17:32:56 +1000
From: "Michael R. McPherson" <hafateltec@hotmail.com>
Subject: Quark, Weird, Funky ...
Message-Id: <9a99vp02dld@enews2.newsguy.com>
Today's fun.
Here is my sub...
sub CORE_send_page {
my $template = shift(@_);
if (-e $template) {
open (TMPL, "<$template") || die "Couldn't open $template\n";
while (<TMPL>) {
my @keyword_pairs = @_;
while (scalar(@keyword_pairs) > 0){
my $keyword = shift(@keyword_pairs);
my $value = shift(@keyword_pairs);
if (defined $keyword && $keyword ne '' &&
$_=~/$keyword/) {
$value = '' if (!defined $value);
$_=~ s/$keyword/$value/g;
}
}
print;
}
close (TMPL);
}
}
Called like such...
my $can = "can";
my $cans = "cans";
CORE_send_page ("../tmpl/can.tmpl",
"_CAN", $can,
"_CANS", $cans);
can.tmpl
<body>
_CAN
_CANS
</body>
This prints on the browser:
can
cansS "<- incorrect"
my $can = "can";
my $cans = "cans";
CORE_send_page ("../tmpl/can.tmpl",
"_CANS", $cans,
"_CAN", $can);
Notice if I swap _CAN and _CANS
This prints on the browser correctly:
can
cans
Any ideas on how to fix this ?
--
##############Þ
print "\n Welcome to NEPP";$Þ=1;while ($Þ){
print "\n$Þ";$Þ++;if ($Þ == 1000) {
print "\n$Þ"."\nWell almost never ending :þ";exit;}}
##############Þ
------------------------------
Date: Mon, 2 Apr 2001 08:06:16 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Quark, Weird, Funky ...
Message-Id: <slrn9cgqpo.852.tadmc@tadmc26.august.net>
Michael R. McPherson <hafateltec@hotmail.com> wrote:
>sub CORE_send_page {
> my $template = shift(@_);
> if (-e $template) {
You could save a level of indent by just returning if it does not exist:
return 0 unless -e $template;
> open (TMPL, "<$template") || die "Couldn't open $template\n";
You should include the reason for the failure in the diag message:
open (TMPL, "<$template") || die "Couldn't open $template $!";
^^
^^
> while (<TMPL>) {
> my @keyword_pairs = @_;
> while (scalar(@keyword_pairs) > 0){
while ( @keyword_pairs ) { # this works fine too
> my $keyword = shift(@keyword_pairs);
> my $value = shift(@keyword_pairs);
> if (defined $keyword && $keyword ne '' &&
>$_=~/$keyword/) {
if ( length $keyword and /\b$keyword\b/ ) {
> $value = '' if (!defined $value);
$value = '' unless defined $value;
>Any ideas on how to fix this ?
Put word boundaries in your pattern match.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 31 Mar 2001 11:18:10 +0300
From: "Mihalis Tsoukalos" <mtsouk@freemail.gr>
Subject: Re: QUE: Serial port interrupt handling from perl
Message-Id: <9a4409$1ge0$1@ulysses.noc.ntua.gr>
Yes,
but if the device connected to the serial port of my computer starts sending
data to the serial port and there is no-one to read them (because the
program is doing something else), after some time the old data is going to
be overwriten by the new data.
Is this true?
This is what I am afraid of and I want to avoid.
thanks,
Mihalis.
wayne.keenan <wayne.keenan@ntlworld.com> wrote in message
news:3AC52338.9793DBBD@ntlworld.com...
> the chracters may come fast, but what about buffering and handshaking?
> the serial device (UART 1- 16 bytes?) & driver should handle them
transparently,
> when asked.
> although handshaking does depend on the device dangling off the outside
end.
>
> Mihalis Tsoukalos wrote:
>
> > Bbirthisel <bbirthisel@aol.com> wrote in message
> > news:20010324203647.25034.00000635@ng-cp1.aol.com...
> > > Hi Mihilis,
> > >
> > > >I want an example of how to handle serial port interrupts from perl.
> > > >If possible I want to have to possible options:
> > > >- Reading interrupt
> > > >- Writing interrupt
> > >
> > > You almost certainly don't want to implement the raw serial driver in
> > > Perl. Even I don't - Win32::CommPort talks to the driver at a rather
low
> > API
> > > level, but no where near interrupt services. But most Operating
> > > Systems already have a serial driver to do that (even the $MS ones
> > starting
> > > with W9x - earlier attempts are disparaged even within $MS).
> > >
> > > What you probably want is read_characters_if_available, and
> > > write_characters_and_let_me_know_when_done. For those, the functions
in
> > > xxx::SerialPort are a possible starting point. Versions for Windows
> > (Win32::)
> > > and POSIX-compliant (Device::). There is also
> > > serial code for the Mac - but not compatible with the ones above.
> > >
> > > -bill
> > > Making computers work in Manufacturing for over 25 years (inquiries
> > welcome)
> >
> > First of all, thanks for answering.
> >
> > Yes Bill,
> > you are right. What I want is what you 've said:
> > "What you probably want is read_characters_if_available, and
> > write_characters_and_let_me_know_when_done."
> >
> > Especially the read_characters_if_available.
> > An interrupt behaviour is exactly what I wanted, but I have to find
another
> > way to achive my purpose.
> >
> > What I want to make sure is that I won't loose any characters from the
> > serial port. This is critical to me because characters for reading may
come
> > pretty fast. So if I spend too mych time for writing then I might looose
> > data that I have to read.
> > If you have any code examples it would be very nice of you.
> > I am using the ::SerialPort perl module (SuSE Linux 7.0).
> >
> > many thanks in advance,
> > Mihalis.
------------------------------
Date: Mon, 02 Apr 2001 22:07:40 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Question: Addressing Strings?
Message-Id: <3AC8F90A.B4992BC7@earthlink.net>
Anno Siegel wrote:
>
> According to Benjamin Goldberg <goldbb2@earthlink.net>:
>
> [...]
>
> > Again, // is magical. It means match with the last nonempty
> > pattern. If you've never had any nonempty patterns in your file,
> > then it may work, but it is a bad idea to always expect this to be
> > so.
>
> Not quite. m// uses whatever regex last matched successfully, not
> just the last regex compiled.
I did not know that. Thanks!
>
> This quirk makes the otherwise attractive m// feature nearly useless.
Well, fortunatly for me, the most recent time I used it, it was in such
a manner that it behaved as desired and expected. It was something like
this:
if( $x =~ /^(.*)\b(foo|bar|baz)\b(.*)$/ and "$1$3" =~ // ) { something }
To find two occurances, in any order, or foo, bar, or baz, within $x.
> It is attractive because it gives you a way to re-use a compiled
> regex without the /o modifier. This means you can re-compile a regex
> occasionally during the run of a program. But you would want to do
> that only when parts of the regex are interpolated at run time. This
> again means that you (generally) don't know what the regex will match
> at a given time. Remember there are regexes that don't match
> anything, so there may not even be such a string. So you don't have a
> chance to reliably initialize m//.
Well, sometimes, anyway. I managed it for what I wanted, didn't I?
> Of course, these days we have qr// for that, so the point is moot.
True.
--
Sometimes the journey *is* its own reward--but not when you're trying to
get to the bathroom in time.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 604
**************************************