[28360] in Perl-Users-Digest
Perl-Users Digest, Issue: 9724 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 14 11:05:54 2006
Date: Thu, 14 Sep 2006 08:05:06 -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, 14 Sep 2006 Volume: 10 Number: 9724
Today's topics:
Re: Boolean Regexp with perlre <rvtol+news@isolution.nl>
Re: Boolean Regexp with perlre <rvtol+news@isolution.nl>
Re: How to put a single thread to sleep? <bik.mido@tiscalinet.it>
Re: How to put a single thread to sleep? <1usa@llenroc.ude.invalid>
I/O with raw disk dcruncher4@aim.com
Re: I/O with raw disk anno4000@radom.zrz.tu-berlin.de
log monitor yuetwah2000@hotmail.com
Re: log monitor <tadmc@augustmail.com>
Re: log monitor yuetwah2000@hotmail.com
Re: log monitor <mritty@gmail.com>
Re: Maximum number of sockets <bik.mido@tiscalinet.it>
Re: print cyriilic (UTF-8) characters with PERL on HTML <andreas.pfaff@swissonline.ch>
Re: print cyriilic (UTF-8) characters with PERL on HTML anno4000@radom.zrz.tu-berlin.de
Re: print cyriilic (UTF-8) characters with PERL on HTML <jurgenex@hotmail.com>
Re: Replace a line <tadmc@augustmail.com>
Simple stateful web page? carlg@libertybasic.com
Re: Simple stateful web page? <David.Squire@no.spam.from.here.au>
Re: String buffer instead of file handle? <bik.mido@tiscalinet.it>
Re: String buffer instead of file handle? <bik.mido@tiscalinet.it>
Re: username passwd expect <rvtol+news@isolution.nl>
Re: username passwd expect <josef.moellers@fujitsu-siemens.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 14 Sep 2006 08:34:30 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Boolean Regexp with perlre
Message-Id: <eeb4bc.1i8.1@news.isolution.nl>
Kevin Crosbie schreef:
> I have a string with comma separated tags:
> "a, b, c, d, e, f"
>
> It's rather easy to write something to express a boolean OR:
> a OR b OR c = (^|,(\s)+)(a|b|c)[,$]
>
> What I would like to know is if there is a way to express AND or NOT:
> 1. (a OR b) AND c
> 2. (a OR b) AND NOT c
> 3. (a OR b) AND NOT (c OR d)
>
> I imagine there is no nice way to do this without doing something like
> writing out your AND clause before and after whatever OR clause you
> are using, which would become really messy for more complicated
> expressions, but perhaps someone knows of some way to do this.
From your "before and after" I assume that 1. is true for the string "c,
a".
1. /[ab]/ and /c/
/(?:[ab].*c|c.*[ab])/
2. /[ab]/ and !/c/
/^[^c]*[ab][^c]*$/
3. /[ab]/ and !/[cd]/
/^[^cd]*[ab][^cd]*$/
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Thu, 14 Sep 2006 09:05:48 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Boolean Regexp with perlre
Message-Id: <eeb64f.18k.1@news.isolution.nl>
Kevin Crosbie schreef:
> I have a string with comma separated tags:
> "a, b, c, d, e, f"
>
> It's rather easy to write something to express a boolean OR:
> a OR b OR c = (^|,(\s)+)(a|b|c)[,$]
>
> What I would like to know is if there is a way to express AND or NOT:
> 1. (a OR b) AND c
> 2. (a OR b) AND NOT c
> 3. (a OR b) AND NOT (c OR d)
>
> I imagine there is no nice way to do this without doing something like
> writing out your AND clause before and after whatever OR clause you
> are using, which would become really messy for more complicated
> expressions, but perhaps someone knows of some way to do this.
From your "before and after" I take it that 1. should be
true for the string "c, a" (so the shown order in your example
is not productive).
If your tags all have length one, as shown:
1. /[ab]/ && /c/
/[ab].*c|c.*[ab]/
2. /[ab]/ && !/c/
/^[^c]*[ab][^c]*$/
3. /[ab]/ && !/[cd]/
/^[^cd]*[ab][^cd]*$/
If your tags can be like "foo, bar, baz, etc.",
then change "[ab]" to "\b(?:foo|bar)\b"
and "c" to "\bbaz\b" or just as well to "\b(?:baz)\b"
and "[cd]" to "\b(?:baz|etc\.)(?=,|$)".
1. /\b(?:foo|bar)\b/ && /\b(?:baz)\b/
/\b(?:foo|bar)\b.*\b(?:baz)\b|\b(?:baz)\b.*\b(?:foo|bar)\b/
2. /\b(?:foo|bar)\b/ && !/\b(?:baz)\b/
3. /\b(?:foo|bar)\b/ && !/\b(?:baz|etc\.)(?=,|$)/
Check out "(?<!pattern)" and "(?!pattern)" in perlre, if you want to
write 2. and 3. as a single regex.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 14 Sep 2006 09:58:33 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: How to put a single thread to sleep?
Message-Id: <olsgg2dr28i47dsknkup1ed4nf6ohto35u@4ax.com>
On Wed, 13 Sep 2006 18:24:46 GMT, "A. Sinan Unur"
<1usa@llenroc.ude.invalid> wrote:
>> but when I'm using Google, Groups I sometimes forget to add the space.
>
>AFAIK, you can set GG to aumatically insert a properly formatted sig.
>You are not willing to spend the time to do that. This is consistent
>with your overall behavior.
Last time I tried, it didn't. And it was only a few months ago. I did
set up a .sig that *does* work with gmail, but not when posting to
groups.
>> --
>> Ralph Moritz
>
>Then why did you omit the space on purpose this time?
>
>*PLONK*
Hey, I understand and share your point. But he's not been *that* rude!
Isn't it a little bit exaggerated?
>--
>A. Sinan Unur <1usa@llenroc.ude.invalid>
>(remove .invalid and reverse each component for email address)
>
>comp.lang.perl.misc guidelines on the WWW:
>http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
And your .sig takes more than four lines, which many people consider
impolite and contrary to netiquette...
:-P
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Thu, 14 Sep 2006 12:05:44 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: How to put a single thread to sleep?
Message-Id: <Xns983E525EDE8C0asu1cornelledu@127.0.0.1>
Michele Dondi <bik.mido@tiscalinet.it> wrote in
news:olsgg2dr28i47dsknkup1ed4nf6ohto35u@4ax.com:
> On Wed, 13 Sep 2006 18:24:46 GMT, "A. Sinan Unur"
> <1usa@llenroc.ude.invalid> wrote:
>
>>> but when I'm using Google, Groups I sometimes forget to add the
>>> space.
>>
>>AFAIK, you can set GG to aumatically insert a properly formatted sig.
>>You are not willing to spend the time to do that. This is consistent
>>with your overall behavior.
>
> Last time I tried, it didn't. And it was only a few months ago. I did
> set up a .sig that *does* work with gmail, but not when posting to
> groups.
Well, I went back and looked, and it looks like you are right about
that.
...
> And your .sig takes more than four lines, which many people consider
> impolite and contrary to netiquette...
>:-P
It is a single solitary newline in-between two blocks. It really does
not affect bandwidth consumed (it is still less than the 320 bytes taken
up by a 4 line 80 column sig). After all, the reason for the custom is
to reduce the amount of bandwidth dedicated to vanity. Half of my sig is
my email address, the other half is a link to the posting guidelines.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: 14 Sep 2006 04:57:12 -0700
From: dcruncher4@aim.com
Subject: I/O with raw disk
Message-Id: <1158235032.449083.55600@b28g2000cwb.googlegroups.com>
How can I open a raw disk file and write to it. I have to write a
program which will
write few gigs of data to both raw disk and a cooked file to compare
the write
performance.
Which functions to use for that.
Thanks.
------------------------------
Date: 14 Sep 2006 12:15:08 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: I/O with raw disk
Message-Id: <4msvecF7ofl6U1@news.dfncis.de>
<dcruncher4@aim.com> wrote in comp.lang.perl.misc:
> How can I open a raw disk file and write to it. I have to write a
"Raw disk" and "file" don't go together. A raw disk has blocks and/or
bytes but no files.
> program which will
> write few gigs of data to both raw disk and a cooked file to compare
> the write
> performance.
>
> Which functions to use for that.
That has nothing to do with Perl and everything with your OS. What is
your OS? You'd best ask that question on an OS-specific group.
Anno
------------------------------
Date: 14 Sep 2006 07:04:40 -0700
From: yuetwah2000@hotmail.com
Subject: log monitor
Message-Id: <1158242680.679947.167590@i42g2000cwa.googlegroups.com>
Hi,
I wanna write a simple perl cgi script that will imitate the behavior
of `tail -f` in unix, log entries are appended at the bottom of the
file, I want to create a page that will automatically scroll down. Can
you shed some light?
Rgds,
------------------------------
Date: Thu, 14 Sep 2006 09:10:56 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: log monitor
Message-Id: <slrnegiong.72h.tadmc@magna.augustmail.com>
yuetwah2000@hotmail.com <yuetwah2000@hotmail.com> wrote:
> I wanna write a simple perl cgi script that will imitate the behavior
> of `tail -f` in unix,
Your Question is Asked Frequently:
perldoc -q tail
How do I do a "tail -f" in perl?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 14 Sep 2006 07:32:39 -0700
From: yuetwah2000@hotmail.com
Subject: Re: log monitor
Message-Id: <1158244359.589732.15410@e3g2000cwe.googlegroups.com>
I want to find some source code that does that already, something like
/hostname/cgi-bin/tail-f?/tmp/log
Tad McClellan wrote:
> yuetwah2000@hotmail.com <yuetwah2000@hotmail.com> wrote:
>
> > I wanna write a simple perl cgi script that will imitate the behavior
> > of `tail -f` in unix,
>
>
> Your Question is Asked Frequently:
>
> perldoc -q tail
>
> How do I do a "tail -f" in perl?
>
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
------------------------------
Date: 14 Sep 2006 07:49:44 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: log monitor
Message-Id: <1158245384.191637.116860@e3g2000cwe.googlegroups.com>
yuetwah2000@hotmail.com wrote:
PLEASE DO NOT TOP POST.
>
> Tad McClellan wrote:
>
> > yuetwah2000@hotmail.com <yuetwah2000@hotmail.com> wrote:
> >
> > > I wanna write a simple perl cgi script that will imitate the behavior
> > > of `tail -f` in unix,
> >
> >
> > Your Question is Asked Frequently:
> >
> > perldoc -q tail
> >
> > How do I do a "tail -f" in perl?
>
> I want to find some source code that does that already, something like
> /hostname/cgi-bin/tail-f?/tmp/log
There is code in the answer to the FAQ that Tad pointed to you. Can
you explain what is not sufficient about it?
If you're looking for a 100% already-written script, you are in the
wrong place. This group assists people with writing and debugging
their own code, not finding others'.
Paul Lalli
------------------------------
Date: 14 Sep 2006 12:56:06 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Maximum number of sockets
Message-Id: <ogaig2ha6ark11joo0s0lrbt9pjq0f63cd@4ax.com>
On Thu, 14 Sep 2006 09:37:45 +1000, "Sisyphus"
<sisyphus1@nomail.afraid.org> wrote:
>ActiveState have patched that file (apparently in a way that breaks MinGW
[snip]
>(I'll submit a bug report about this to ActiveState.)
Well done! However I wonder wether it must be considered an actual
bug. Do they consider compatibility with MinGW a requirement of their
source code? Or is that with the actual build tool they use the only
one they consider?
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 14 Sep 2006 00:16:39 -0700
From: "andipfaff" <andreas.pfaff@swissonline.ch>
Subject: Re: print cyriilic (UTF-8) characters with PERL on HTML page
Message-Id: <1158218199.825295.187960@h48g2000cwc.googlegroups.com>
auf so eine hochn=C3=A4sige Antwort sollte man sich eigentlich den
Kommentar sparen!
- wieso fragst du nach dem problem, obwohl du noch gar nicht bis zum
Ende gelesen hast?
- wenn du die Frage nach dem Minnimum nicht verstehst, wieso
beantwortest du diese dann doch noch am Ende deines Kommentars?
- wieso soll Notepad ein Problem sein? Er ist immerhin kostenlos und
kann Unicode. Alle anderen drei Editoren, die ich probiert habe,
k=C3=B6nnen das nicht
- Ob du nun Perl oder PERL schreibst, ist mir wurscht, denn
offensichtlich hast du ja trotz der falschen Rechtschreibung kapiert,
worum es geht, oder?
- ich ben=C3=B6tige kein "binmode STDOUT, ":utf8";", es funktioniert auch
ohne
Peter J. Holzer schrieb:
> On 2006-09-13 08:59, andipfaff <andreas.pfaff@swissonline.ch> wrote:
> > beginners question: I have written a small website with a PERL script
>
> The language is called "Perl", not "PERL".
>
> > which can be viewed in 4 western european languages. Each text to be
> > displayed is stored in arrays like
> > $text1[1] =3D qq(Hallo);
> > $text1[2] =3D qq(Salut);
> > $text1[3] =3D qq(Saluti);
> > $text1[4] =3D qq(Hello);
> > and printed to STDOUT. Now I want to extend this with cyrillic
> > characters (5th language: russian). Unfortunately I have no idea how to
> > do that. I simply tried to cut&paste cyrillic letters from websites
> > like wikipedia cyrillic aplphabet, but in my Editor (DZSoft) I just get
> > a question mark when pasting. In Notepad pasting is OK, because he is
> > capable of UTF-8.
>
> So what's your problem? (Well, being forced to use notepad may count as
> a problem, but it should be good enough for a short test script)
>
>
> > What are the minimum requirements to print a cyrillic character with
> > PERL into a website?
>
> I don't think I understand the question.
>
> > The PERL script is using CGI, but HTML code is written directly:
> > print qq(Content-type: text/html\n\n
>
> You need to declare the charset in the content-type:
>
> print qq(Content-type: text/html; charset=3Dutf-8\n\n
>
> or you need to convert all non-latin-1 characters to entities.
>
> > Does anybody can give me a simple script which I can test with Notepad
> > as en editor?
>
>
> #!/usr/bin/perl
> use utf8;
> use warnings;
> use strict;
>
> my $txt =3D "=D1=8D=D0=BA=D1=80=D0=B0=D0=BD=D0=BE=D0=BF=D0=BB=D0=B0=CC=81=
=D0=BD";
>
> binmode STDOUT, ":utf8";
> print "Content-Type: text/html; charset=3Dutf-8\n";
> print "\n";
> print "<p>$txt</p>\n";
>
> hp
>
>
> --
> _ | Peter J. Holzer | > Wieso sollte man etwas erfinden was nicht
> |_|_) | Sysadmin WSR | > ist?
> | | | hjp@hjp.at | Was sonst w=C3=A4re der Sinn des Erfindens?
> __/ | http://www.hjp.at/ | -- P. Einstein u. V. Gringmuth in desd
------------------------------
Date: 14 Sep 2006 08:59:55 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: print cyriilic (UTF-8) characters with PERL on HTML page
Message-Id: <4msk0bF7ijveU1@news.dfncis.de>
andipfaff <andreas.pfaff@swissonline.ch> wrote in comp.lang.perl.misc:
Please don't top-post. Put your comments after the quoted text you're
replying to. Also, this isn't private mail, it's Usenet. Even if
your partner seems to have a German address your reply should be in
the preferred language of the group, which is English.
> auf so eine hochnäsige Antwort sollte man sich eigentlich den
> Kommentar sparen!
That would have been a good idea.
> - wieso fragst du nach dem problem, obwohl du noch gar nicht bis zum
> Ende gelesen hast?
Your problem was poorly stated.
> - wenn du die Frage nach dem Minnimum nicht verstehst, wieso
> beantwortest du diese dann doch noch am Ende deines Kommentars?
Just as poorly stated. "Printing into a website" can be done
in many different ways. Which do you intend to use?
[...]
> - Ob du nun Perl oder PERL schreibst, ist mir wurscht, denn
> offensichtlich hast du ja trotz der falschen Rechtschreibung kapiert,
> worum es geht, oder?
If you don't know to spell the language you're using, don't expect to be
taken very seriously. Just good advice for the future. For the moment
I believe you have forfeited your chances for a useful reply.
Anno
------------------------------
Date: Thu, 14 Sep 2006 14:37:21 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: print cyriilic (UTF-8) characters with PERL on HTML page
Message-Id: <BOdOg.52117$Qb2.17750@trnddc08>
andipfaff wrote:
[Unfortunately you have chosen a quoting style that makes is very difficult
to identify what are are referring to; trying to mitigate]
> auf so eine hochnäsige Antwort sollte man sich eigentlich den
> Kommentar sparen!
Considering how poorly the original question was stated IMHO it was a pretty
moderate response.
> - wieso fragst du nach dem problem, obwohl du noch gar nicht bis zum
> Ende gelesen hast?
I can only guess that you are refering to:
>> So what's your problem?
Please note that just before the OP stated:
>>> In Notepad pasting is OK, because he is capable of UTF-8.
So obviously there is no problem here except for him being forced to use
Notepad, or is there?
Besides: it is beyond me how the editor used could have any impact on how to
print something from a program.
> - wenn du die Frage nach dem Minnimum nicht verstehst, wieso
> beantwortest du diese dann doch noch am Ende deines Kommentars?
I can only guess that you are refering to the OPs question
>>> What are the minimum requirements to print a cyrillic character with
>>> PERL into a website?
and the program sample that was provided by Peter.
Well, Peter didn't answer the OPs question at all. The correct answer to the
OPs question would have been:
Your question is non-sensical because the Perl print() command always writes
to a file handle. It cannot print to a web site (whatever that is supposed
to mean!). If you are asking about which minimal format/content a web page
must have to display cyrillic characters then please ask in a newsgroup that
deals with HTML.
Peter was polishing his crystal ball and reading tea leafes to guess what
the OP may have been talking about and kindly provided that HTML
format/content although it has nothing to do with Perl. If it solves the OPs
problem is unclear because the OP really didn't say if the content/fromat of
the HTML page was his problem in the frist place.
> - wieso soll Notepad ein Problem sein? Er ist immerhin kostenlos und
> kann Unicode. Alle anderen drei Editoren, die ich probiert habe,
> können das nicht
Your choice of editor has no bearing on the execution of Perl program or its
output. Therefore even mentioning them in the original posting was a red
hering.
> - Ob du nun Perl oder PERL schreibst, ist mir wurscht, denn
> offensichtlich hast du ja trotz der falschen Rechtschreibung kapiert,
> worum es geht, oder?
Well, then I guess you don't care about "Only perl can parse Perl" (please
note the capitalization!). You problem, because it does have an important
meaning.
> - ich benötige kein "binmode STDOUT, ":utf8";", es funktioniert auch
> ohne
[Leaving the rest of the previous posting in to provide context in case I
missinterpreted the references]
> Peter J. Holzer schrieb:
>
>> On 2006-09-13 08:59, andipfaff <andreas.pfaff@swissonline.ch> wrote:
>>> beginners question: I have written a small website with a PERL
>>> script
>>
>> The language is called "Perl", not "PERL".
>>
>>> which can be viewed in 4 western european languages. Each text to be
>>> displayed is stored in arrays like
>>> $text1[1] = qq(Hallo);
>>> $text1[2] = qq(Salut);
>>> $text1[3] = qq(Saluti);
>>> $text1[4] = qq(Hello);
>>> and printed to STDOUT. Now I want to extend this with cyrillic
>>> characters (5th language: russian). Unfortunately I have no idea
>>> how to do that. I simply tried to cut&paste cyrillic letters from
>>> websites like wikipedia cyrillic aplphabet, but in my Editor
>>> (DZSoft) I just get a question mark when pasting. In Notepad
>>> pasting is OK, because he is capable of UTF-8.
>>
>> So what's your problem? (Well, being forced to use notepad may count
>> as a problem, but it should be good enough for a short test script)
>>
>>
>>> What are the minimum requirements to print a cyrillic character with
>>> PERL into a website?
>>
>> I don't think I understand the question.
>>
>>> The PERL script is using CGI, but HTML code is written directly:
>>> print qq(Content-type: text/html\n\n
>>
>> You need to declare the charset in the content-type:
>>
>> print qq(Content-type: text/html; charset=utf-8\n\n
>>
>> or you need to convert all non-latin-1 characters to entities.
>>
>>> Does anybody can give me a simple script which I can test with
>>> Notepad as en editor?
>>
>>
>> #!/usr/bin/perl
>> use utf8;
>> use warnings;
>> use strict;
>>
>> my $txt = "???????????";
>>
>> binmode STDOUT, ":utf8";
>> print "Content-Type: text/html; charset=utf-8\n";
>> print "\n";
>> print "<p>$txt</p>\n";
jue
------------------------------
Date: Thu, 14 Sep 2006 08:15:34 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Replace a line
Message-Id: <slrnegilfl.6n6.tadmc@magna.augustmail.com>
Ved <vedpsingh@gmail.com> wrote:
> I have to replace only the lines
>
> if ( dat0s0 > dat1s0) then
>
> with
>
> if ( abs(dat0s0) > abs(dat1s0)) then
-------------------------------------
#!/usr/bin/perl
use warnings;
use strict;
while ( <DATA> ) {
if ( /^\s*if.*then$/ ) {
s/(\S+)(\s*\))/abs($1)$2/; # 2nd operand
s/(\(\s*)(\S+)/$1abs($2)/; # 1st operand
}
print;
}
__DATA__
if ( dat0s0 > dat1s0) then
dat0s1 <= dat0s0 ;
dat1s1 <= dat1s0 ;
else
dat0s1 <= dat1s0 ;
dat1s1 <= dat0s0 ;
end if;
if ( dat2s0 > dat3s0) then
dat2s1 <= dat2s0 ;
dat3s1 <= dat3s0 ;
else
dat2s1 <= dat3s0;
dat3s1 <= dat2s0 ;
end if;
----
if ( dat4s0 > dat5s0) then
dat4s1 <= dat4s0 ;
dat5s1 <= dat5s0 ;
else
dat4s1 <= dat5s0;
dat5s1 <= dat4s0 ;
end if;
-------------------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 14 Sep 2006 06:49:33 -0700
From: carlg@libertybasic.com
Subject: Simple stateful web page?
Message-Id: <1158241773.737026.48310@h48g2000cwc.googlegroups.com>
How would I write a simple web app in Perl+cgi that has state? Let's
say I just want to have a web page that has an input field, an Accept
button and a Clear button. Whenever I type some text into the field
and click on Accept it concatenates the text in the field with an
existing string and displays it on the web page. So I can submit a few
words one at a time and make a sentence. Clicking the Clear button
lets me start over.
-Carl Gundel, author of Liberty BASIC
http://www.libertybasic.com
------------------------------
Date: Thu, 14 Sep 2006 14:53:17 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: Simple stateful web page?
Message-Id: <eebmse$g95$1@scorpius.csx.cam.ac.uk>
carlg@libertybasic.com wrote:
> How would I write a simple web app in Perl+cgi that has state? Let's
> say I just want to have a web page that has an input field, an Accept
> button and a Clear button. Whenever I type some text into the field
> and click on Accept it concatenates the text in the field with an
> existing string and displays it on the web page. So I can submit a few
> words one at a time and make a sentence. Clicking the Clear button
> lets me start over.
This is really a CGI programming question, not a Perl question. There
are a number of ways. You could use cookies. You could use hidden input
fields in the form.
If you want to do this in Perl, go to CPAN and check out the CGI.pm
module, and the CGI::Cookie.pm module (amongst others). They make it
easier to do what you want.
DS
------------------------------
Date: 14 Sep 2006 12:56:05 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: String buffer instead of file handle?
Message-Id: <5c8ig2dpr49hlpa8t9l0sv5vuacg4rgmcf@4ax.com>
On 13 Sep 2006 11:48:26 -0700, "Brian McCauley" <nobull67@gmail.com>
wrote:
>[1] Actually it's not completely built-in, behind the curtain open()
>actually loads a module IIRC. But please ignore the man behind the
>curtain. :-)
Indeed I've been sort-of bit in the neck by this while preparing some
example code for a PM node, specifically
<http://perlmonks.org/?node_id=572127>. Although it was not strictly
necessary I wanted to provide support for a Foo.pm module by means of
the code-in-@INC feature, as both a way to generate the code and have
everything in one single script. Again, it was a game and a proof of
concept, not a way to add to clarity! Thus in real code I would write
something like
my $mod=pop;
return undef unless $mod eq 'Foo.pm';
# return a fh to Foo.pm's contents
But in this case I wanted to be a smart dude and use a somewhat more
exhotic way to select upon 'Foo.pm'. Eventually I just used &&'s short
circuiting, so that a stripped down version of the script may be the
following:
#!/usr/bin/perl -l
use strict;
use warnings;
use lib sub {
pop eq 'Foo.pm' &&
do {
open my $fh, '<', \<<'.EOM' or die $!;
# --------------------
package Foo;
sub new { bless [], shift }
1;
# --------------------
.EOM
$fh;
};
};
use Foo;
print Foo->new;
__END__
However before getting to this I was thinking of another witty way to
return the correct filehandle if the second argument passed to the
anonymous sub is 'Foo.pm' and undef otherwise: just using hash(ref)
lookup, as in
{ 'Foo.pm' => $fh }->{ pop() };
Thus the actual code I tried first was similar to the one above with
the C<use lib> statement replaced by the following one:
use lib sub {
{ 'Foo.pm' =>
do {
open my $fh, '<', \<<'.EOM' or die $!;
# --------------------
package Foo;
sub new { bless [], shift }
1;
# --------------------
.EOM
$fh;
} }->{+pop};
};
Guess what happens when you actually try to run this?
$ ./subinc
Recursive call to Perl_load_module in PerlIO_find_layer at subinc
line 9.
BEGIN failed--compilation aborted at sunininc.pl line 22.
BEGIN failed--compilation aborted at sunininc.pl line 22.
The reason is obviously that in this case there's no short circuiting,
thus perl tries to open() anyway, which needs loading a module, which
calls the same sub for lookup, and so on...
Of course I wrote that "I've been *sort-of* bit in the neck by this"
because it is not a *real* problem and there are tons of workarounds.
Simply, it was unexpected.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 14 Sep 2006 12:56:08 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: String buffer instead of file handle?
Message-Id: <s94ig25hl8rillnj89dcopouh4umahn0lh@4ax.com>
On 13 Sep 2006 15:31:58 -0700, "danparker276@yahoo.com"
<danparker276@yahoo.com> wrote:
>" open($fh, '>', \$variable)" This would work perfect, just not the
>right version of perl.
This *should* work perfectly. But *you* say it didn't. And in a way
that clearly shows that your perl does not support thay feature. Thus
your perl must be considerably old and I recommend you to follow the
good piece of advice you've been given: i.e. upgrade it.
>And your quote:
>"> Did you do that?
>>
>> (obviously not...)"
>
>Makes me want to punch you in the face. Why do you have to be such a
>smart a**?
>I guess with a name like Tad, you're used to being picked on.
Such an attitude as yours makes me *possibly* want to punch one in the
face. Both for your refusal of listening to good suggestions after
having asked for help and for bringing a personal attack -albeit a
very weak one, due to its stupidity- as means to support your "point".
>Why does everyone have to always say "read the docs". This is
Because some people tries very hard to keep the docs up to date and
rich and helpful, maybe? Because it is the best way to teach one how
to find quickly help without bothering people with questions that do
not really deserve being asked?
>something simple I thought someone knew off the top of their head.
>Maybe I don't have to use the open function.
In fact someone knew. Most of us do. The answer is
open my $fh, '>', \$buffer or die "horribly: $!\n";
That's the first answer you got. And since it is now a standard open()
feature you've been pointed to its documentation as well. Of course
you were not strictly required to check it soon, but you definitely
should have, upon verifying that the ready made solution above didn't
work. You would have realized that the feature we pointed you to
appears not to be documented on your system. Thus you could have
realized that your system is outdated too. Then it could have been
fair to ask "how do I do it with an outdated perl?" if you *really* do
not want to update, which remains the best thing to do in any case...
>Oh yeah, and I top-posted on purpose. Everyone on this group is so
Oh! Very kind of you to make communication more difficult for everyone
here (but possibly you), for no real good reason. You will be
*PLONKED* on purpose.
Ignorance one can cope with, stupidity one can cope with. Arrogance is
just a little bit too much for me and for quite about of others here.
With this attitude you will be left alone with the "expertise" of
those who "will answer questions"...
>stuck up. .NET 2.0 blows everything away anyway. At least on their
>formus, people from microsoft will answer questions instead of "Look at
>the docs"
And who gives a fuck?!? Should this increase my consideration about
them? Should this decrease that of one of the most resourceful and
helpful newsgroups I've ever been in, namely this one?
"Give a man a fish, he'll live for a day. Teach him how to fish, he'll
tell you that he has no time to play with lines and hooks."
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Thu, 14 Sep 2006 10:07:28 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: username passwd expect
Message-Id: <eeb9q4.1bo.1@news.isolution.nl>
onlineviewer schreef:
> I have an array where @array[0] contains all the usernames and
> @array[1] contains the corresponding passwds. I am trying to use the
> expect module to send the passwd when prompted for passwd. I have the
> following so far, but i'm not sure if i am approaching this the right
> way. And the syntax for the expect object doesnt seem to be right
> either. Any suggestions? Thanks
>
> use strict;
> use Expect;
>
> foreach my $val($values[0]){
> system `useradd $val`;
> system `passwd $val`;
> my $exp = new Expect;
> $exp->send("$values[1]");
> $exp->send("$values[1]");
> }
Your question is more about how to use a multidimensional array (see
perldsc) than about Expect, so I am transfering this to clpm.
1. You are talking about @array[0], but in your code I see $values[0].
2. A hash might be more convenient (unless the storage order in the
array matters).
3. Show how you put data in your array.
4. See `perldoc -q quot` about when and why "$vars" is bad.
#!/usr/bin/perl
use warnings ;
use strict ;
use Data::Dumper ;
my @user_pass ;
while (<DATA>)
{
push @user_pass, [ /\S+/g ] ;
}
print Dumper(\@user_pass), "\n" ;
for my $row (@user_pass)
{
print $row->[0], ":\t", $row->[1], "\n" ;
}
__DATA__
john f5q*d&7d
sue Gy^u&%x8
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Thu, 14 Sep 2006 14:02:43 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: username passwd expect
Message-Id: <eebgjj$is6$1@nntp.fujitsu-siemens.com>
Dr.Ruud wrote:
> onlineviewer schreef:
>=20
>=20
>>I have an array where @array[0] contains all the usernames and
>>@array[1] contains the corresponding passwds. I am trying to use the
>>expect module to send the passwd when prompted for passwd. I have the
>>following so far, but i'm not sure if i am approaching this the right
>>way. And the syntax for the expect object doesnt seem to be right
>>either. Any suggestions? Thanks
>>
>>use strict;
>>use Expect;
>>
>>foreach my $val($values[0]){
>> system `useradd $val`;
>> system `passwd $val`;
>> my $exp =3D new Expect;
>> $exp->send("$values[1]");
>> $exp->send("$values[1]");
>> }
>=20
>=20
> Your question is more about how to use a multidimensional array (see
> perldsc) than about Expect, so I am transfering this to clpm.
Well, aamof it is also about Expect, as Onlineviewer (What does his=20
mother call him? "Onnie"?) has got it wrong from the start:
If you type "`passwd $val`", then the passwd program will be run and=20
perl will wait until it has finished. Using Expect afterwards will do no =
good.
What Onnie needs is, obviously, to first get username and passwd into=20
appropriate variables. Assume this has been done:
use warnings;
use strict;
use Expect;
my $username =3D 'josef';
my $password =3D '.grimbly123';
my $exp =3D new Expect;
$exp->spawn('passwd', $username);
my @patterns =3D (
'New password: ',
'New UNIX password: '
);
$exp->expect(5, @patterns);
$exp->send("$password\r");
@patterns =3D (
'Re-enter new password: ',
'Retype new UNIX password: '
);
$exp->expect(5, @patterns);
$exp->send("$password\r");
@patterns =3D (
'Password changed',
'passwd: all authentication tokens updated successfully.'
);
$exp->expect(5, @patterns);
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 9724
***************************************