[19109] in Perl-Users-Digest
Perl-Users Digest, Issue: 1304 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 14 00:10:33 2001
Date: Fri, 13 Jul 2001 21:10:17 -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: <995083817-v10-i1304@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 13 Jul 2001 Volume: 10 Number: 1304
Today's topics:
Regex question <bcoon@sequenom.com>
Re: Regex question <emdee@DEMUNGEcwcom.net>
Re: Regex question <krahnj@acm.org>
Re: Regex question (Tad McClellan)
Re: Regex question <krahnj@acm.org>
Re: Shouldn't -e return FALSE instead of UNDEFINED on n (Jay Tilton)
Re: Shouldn't -e return FALSE instead of UNDEFINED on n (Tad McClellan)
Re: Shouldn't -e return FALSE instead of UNDEFINED on n (David Efflandt)
Re: Shouldn't -e return FALSE instead of UNDEFINED on n <mnemotronic@mind\no-spam/spring.com>
Sockets: What am I doing wrong? <xhotarek@fi.muni.cz>
Tentative Lightning Talk Schedule posted (Mark Jason Dominus)
Re: Where is MD5 <iltzu@sci.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 13 Jul 2001 15:10:44 -0700
From: BCC <bcoon@sequenom.com>
Subject: Regex question
Message-Id: <3B4F71E4.591AA2B9@sequenom.com>
How do I begin a match starting at a certain position?
For example, if I have:
$s = "ABC DEF GHI JKL";
And I want to match after the 8th character to extract "GHI", how do I
do this?
I looked all over usenet, and the perldocs... I found loads of info on
how to GET the position, but nothing on how to start matching from a
position without using pos().
Thanks!
Bryan
------------------------------
Date: Fri, 13 Jul 2001 22:32:57 GMT
From: Matt D <emdee@DEMUNGEcwcom.net>
Subject: Re: Regex question
Message-Id: <2jtuktg1ifbscn47o8s3fa1mlv99dtq4g3@4ax.com>
In message-id <3B4F71E4.591AA2B9@sequenom.com>
on Fri, 13 Jul 2001 15:10:44 -0700
'BCC' issued the following statement:
>How do I begin a match starting at a certain position?
>
>For example, if I have:
>$s = "ABC DEF GHI JKL";
>
>And I want to match after the 8th character to extract "GHI", how do I
>do this?
>
>I looked all over usenet, and the perldocs... I found loads of info on
>how to GET the position, but nothing on how to start matching from a
>position without using pos().
how about:
$s =~ /^.{8}(\w{3})/;
$match = $1;
HTH
------------------------------
Date: Fri, 13 Jul 2001 22:49:44 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Regex question
Message-Id: <3B4F7B0C.1FD1D817@acm.org>
BCC wrote:
>
> How do I begin a match starting at a certain position?
>
> For example, if I have:
> $s = "ABC DEF GHI JKL";
>
> And I want to match after the 8th character to extract "GHI", how do I
> do this?
>
> I looked all over usenet, and the perldocs... I found loads of info on
> how to GET the position, but nothing on how to start matching from a
> position without using pos().
if ( substr( $s, 8, 3 ) eq 'GHI' ) {
...
if ( substr( $s, 8, 3 ) =~ /^GHI$/ ) {
...
John
--
use Perl;
program
fulfillment
------------------------------
Date: Fri, 13 Jul 2001 18:42:15 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Regex question
Message-Id: <slrn9kuua7.ojk.tadmc@tadmc26.august.net>
BCC <bcoon@sequenom.com> wrote:
>How do I begin a match starting at a certain position?
>
>For example, if I have:
>$s = "ABC DEF GHI JKL";
>
>And I want to match after the 8th character to extract "GHI", how do I
>do this?
Yet another nifty trick from Randal and the Stonehenge
training materials:
Apply the pattern match to a substr().
substr($s, 7) =~ s/GHI/-->GHI<--/g;
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 14 Jul 2001 00:41:48 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Regex question
Message-Id: <3B4F954F.9802FC49@acm.org>
Tad McClellan wrote:
>
> BCC <bcoon@sequenom.com> wrote:
>
> >How do I begin a match starting at a certain position?
> >
> >For example, if I have:
> >$s = "ABC DEF GHI JKL";
> >
> >And I want to match after the 8th character to extract "GHI", how do I
^^^^^^^^^^^^^^^^^^^^^^^
> >do this?
>
> Yet another nifty trick from Randal and the Stonehenge
> training materials:
>
> Apply the pattern match to a substr().
>
> substr($s, 7) =~ s/GHI/-->GHI<--/g;
The OP wants to match _after_ the eighth character not _at_ the eighth
character.
substr($s, 8) =~ s/GHI/-->GHI<--/g;
John
--
use Perl;
program
fulfillment
------------------------------
Date: Fri, 13 Jul 2001 23:17:03 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Shouldn't -e return FALSE instead of UNDEFINED on non-existant file?
Message-Id: <3b4f7f36.36568377@news.erols.com>
On 13 Jul 2001 14:30:22 -0700, mnemotronic@yahoo.com (pt) wrote:
>it makes sense (to me) for this operator to
>actually return TRUE or FALSE.
> Is it possible for -e to ever return the FALSE value ('') ???
"The" false value? There are several different values that evaluate to
false in a logical context. undef is one of them.
I can't see why this is getting under your skin. What could you be doing
that is sensitive to whether a false value is undef or an empty string?
------------------------------
Date: Fri, 13 Jul 2001 18:46:42 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Shouldn't -e return FALSE instead of UNDEFINED on non-existant file?
Message-Id: <slrn9kuuii.ojk.tadmc@tadmc26.august.net>
pt <mnemotronic@yahoo.com> wrote:
>The generic description for the file test operators says they return 1
>for TRUE and '' for FALSE. The -e (file exists) does not return FALSE
>if the file doesn't exist, it returns UNDEFINED, as do the other -X
>operators.
> I know I'm picking at nano-nits while rowing upstream amd pissing
>into the wind here, but it makes sense (to me) for this operator to
>actually return TRUE or FALSE.
> Is it possible for -e to ever return the FALSE value ('') ???
^^^^^^^^^^^^^^^
-e *does* return a false value.
Perl does not have _the_ false value. It has several false values.
The empty string is one of Perl's false values.
undef is another of Perl's false values.
Did you maybe mean this instead:
Is it possible for -e to ever return the empty string?
??
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 14 Jul 2001 00:24:02 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: Shouldn't -e return FALSE instead of UNDEFINED on non-existant file?
Message-Id: <slrn9kv492.bsc.see-sig@typhoon.xnet.com>
On Fri, 13 Jul 2001 18:46:42 -0400, Tad McClellan <tadmc@augustmail.com> wrote:
> pt <mnemotronic@yahoo.com> wrote:
>>The generic description for the file test operators says they return 1
>>for TRUE and '' for FALSE. The -e (file exists) does not return FALSE
>>if the file doesn't exist, it returns UNDEFINED, as do the other -X
>>operators.
>> I know I'm picking at nano-nits while rowing upstream amd pissing
>>into the wind here, but it makes sense (to me) for this operator to
>>actually return TRUE or FALSE.
>> Is it possible for -e to ever return the FALSE value ('') ???
> ^^^^^^^^^^^^^^^
>
> -e *does* return a false value.
>
> Perl does not have _the_ false value. It has several false values.
>
> The empty string is one of Perl's false values.
>
> undef is another of Perl's false values.
>
>
> Did you maybe mean this instead:
>
> Is it possible for -e to ever return the empty string?
Here is one way to to that (for whatever obscure reason):
(-e $file) ? 1 : '';
--
David Efflandt (Reply-To is valid) http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Fri, 13 Jul 2001 21:39:54 -0600
From: pt <mnemotronic@mind\no-spam/spring.com>
Subject: Re: Shouldn't -e return FALSE instead of UNDEFINED on non-existant file?
Message-Id: <3B4FBF0A.6EDF0AD@mindspring.com>
Tad McClellan wrote:
> pt <mnemotronic@yahoo.com> wrote:
> >The generic description for the file test operators says they return 1
> >for TRUE and '' for FALSE. The -e (file exists) does not return FALSE
> >if the file doesn't exist, it returns UNDEFINED, as do the other -X
> >operators.
> > I know I'm picking at nano-nits while rowing upstream amd pissing
> >into the wind here, but it makes sense (to me) for this operator to
> >actually return TRUE or FALSE.
> > Is it possible for -e to ever return the FALSE value ('') ???
> ^^^^^^^^^^^^^^^
>
> -e *does* return a false value.
>
> Perl does not have _the_ false value. It has several false values.
>
Ok, what am I missing here???
This code
print 'file exists=',-e "xyzzy.plugh","\n";
causes this
file exists=Use of uninitialized value in print at f2.pl line 64 (#1)
The "-e "filename" should be either '1' or '', so the printed result
should be either 'file exists=1' or 'file exists=', right??? It seems to
be necessary to check for 'defined(-e "filename")'.
> The empty string is one of Perl's false values.
>
> undef is another of Perl's false values.
>
> Did you maybe mean this instead:
>
> Is it possible for -e to ever return the empty string?
>
> ??
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
Remove the obvious anti-spam to reply.
------------------------------
Date: Wed, 11 Jul 2001 17:05:09 GMT
From: Vit Hotarek <xhotarek@fi.muni.cz>
Subject: Sockets: What am I doing wrong?
Message-Id: <Pine.SGI.4.21.0107111850080.21489135-100000@aisa.fi.muni.cz>
Hello,
when I run the script below, it produces
desired output: response from the
$remote_host on port $port.
But the problem is, that it doesn't
end. I really have no idea how to
solve it, i tried everything.
God bless you for any help ;-)
Thank you very much.
Vit Hotarek
#!/usr/bin/perl -w
use strict;
use Socket;
my ($line);
my ($remote_host, $port, $iaddr, $paddr, $proto);
$port = 21; # FTP
$remote_host= 'put_here_any';
$iaddr = inet_aton($remote_host) or die "No host: $!\n";
$paddr = sockaddr_in($port, $iaddr);
$proto = getprotobyname('tcp');
socket(SOCK, PF_INET, SOCK_STREAM, $proto) or die "Socket: $!\n";
connect(SOCK, $paddr) or die "Connect: $!\n";
while($line = <SOCK>)
{
print $line;
}
close (SOCK) or die "Close: $!";
exit(0);
------------------------------
Date: Sat, 14 Jul 2001 03:12:29 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Tentative Lightning Talk Schedule posted
Message-Id: <3b4fb89c.2631$301@news.op.net>
Keywords: Alison, cuff, efflorescent, reflect
I have made the selections for the lightning talks session at
O'Reilly's TPC 2001. The tentative schedule (likely to change) is
available at
http://perl.plover.com/lt/tpc2001.html
Updates to this page will be made as new information arrives.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: 13 Jul 2001 22:14:15 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Where is MD5
Message-Id: <995062309.19813@itz.pp.sci.fi>
In article <1ewg0ew.11hahz21jzdvegN%otto.wyss@bluewin.ch>, Otto Wyss wrote:
>Why isn't there a
>
>perldoc *MD5*
>perldoc *
>
>to show any related modules? How can I see what modules are currently
perldoc -riX MD5
perldoc -h
perldoc perldoc
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 1304
***************************************