[9192] in Perl-Users-Digest
Perl-Users Digest, Issue: 2809 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 4 18:07:34 1998
Date: Thu, 4 Jun 98 15:00:32 -0700
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, 4 Jun 1998 Volume: 8 Number: 2809
Today's topics:
Re: -B $file problems <rootbeer@teleport.com>
Re: -B $file problems (Larry Rosler)
??change case on FIRST letter ONLY in a word?? <tag@io.com>
Re: ??change case on FIRST letter ONLY in a word?? (Matt Knecht)
Re: ??change case on FIRST letter ONLY in a word?? <bowlin@sirius.com>
Re: ??change case on FIRST letter ONLY in a word?? <jdporter@min.net>
Re: ??change case on FIRST letter ONLY in a word?? (I R A Aggie)
[NT]: Getting Perl CGI to work <dsanders@netxchange.com>
Re: Anyone know graphics? <rootbeer@teleport.com>
decimal arithmetic (Douglas Wilson)
Determining JPEG and GIF dimension sizes in PERL <needcrew@tiac.net>
Foreach Efficiency <p-fein@uchicago.edu>
Re: Foreach Efficiency <jdporter@min.net>
Re: HELP: Upload binary file with Perl script on WinNT <rootbeer@teleport.com>
how to pass user name and password to unix? (Simon)
Re: map in void context regarded as evil - suggestion (Kevin Reid)
mm/dd/yy to localtime value? <wthompson@jehosaphat.bbn.com>
Re: mm/dd/yy to localtime value? (I R A Aggie)
On: do{}while semantics <ajohnson@gpu.srv.ualberta.ca>
Re: On: do{}while semantics <tchrist@mox.perl.com>
Re: Perl Socket connections on NT <jay@rgrs.com>
Re: problem using LWP <jdporter@min.net>
problem using variables for waitfor in telnet module (John Kelly)
Re: problem using variables for waitfor in telnet modul (Michael J Gebis)
Re: Regex: parens inside quantifiers: can you capture a (Larry Rosler)
Re: Running Perl script on remote machine and returning <rootbeer@teleport.com>
Re: Search Engine (Bob Trieger)
Re: Search Engine <rootbeer@teleport.com>
Send message from UNIX to Windows <krige@telematik.informatik.uni-karlsruhe.de>
Re: Strange results from a script... (Jon-o Addleman)
TC Loses it! ;) [Was: Re: Why is there no "in" operator <p-fein@uchicago.edu>
Re: Unbuffered Input <tchrist@mox.perl.com>
Re: Use of HTML, POD, etc in Usenet (was: Re: map in vo <quentin@shaddam.amd.com>
Re: Why is there no "in" operator in Perl? <ajohnson@gpu.srv.ualberta.ca>
Re: Why is there no "in" operator in Perl? (Michael J Gebis)
Re: Why is there no "in" operator in Perl? <tchrist@mox.perl.com>
Re: Why is there no "in" operator in Perl? (Michael J Gebis)
Re: Why is there no "in" operator in Perl? (Clinton Pierce)
Re: Why is there no "in" operator in Perl? <bowlin@sirius.com>
Re: Why is there no "in" operator in Perl? <jll@skynet.be>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 04 Jun 1998 21:31:57 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: -B $file problems
Message-Id: <Pine.GSO.3.96.980604142439.29617I-100000@user2.teleport.com>
On Thu, 4 Jun 1998, Draco Paladin wrote:
> I am working on a DOS machine and have a file that contains a bunch of
> text (specificallt the word "Hello" 40 times) followed by a single CR
> (\r).
>
> When I test it with -B it returns true (ie that it is a binary file) but
> if that CR is anywhere else in the file it returns false (ie that it is a
> text file).
>
> Is this a problem with PERL or specifically with the DOS port of perl?
See whether you can make a short test program to demonstrate this
behavior. If you can do so, make it so that it'll run under Unix as well
as DOS. Ideally, it should be no more than about half a dozen lines of
code. Armed with that, it'll be easy to test many systems to see whether
this is truly a bug in Perl or what. Thanks!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 4 Jun 1998 14:39:43 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: -B $file problems
Message-Id: <MPG.fe0b3f6134d8e4c98969a@hplntx.hpl.hp.com>
In article <Pine.A41.3.96.980604110724.60394A-100000@unix3.UVic.CA>,
paladin@uvic.ca says...
> I have a problem with the File test operator -B.
>
> I am working on a DOS machine and have a file that contains a bunch of
> text (specificallt the word "Hello" 40 times) followed by a single CR
> (\r).
>
> When I test it with -B it returns true (ie that it is a binary file) but
> if that CR is anywhere else in the file it returns false (ie that it is a
> text file).
>
> Is this a problem with PERL or specifically with the DOS port of perl?
Apparently the heuristics used to determine the file type are failing on
that particular file. One could speculate why, but only the actual perl
code would tell.
The following is the first sentence of the comparable Unix file(1)
command:
'file' performs a series of tests on each file in an attempt to classify
it.
Note -- an 'attempt' which might well fail on your particlar file.
BTW, do you consider it 'binary' or 'text' yourself? Without even one \n
character, especially not at the end, who can tell?
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: Thu, 04 Jun 1998 15:17:09 -0500
From: "Todd A. Guillory" <tag@io.com>
Subject: ??change case on FIRST letter ONLY in a word??
Message-Id: <357700B0.CCD95042@io.com>
OK, I give up!!!
if the FIRST and ONLY first letter in an input string is lower, how do I
change it to uppercase without changing all the other letters in the string???
the s/// is literal in the replacement
input =~ s/^[a-z]{1}/[A-Z]/;
so test -> [A-Z]est
and
tr/[a-z]/[A-Z]/
replaces ALL the characters
what do I need?
Thanks
tag@io.com
------------------------------
Date: Thu, 04 Jun 1998 20:48:08 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: ??change case on FIRST letter ONLY in a word??
Message-Id: <cKDd1.347$14.2584495@news2.voicenet.com>
Todd A. Guillory <tag@io.com> wrote:
>if the FIRST and ONLY first letter in an input string is lower, how do I
>change it to uppercase without changing all the other letters in the string???
>
>what do I need?
I'm sure somebody will come up with something slicker, but this works
for me:
$str = ' some lowercase words to fix. ';
$str =~ s/\b(\w)/uc($1)/ge;
$str becomes ' Some Lowercase Words To Fix '.
--
Matt Knecht - <hex@voicenet.com>
"496620796F752063616E207265616420746869732C20796F7520686176652066
617220746F6F206D7563682074696D65206F6E20796F75722068616E6473210F"
------------------------------
Date: Thu, 04 Jun 1998 13:48:53 -0700
From: Jim Bowlin <bowlin@sirius.com>
To: tag@io.com
Subject: Re: ??change case on FIRST letter ONLY in a word??
Message-Id: <35770835.C231AE32@sirius.com>
Todd A. Guillory wrote:
>
> OK, I give up!!!
>
> if the FIRST and ONLY first letter in an input string is lower, how do I
> change it to uppercase without changing all the other letters in the string???
How about
$out = ucfirst $in;
-- Jim Bowlin
------------------------------
Date: Thu, 04 Jun 1998 21:00:57 GMT
From: John Porter <jdporter@min.net>
Subject: Re: ??change case on FIRST letter ONLY in a word??
Message-Id: <35770CA9.5BAF@min.net>
Todd A. Guillory wrote:
>
> OK, I give up!!!
>
> if the FIRST and ONLY first letter in an input string is lower, how do I
> change it to uppercase without changing all the other letters in the string???
I know it seems counterintuitive, but a cursory examination of the
relevant documentation (perlfunc) would have found a perl built-in
function named lcfirst. It might do what you want. :-)
John Porter
------------------------------
Date: Thu, 04 Jun 1998 17:39:34 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: ??change case on FIRST letter ONLY in a word??
Message-Id: <fl_aggie-0406981739340001@aggie.coaps.fsu.edu>
In article <357700B0.CCD95042@io.com>, tag@io.com wrote:
[posted && cc'd]
+ OK, I give up!!!
+
+ if the FIRST and ONLY first letter in an input string is lower, how do I
+ change it to uppercase without changing all the other letters in the string???
perlfaq4: Data: Strings
How do I capitalize all the words on one line?
Which suggests:
To make the first letter of each word upper case:
$line =~ s/\b(\w)/\U$1/g;
In your case (if you'll pardon the expression :), you'll probably want:
$line =~ s/^(\w)/\U$1/;
A couple of tests:
$a='abcdefg';
$a =~ s/^(\w)/\U$1/;
print "$a\n";
Abcdefg --- ok
$a='abc def g';
Abc def g --- ok
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>
------------------------------
Date: Thu, 04 Jun 1998 21:19:00 GMT
From: "David Sanders" <dsanders@netxchange.com>
Subject: [NT]: Getting Perl CGI to work
Message-Id: <8bEd1.130$Aj.2019876@iagnews.iagnet.net>
I recently installed Perl for Win32, and can run scripts from the
command prompt. However, when I first started trying to run sample
("Hello, world!") scripts on my IIS 4.0, it would give me, "%1 is not
a valid WinNT application". Well, I seem to have fixed that, but am
still having problems. When I try to execute the script now, the
computer just runs and runs and runs, until _I_ stop it.
Here is my sample script:
print "HTTP/1.0 200 OK\n"; print "Content-Type: text/html\n\n";
print "<HTML>\n"; print "<HEAD>\n"; print "<TITLE>Hello
World</TITLE>\n"; print "</HEAD>\n"; print "<BODY>\n"; print
"<H4>Hello World</H4>\n"; print "<P>\n"; print "Your IP Address is
$ENV{REMOTE_ADDR}.\n"; print "<P>"; print "<H5>Have a nice
day</H5>\n"; print "</BODY>\n"; print "</HTML>\n";
What is wrong???
Also, how do I set up my paths properly?
#! does not seem to work on NT, and I can't find out how to get it to
run.
Thanks in advance for your help,
Dave
------------------------------
Date: Thu, 04 Jun 1998 21:54:27 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Anyone know graphics?
Message-Id: <Pine.GSO.3.96.980604145355.29617L-100000@user2.teleport.com>
On Thu, 4 Jun 1998, BBQ wrote:
> Does anyone know of any module, system, or anything app that could help
> produce gif's or jpeg's for web output??
Yes. There are even ones which can do this for non-web output. :-)
Have you looked at the ones on CPAN?
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 04 Jun 1998 21:10:35 GMT
From: dgwilson@gte.net (Douglas Wilson)
Subject: decimal arithmetic
Message-Id: <6l71ul$is$1@gte1.gte.net>
#!/usr/local/bin/perl -w
use strict;
my $val1=119.98;
my $val2=21.00;
my $val3=140.98;
if (($val1+$val2)==$val3) {
print "Equal\n";
} else {
print "Not equal\n";
}
The above gives me "Not equal".
If I change val1&val3 or val2&val3 by .01 it'll say "Equal".
Can anyone confirm?
>uname -a
SunOS 5.5.1 Generic_103640-08 sun4u sparc SUNW,Ultra-2
> perl -v
This is perl, version 5.003 with EMBED
built under solaris at Sep 14 1996 22:39:00
+ suidperl security patch
Thanks,
Douglas Wilson
------------------------------
Date: Thu, 4 Jun 1998 17:51:25 -0400
From: "The Needham's" <needcrew@tiac.net>
Subject: Determining JPEG and GIF dimension sizes in PERL
Message-Id: <6l78l1$es4@news-central.tiac.net>
Hi,
I am trying to figure out if there is a way to determine the height and
width of a given image from within perl. I will be using only JPG and GIF
images if this helps.
Thanks in advance
Please respond to needcrew@tiac.net
Mike
------------------------------
Date: Thu, 4 Jun 1998 20:46:26 GMT
From: Peter A Fein <p-fein@uchicago.edu>
Subject: Foreach Efficiency
Message-Id: <87g1hksxnh.fsf@bj2-64.rh.uchicago.edu>
A look through the Camel's efficiency section didn't turn up anything,
so here goes:
I have some code that looks like:
foreach my $i (sort article_cmp @all_pages) {
do_stuff_with($i); # more or less
}
My inclination is that the list-generating sort only gets done once,
and therfore doing it outside the loop and storing it in a variable
which foreach then indexes would be unnecessary. Is this correct?
--
Peter Fein 773-834-6206
1005 E. 60th St. Chicago, IL 60637
p-fein@uchicago.edu http://pfein.home.ml.org/
------------------------------
Date: Thu, 04 Jun 1998 21:07:47 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Foreach Efficiency
Message-Id: <35770E46.4D7D@min.net>
Peter A Fein wrote:
>
> foreach my $i (sort article_cmp @all_pages) {
>
> My inclination is that the list-generating sort only gets done once,
> and therfore doing it outside the loop and storing it in a variable
> which foreach then indexes would be unnecessary. Is this correct?
That's a good inclination to have.
Why don't you test your hypothesis using Benchmark?
John Porter
------------------------------
Date: Thu, 04 Jun 1998 21:24:08 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: HELP: Upload binary file with Perl script on WinNT
Message-Id: <Pine.GSO.3.96.980604142034.29617H-100000@user2.teleport.com>
On Thu, 4 Jun 1998, PH wrote:
> open(OUTFILE,">$outfile");
Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.
> while ($bytesread = read(INFILE,$buffer,1024)) {
> $totalbytes += $bytesread;
> binmode OUTFILE;
You should call binmode just after opening the file. I don't _think_ that
doing it this way is necessarily wrong, but it's not using the function as
it's documented to be used.
> if ((stat $outfile)[7] < 1) {
If you only need the size, it's easier to use -s rather than stat. (But
there's nothing wrong about doing this, although you should really use a
comment so that it's clear that you're getting the size.)
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 04 Jun 1998 21:22:13 GMT
From: schoy@gte.net (Simon)
Subject: how to pass user name and password to unix?
Message-Id: <6l738g$3ji$1@gte2.gte.net>
I don't know if it is do-able. but is there a PERL command to access
files in a protected UNIX directory by passing the login name and
password? or maybe sending them with a HTTP command with parameters.
something like:
http://www.somedomain.com/protected/myfile.zip?name=john+password=xxxx
any suggestions are appreciated.
TIA, plz send response to
schoy@msm.mea.com
------------------------------
Date: Thu, 4 Jun 1998 16:51:25 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: map in void context regarded as evil - suggestion
Message-Id: <1da2i11.zonkij1kcyvggN@slip166-72-108-215.ny.us.ibm.net>
Tom Christiansen <tchrist@mox.perl.com> wrote:
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc, kpreid@ibm.net (Kevin Reid) writes:
> :Will this addition also allow this:
> :@list[$i] =~ s/foo/bar/ for ($i = 0; $i < $#list; $i++);
> ^
> ^
> ^ use -w or die;
$is_a_typo = 1;
$example = '@list[$i] =~ s/foo/bar/ for ($i = 0; $i < $#list; $i++);';
substr($example, 0, 1) = '$';
--
Kevin Reid. | Macintosh.
"I'm me." | Think different.
------------------------------
Date: Thu, 04 Jun 1998 20:32:51 GMT
From: William Thompson <wthompson@jehosaphat.bbn.com>
Subject: mm/dd/yy to localtime value?
Message-Id: <35770472.4615@jehosaphat.bbn.com>
Greetings,
I'm aware of localtime(time) and how it can be used derive
($sec,$min,$hour,$mday,$mon,$year), but given a Unix `date` format,
e.g.,
Thu Jun 4 13:35:45 EDT 1998
can someone help me derive the correct localtime (or `time`) value?
Is there a function or module that already does this?
Thanks,
Bill Thompson
thompson@bbn.com
------------------------------
Date: Thu, 04 Jun 1998 17:30:31 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: mm/dd/yy to localtime value?
Message-Id: <fl_aggie-0406981730310001@aggie.coaps.fsu.edu>
In article <35770472.4615@jehosaphat.bbn.com>, William Thompson
<wthompson@jehosaphat.bbn.com> wrote:
[posted && cc'd]
+ Thu Jun 4 13:35:45 EDT 1998
+
+ can someone help me derive the correct localtime (or `time`) value?
+ Is there a function or module that already does this?
perlfaq4: Data: Dates
How can I take a string and turn it into epoch seconds?
'perldoc perlfaq4' should provide this information.
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>
------------------------------
Date: Thu, 04 Jun 1998 14:51:44 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: On: do{}while semantics
Message-Id: <3576FAD0.7D712540@gpu.srv.ualberta.ca>
The following is a not a 'bug cry', but a slightly-less-than-brief
discussion on do{}while semantics and a little expectation
problem I had.
do{
statement1;
statement2;
}while condition
is documented in perlfunc to:
1)execute the block once before testing the condition.
2)return the result of the last statement.
now, we can see that 1 is true with:
Ex_1
$a=9;$b=100;
do{
print "inside do block: \$a=$a\n";
$a++;
}while $a==10;
print "\$a=$a \$b=$b\n"
which prints:
inside do block: $a=9
inside do block: $a=10
$a=11 $b=100
so the block was executed first when $a==9, $a was incremented
to 10, the condition tests true, the block is executed again
incrementing $a to 11 which fails the conditional test.
and we can see that 2 is true with:
Ex_2
$a=10;$b=100;
$b=do{
print "inside do block: \$a=$a\n";
$a++;
}while $a==10;
print "\$a=$a \$b=$b\n"
which prints:
inside do block: $a=10
$a=11 $b=10
so, $b was assigned the value of the last statement in the block.
but this last one masks the fact that the while condition
was actually tested *before* the block was executed, because:
Ex_3
$a=9;$b=100;
$b=do{
print "inside do block: \$a=$a\n";
$a++;
}while $a==10;
print "\$a=$a \$b=$b\n"
just prints:
$a=9 $b=100
the block was never executed even once.
After some staring, I conclude that this is a precendence issue
introduced by the assignment operator and that it is being parsed
as:
( $b = do{BLOCK} ) while CONDITION;
rather than:
$b=(do{BLOCK} while CONDITION);
which causes a syntax error. Of course,
$b=do{do{BLOCK} while CONDITION};
parses, but then $b doesn't get the value of the last statement
in the inner do{BLOCK}. So for the behaviour I had (mistakenly,
it would seem) expected, we can use:
do{$b=do{BLOCK}}while CONDITION
giving:
Ex_3.1
$a=9;$b=100;
do{
$b=do{
print "inside do block: \$a=$a\n";
$a++;
};
}while $a==10;
print "\$a=$a \$b=$b\n"
Perhaps many others would have realized the precedence issues at
the outset---I merely assumed that the while modifier would bind
more tightly as a do{BLOCK} modifier. Truth be told, I hit this
problem while trying to be 'clever' with a somewhat more complex
problem (see where that gets you :-) and not during 'real'
programming. Nevertheless, I thought this little discussion might
be of some benefit to someone out there and perhaps prevent a
similar mistake.
regards
andrew
------------------------------
Date: 4 Jun 1998 20:14:36 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: On: do{}while semantics
Message-Id: <6l6v7c$so0$3@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Andrew Johnson <ajohnson@gpu.srv.ualberta.ca> writes:
:but this last one masks the fact that the while condition
:was actually tested *before* the block was executed, because:
That's right. IFF the postfix while/until is applying to
a do{} TERM shall it be evaluated afterwords. From perlsyn:
The while and until modifiers have the usual "while loop" semantics
(conditional evaluated first), except when applied to a do-BLOCK
(or to the now-deprecated do-SUBROUTINE statement), in which case
the block executes once before the conditional is evaluated.
: ( $b = do{BLOCK} ) while CONDITION;
:rather than:
: $b=(do{BLOCK} while CONDITION);
Of course. That's not in the grammar. Think about it.
(Actually, it looks like you have.)
:the outset---I merely assumed that the while modifier would bind
:more tightly as a do{BLOCK} modifier.
No, no. Check the yacc grammar again. You can't attach whiles and
untils willy-nilly wherever you'd like to see them in the middle of
an expression. Look for the sideff production.
Otherwise, we could have things like:
$x = f($y++ while g($y)) + g(--$x if sin($x));
which is just plain silly. That's what you were thinking
would happen, you know.
--tom
--
Just don't create a file called -rf. :-)
--Larry Wall in <11393@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: 04 Jun 1998 16:39:29 -0400
From: Jay Rogers <jay@rgrs.com>
To: stephens.42@osu.edu
Subject: Re: Perl Socket connections on NT
Message-Id: <82af7sj3zy.fsf@shell2.shore.net>
William Stephens <stephens.42@osu.edu> writes:
> I am trying to connect to a remote server using a socket from NT. I
> have the connection created and opened, but I get pure junk back (ex:
> v? v? 2? 2?) when it should and does print "User ID:" via telnet.
>
> DO any of you know what might be causing this or how to convert it to
> something readable?
Those are TELNET control characters. You can use Net::Telnet to read
and write while transparently handling those special characters for
you.
--
Jay Rogers
jay@rgrs.com
------------------------------
Date: Thu, 04 Jun 1998 20:52:23 GMT
From: John Porter <jdporter@min.net>
Subject: Re: problem using LWP
Message-Id: <35770AAA.6452@min.net>
sylviamo@my-dejanews.com wrote:
>
> D:\Projects\Tiger>perl -MLWP::Simple -e 'getprint "http://www.sn.no"'
> Can't find string terminator "'" anywhere before EOF at -e line 1.
This is a problem of nothing but your shell -- specifically, cmd.exe's
brain-dead handling of quotes on the commandline.
Try switching the quotes, so that the double-quotes are outside:
D:\Projects\Tiger>perl -MLWP::Simple -e "getprint 'http://www.sn.no'"
> # test LWP simpleuse LWP::Simple;
> $content = get("http://biz.yahoo.com/news/biotechnology.html");print $content;
> ...and it just hangs.
You sure it's not busy getting that page? Maybe you have a slow
connection.
> Don't I need to tell it somewhere how to connect to the internet? I'm using
> a proxy server--to I need to tell it to use that somewhere?
Yes; consult the UserAgent doc for the proxy() method.
(perldoc UserAgent)
There's also an envar you can set; not sure if it's documented well...
hth,
John Porter
------------------------------
Date: Thu, 04 Jun 1998 20:26:48 GMT
From: john.kelly@citicorp.com (John Kelly)
Subject: problem using variables for waitfor in telnet module
Message-Id: <357c0219.22980634@news.citicorp.com>
I'm having a problem with using a variable instead of a literal for
the waitfor
if I do:
$rem->waitfor('/CSBILL_FES: $/') or die $rem->errmsg;
it works, but if I assign a variable the prompt and do :
$rem->waitfor('/$prompt/') or die $rem->errmsg;
I get
bad match operator: Variable "$prompt" is not imported at
test_telnet_csbill.pl
I have tried many variations on this. Can I pass a variable to this
function?
Thanks
John
------------------------------
Date: 4 Jun 1998 20:45:30 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: problem using variables for waitfor in telnet module
Message-Id: <6l711a$mo5@mozo.cc.purdue.edu>
john.kelly@citicorp.com (John Kelly) writes:
}I assign a variable the prompt and do :
}$rem->waitfor('/$prompt/') or die $rem->errmsg;
}I get
}bad match operator: Variable "$prompt" is not imported at
}test_telnet_csbill.pl
}I have tried many variations on this. Can I pass a variable to this
}function?
Was one of the variations:
#untested purely speculative solution - mjg
$rem->waitfor("/$prompt/") or die $rem->errmsg;
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: Thu, 4 Jun 1998 14:24:01 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Regex: parens inside quantifiers: can you capture all of them?
Message-Id: <MPG.fe0b04b5e5cb5d9989699@hplntx.hpl.hp.com>
In article <3576DFBF.5980BBBF@matrox.com>, aqumsieh@matrox.com says...
> brian d foy wrote:
...
> True ... I was deceived by the (\w+) within the (?:) ... but why should that create a
> reference? Don't the outer brackets (?:) prevent the creating of backreferneces to
> whatever is in between??
>
> > (?: \s+ (\w+) )*
> >
> > the (\w+) does create a backreference, but since the * says to match
> >
>
> Why???
Because you asked it to: Ignore the string matched by the outer set of
parentheses, but remember the string matched by the inner set. If you
don't want that, you need another (?: instead of just ( for the econd
left parenthesis.
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: Thu, 04 Jun 1998 21:51:41 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Running Perl script on remote machine and returning result to script on current machine
Message-Id: <Pine.GSO.3.96.980604144804.29617K-100000@user2.teleport.com>
On Thu, 4 Jun 1998, Gordon Marler wrote:
> Here's where I'm stuck. I need to have the script on the central
> machine do something like this:
>
> 3. The central server script then causes the remote machine to run a
> small Perl script
If you are able to connect to the remote machine, you may be able to
use a network protocol to ask it to run your script or to do anything
else. There are several protocols available which may suit your needs.
Some of these can be easy to implement in Perl via a module.
> The difficulty seems to be with having the central server script pass
> the small hard-coded Perl script to the remote machine, run it, then
> pass the result back to the central server's script.
For security reasons, you may need to use something like Penguin to do
this. You can find Penguin on CPAN.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 04 Jun 1998 21:27:36 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: Search Engine
Message-Id: <6l73j4$v45$1@ligarius.ultra.net>
[ posted and mailed ]
"Vincent M. Probasco" <probavm@cat.com> wrote:
-> Tom, I think you misunderstood my question. I was simply looking for
-> advice on which search engine
-> to use for the following problem.
->
-> I would like the user to input some type of "Problem attributed to "
-> data and then the search engine
-> needs to return a link to a troube report. All the trouble reports are
-> in the same directory. I would prefer this search engine to be written
-> in Perl.Any advice on a fast engine would be helpfull. Thanks,
I think you misunderstood. c.l.p.m is perl programmers discussing perl issues
and functions with other perl programmers. Not some kind of welfare for people
looking for program handouts.
HTH
Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-239-0341
and hang up when the recording starts. "
------------------------------
Date: Thu, 04 Jun 1998 21:47:31 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Search Engine
Message-Id: <Pine.GSO.3.96.980604143541.29617J-100000@user2.teleport.com>
On Thu, 4 Jun 1998, Vincent M. Probasco wrote:
> I would like the user to input some type of "Problem attributed to "
> data and then the search engine needs to return a link to a troube
> report. All the trouble reports are in the same directory. I would
> prefer this search engine to be written in Perl.Any advice on a fast
> engine would be helpfull.
Well, my previous advice may yet be helpful:
If you're trying to find an archive of downloadable software, though,
the search engine at Yahoo may turn out to be useful for you after
all.
This newsgroup is not necessarily the best way to _find_ software (as
opposed to writing it). Freely-available software is stored in archives
which you should be able to find via Yahoo or another source.
If you're simply looking for advice on which available software is better
to use on the web, perhaps a web-related newsgroup would be able to help
you. In fact, their FAQ may have useful information, too.
Good luck with finding the software you need!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 04 Jun 1998 22:53:32 +0200
From: William Krige <krige@telematik.informatik.uni-karlsruhe.de>
Subject: Send message from UNIX to Windows
Message-Id: <3577094B.D409706E@telematik.informatik.uni-karlsruhe.de>
Hi
I am looking for some help in connection with sending information to a
port. I am running a PERL script which monitors UNIX log files. If the
script detects any irregularities, it sends the System administrator an
email message and an online message. What I want to do is to be able to
send a message from UNIX to a Windows95 or NT machine, because if the SA
doesn't have a UNIX session open on his Windows machine then he will not
receive the online message (i.e. The UNIX machine must send a message to
a specific IP adress ). I need to send a message from UNIX to Windows.
Does anyone know how to do this in PERL or does anybody possibly have
code to do this?
Your help would be greatly appreciated
Thanks
William
9435697@ml.petech.ac.za
or
krige@telematik.informatik.uni-karlsruhe.de
------------------------------
Date: Thu, 04 Jun 1998 21:29:50 GMT
From: jaddle@po-box.mcgill.ca (Jon-o Addleman)
Subject: Re: Strange results from a script...
Message-Id: <35771164.15546031@news.nbnet.nb.ca>
Once upon a Thu, 04 Jun 1998 01:50:29 -0400, comdog@computerdog.com
(brian d foy) wrote:
>some things to remember:
>
> * for a null regex, m// will use the last succesfully matched
> pattern not hidden by an inner block is used. this could
> mess up your
Aha! That was the problem. I wasn't aware of that... Thanks!
One thing with your suggestion: defined() doesn't really work, because
all the values are set from the web form. The blank ones just get set
to "", but I checked it with (ne "") instead of defined and it worked
fine.
Thanks again!
Jon-o Addleman
------------------------------
Date: Thu, 4 Jun 1998 20:33:29 GMT
From: Peter A Fein <p-fein@uchicago.edu>
Subject: TC Loses it! ;) [Was: Re: Why is there no "in" operator in Perl?]
Message-Id: <87hg20sy92.fsf_-_@bj2-64.rh.uchicago.edu>
Tom Christiansen <tchrist@mox.perl.com> writes:
> Essentially, the word "in" should set off a Pavlovian response
> saying
>
> +-------------------------------------------------------------+
> | HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH |
> | HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH |
> | HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH |
> | HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH |
> | HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH |
> | HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH |
> | HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH |
> | HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH |
> | HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH |
> +-------------------------------------------------------------+
Umm, whoa. ;)
--
Peter Fein 773-834-6206
1005 E. 60th St. Chicago, IL 60637
p-fein@uchicago.edu http://pfein.home.ml.org/
------------------------------
Date: 4 Jun 1998 20:01:07 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Unbuffered Input
Message-Id: <6l6ue3$so0$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
awmyers@netcom.com (Alan Myers) writes:
:Can I get perl to process input one character at a time
:without waiting for EOF?
Sure, by reading the faqqing manpage.
% man perlfaq8
...
How do I do fancy stuff with the keyboard/screen/mouse?
I can't wait for the moderated group. Can't wait.
--tom
--
Remember why the good Lord made your eyes -- Pla-gi-a-rize! --Tom Lehrer
------------------------------
Date: 04 Jun 1998 16:52:48 -0500
From: Quentin Fennessy <quentin@shaddam.amd.com>
Subject: Re: Use of HTML, POD, etc in Usenet (was: Re: map in void context regarded as evil - suggestion)
Message-Id: <ximbts8zvf3.fsf@shaddam.amd.com>
>>>>> "John" == John Porter <jdporter@min.net> writes:
John> But if we're talking about "de facto" standards -- there's
John> probably nothing in the world (of computers) that even comes
John> close to ascii. That's not to say that it's *completely*
John> universal, of course...
ASCII is wide-spread alright. And then there is kermit.
My calculator knows kermit. As a de jure standard I vote
for kermit.
--
Quentin Fennessy AMD, Austin Texas
Secret hacker rule #11 - hackers read manuals
------------------------------
Date: Thu, 04 Jun 1998 15:03:56 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Why is there no "in" operator in Perl?
Message-Id: <3576FDAC.5D29B1A2@gpu.srv.ualberta.ca>
Matt Knecht wrote:
!
! Glen Koundry <glengk@mindspring.com> wrote:
! >@l1=("ab","abc","bc");
! >
! >if("ab" in @l1) {
! > print "found ab\n";
! >}
! >
! >Is there some other language construct which serves this purpose?
! >(grep doesn't seem to be a good choice since the "ab" in the above
! >example would match "abc" as well).
!
! No, grep is what you want. You just need to anchor the regex.
!
! @arr = qw(ab abc cab);
!
! for $try (@arr) {
! my $num = grep(/^$try$/, @arr);
! print "Matched $try $num times.\n" if $num;
! }
note, though, that grep is not restricted to regular expressions
for testing, one can use an 'eq' test for improved performance:
use Benchmark;
use vars qw/@a $try $num_1 $num_2/;
@a=qw(ab abc bc de ab);
$try='ab';
$count=100000;
timethese($count,{
'regex'=>'$num_1=grep /^$try$/,@a',
'eq'=>'$num_2=grep{$_ eq $try}@a',
});
print "$num_1:$num_2\n";
Benchmark: timing 100000 iterations of eq, regex...
eq: 5 secs ( 4.14 usr 0.00 sys = 4.14 cpu)
regex: 14 secs (12.57 usr 0.00 sys = 12.57 cpu)
2:2
regards
andrew
------------------------------
Date: 4 Jun 1998 19:54:38 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Why is there no "in" operator in Perl?
Message-Id: <6l6u1u$lj2@mozo.cc.purdue.edu>
glengk@mindspring.com (Glen Koundry) writes:
}Am I missing something or does Perl lack the ability to check if
}something is part of a list, something like this:
[deletia-mjg]
}Is there some other language construct which serves this purpose?
}(grep doesn't seem to be a good choice since the "ab" in the above
}example would match "abc" as well).
Yes. Everybody just builds up a hash, like so:
@l1=("ab","abc","bc");
map { $l1_found{$_}++;} @l1;
if($l1_found{'ab'}) {
print "found ab\n";
}
If you're incredibly anal, you might want to consider the time vs.
space issue of this solution versus other solutions. Oh yeah, I can't
be sure of this, but I'm pretty sure that you have a misconception
about what the perl grep command does. (This is common, so don't feel
bad. Just read up!)
This is all covered in the faq, somewhere. In fact, here's some
unsolicited advice: March into your boss's office, and say, "Hey,
Mr. Man, I'm going to spend the rest of the afternoon reading the perl
faq. I'll be a better employee (not to mention a better person)
because of it. You got a problem with that?" You will see jillions
of cool tricks like the one above, and be a happier person overall.
You'll get a raise, and in not time flat be on a sunny beach in Hawaii
enjoying you decision to read the perl faq.
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: 4 Jun 1998 19:59:49 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Why is there no "in" operator in Perl?
Message-Id: <6l6ubl$so0$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, glengk@mindspring.com (Glen Koundry) writes:
:Am I missing something or does Perl lack the ability to check if
:something is part of a list,
You are missing having read the find perlfaq4 manpage, included on your
very system, which answers this is gorious detail. I can't
wait for the moderated group.
How can I tell whether an array contains a certain element?
Essentially, the word "in" should set off a Pavlovian response
saying
+-------------------------------------------------------------+
| HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH |
| HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH |
| HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH |
| HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH |
| HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH |
| HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH |
| HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH |
| HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH |
| HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH HASH |
+-------------------------------------------------------------+
That you should have chosen a list to represent something which
is more properly represented by a set means you already made a
bad decision, and anything else we do to help you out of this
is just throwing good money after bad--teaching pigs to sing.
Now go back and use a hash from the start.
And read the fricking manpages! Sheesh.
--tom
--
The debate rages on: Is PL/I Bactrian or Dromedary?
------------------------------
Date: 4 Jun 1998 20:14:44 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Why is there no "in" operator in Perl?
Message-Id: <6l6v7k$m2q@mozo.cc.purdue.edu>
Andrew Johnson <ajohnson@gpu.srv.ualberta.ca> writes:
}note, though, that grep is not restricted to regular expressions
}for testing, one can use an 'eq' test for improved performance:
If you care about performance, and your arrays are big, don't use a
linear search. Hash, baby, hash! (Please see tcgrep's post on this
for more copies of the word "HASH".)
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: 4 Jun 1998 19:40:57 GMT
From: cpierce1@cp500.fsic.ford.com (Clinton Pierce)
To: glengk@mindspring.com (Glen Koundry)
Subject: Re: Why is there no "in" operator in Perl?
Message-Id: <6l6t89$cd310@eccws1.dearborn.ford.com>
In article <3576f315.106536561@news.mindspring.com>,
glengk@mindspring.com (Glen Koundry) writes:
>Am I missing something or does Perl lack the ability to check if
>something is part of a list, something like this:
>
>@l1=("ab","abc","bc");
>
>if("ab" in @l1) {
> print "found ab\n";
>}
>
>
>Is there some other language construct which serves this purpose?
>(grep doesn't seem to be a good choice since the "ab" in the above
>example would match "abc" as well).
Nonsense! it's all in how ya use it:
@l1=("ab","abc","bc");
if(grep($_ eq "ab", @l1)) {
print "found ab\n";
}
The EXPR in grep doesn't HAVE to be a regular expression match...
--
+------------------------------------------------------------------------+
| Clinton A. Pierce | "If you rush a Miracle Man, | http://www. |
| cpierce1@ford.com | you get rotten miracles" | dcicorp.com/ |
| fubar@ameritech.net |--Miracle Max, The Princess Bride| ~clintp |
+------------------------------------------------------------------------+
GCSd-s+:+a-C++UALIS++++P+++L++E---t++X+b+++DI++++G++e+>++h----r+++y+++>y*
------------------------------
Date: Thu, 04 Jun 1998 14:00:12 -0700
From: Jim Bowlin <bowlin@sirius.com>
To: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Why is there no "in" operator in Perl?
Message-Id: <35770ADC.EC7E9CA0@sirius.com>
Andrew Johnson wrote:
>
> note, though, that grep is not restricted to regular expressions
> for testing, one can use an 'eq' test for improved performance:
>
> use Benchmark;
> use vars qw/@a $try $num_1 $num_2/;
> @a=qw(ab abc bc de ab);
> $try='ab';
> $count=100000;
> timethese($count,{
> 'regex'=>'$num_1=grep /^$try$/,@a',
> 'eq'=>'$num_2=grep{$_ eq $try}@a',
> });
>
> print "$num_1:$num_2\n";
>
> Benchmark: timing 100000 iterations of eq, regex...
> eq: 5 secs ( 4.14 usr 0.00 sys = 4.14 cpu)
> regex: 14 secs (12.57 usr 0.00 sys = 12.57 cpu)
> 2:2
Andrew, the test is more fair if you optimize the regular expression.
use Benchmark;
use vars qw/@a $try $num_1 $num_2 $num_3/;
@a=qw(ab abc bc de ab);
$try='ab';
$count=100000;
timethese($count,{
'/regex/o' => '$num_1 = grep /^$try$/o, @a',
'/regex/' => '$num_2 = grep /^$try$/, @a',
'eq' => '$num_3 = grep{$_ eq $try} @a',
});
print "$num_1:$num_2:$num_3\n";
Benchmark: timing 100000 iterations of /regex/, /regex/o, eq...
/regex/: 5 secs ( 4.54 usr 0.00 sys = 4.54 cpu)
/regex/o: 3 secs ( 2.40 usr 0.00 sys = 2.40 cpu)
eq: 2 secs ( 1.53 usr 0.00 sys = 1.53 cpu)
2:2:2
-- Jim Bowlin
------------------------------
Date: Thu, 04 Jun 1998 23:16:38 +0200
From: Jean-Louis Leroy <jll@skynet.be>
Subject: Re: Why is there no "in" operator in Perl?
Message-Id: <VA.00000077.00cb05e0@enterprise>
In article <6l6ubl$so0$1@csnews.cs.colorado.edu>, Tom Christiansen
wrote:
> That you should have chosen a list to represent something which
^^^^
> is more properly represented by a set means you already made a
^^^
> bad decision, and anything else we do to help you out of this
> is just throwing good money after bad--teaching pigs to sing.
> Now go back and use a hash from the start.
^^^^^^^^^^
Hmm.
Jean-Louis Leroy
http://ourworld.compuserve.com/homepages/jl_leroy/
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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 V8 Issue 2809
**************************************