[11302] in Perl-Users-Digest
Perl-Users Digest, Issue: 4902 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 15 20:07:35 1999
Date: Mon, 15 Feb 99 17:00:25 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 15 Feb 1999 Volume: 8 Number: 4902
Today's topics:
Re: choosing start_element() vs. startElement() <ruby@slack.net>
Re: embedded SQL in perl? <jwarner@tivoli.com>
HELP! error: Bad name after Uname:: at shift.pl line 66 silent1@bigpond.com
Re: How do you calculate $yday if already know $mday, $ <bvis@mtv.com>
Re: installing Tk module from CPAN <lusol@Pandora.CC.Lehigh.EDU>
Re: IP Address of Client Machine <ruby@slack.net>
Re: Making a Subject Index with Perl <ebohlman@netcom.com>
MySQL Perl Interface <bosco@ipoline.com>
Re: newbie question, basepath <jwarner@tivoli.com>
Re: Parsing <bmb@ginger.libs.uga.edu>
Perl program distribution scot777@my-dejanews.com
Re: Perl program distribution <tchrist@mox.perl.com>
Re: Perl s///...can it be done in one line? (brian d foy)
Re: Perl s///...can it be done in one line? <stevenhenderson@prodigy.net>
Re: Perl s///...can it be done in one line? (Dustin Christopher Preuitt)
Re: Perl s///...can it be done in one line? (Dustin Christopher Preuitt)
reading a whole file into a string <usenet@arix.com>
Re: reading a whole file into a string <tchrist@mox.perl.com>
Re: reading a whole file into a string <marms@sandia.gov>
Re: REGEX $1, $2 ... array? <asquith@macconnect.com>
Re: REGEX $1, $2 ... array? <tchrist@mox.perl.com>
Re: REGEX $1, $2 ... array? (Ilya Zakharevich)
Re: retrieving java with pearl <ruby@slack.net>
SRC: plxload -- show what files a perl program loads <tchrist@mox.perl.com>
Re: String Compare (Randal L. Schwartz)
Re: String Compare (Andre L.)
System function call causes telnetd I/O error (David Tucker)
Re: V-day Perl Poetry <southpark@nni.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 15 Feb 1999 23:28:01 +0000
From: Murray <ruby@slack.net>
To: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: choosing start_element() vs. startElement()
Message-Id: <36C8AD81.55393847@slack.net>
My humble opinion would be to consider the focus. If it's Perl code
that is to be used primarily from a Java application, then follow the
Java rules, where as if it's Java code to be called from within Perl,
follow the Perl guidelines.
Jonathan Stowe wrote:
> In comp.lang.perl.misc Ken MacLeod <ken@bitsko.slc.ut.us> wrote:
> >
> > Please take a moment to think about and comment on issues of
> > portability of source code and design, consistency of naming within
> > the XML set of modules and the rest of Perl modules, adherence to
> > standards vs. localization, and interfacing to other languages
> through
> > things like CORBA, RPC, or other bridges.
> >
>
> I'm not entirely sure that this is an issue - as long as the
> difference is
> known i.e that certain schools prefer the OneBigNameWithCapitals
> approach
> against the obviously_more_readable_underscore_seaprated_words then it
>
> most programmers will be able to understand and implement thee
> difference.
> I for instance found myself unconsciously translating (in another
> thread)
> the javascript parseInt to the Perlish parse_int.
>
> Of course if we get into a situation where there is a sharing of the
> namespaces (which I am not aware of at present) then perhaps we will
> have
> to revisit this.
>
> A nostalgic thing comes over me regarding ICL's SCL where infact
>
> display_library_details
>
> and
>
> displaylibrarydetails
>
> became the same thing to the interpreter (as infact did DLD but thats
> something else :)
>
> /J\
> --
> Jonathan Stowe <jns@btinternet.com>
> Some of your questions answered:
> <URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
> Hastings:
> <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Mon, 15 Feb 1999 15:50:25 -0600
From: John Warner <jwarner@tivoli.com>
Subject: Re: embedded SQL in perl?
Message-Id: <36C896A0.8C6E06FB@tivoli.com>
It is pretty much the same as any other language. Take a look at DBI and
DBD::Sybase, DBD:MySQL, and DBD:ODBC at a CPAN site. I checked the University
of Illinois CPAN site which can be found at:
ftp://uiarchive.uiuc.edu/pub/lang/perl/CPAN/modules/by-module/DBD/. There are
other modules there if you need them. Be sure to carefully read the
documentation that comes with DBI and the DBD modules you install. (BTW, you
need to install DBI first and then choose the appropriate DBD module.)
After installing DBI and DBD you can then do things like:
# Connects to an Oracle server using DBD::Oracle
die "Cannot do \$dbh->connect: $DBI::errstr\n" unless $dbh =
DBI->connect($srvr,$uname,$upwd,$dbtype);
# Connects to a play MS Access db DBD::ODBC
my $dbh = DBI->connect($srvr, $srvr_db_login, $srvr_db_pwd, { RaiseError => 1
});
Notice that having the appropriate DBD module allows us to get away from the
messy db connectivity junk (it's passed off to the DBD module) and get on with
the job of solving our problem in a consistent manner regardless of what kind
of db we're running on the backend. NOTE: $srvr in both examples needs to be
a defined System DSN when running under WinNT.
The lines:
my $sqlstmt = "SELECT uid,password FROM UserInfo WHERE uid=\'$name\'";
my $sth = $dbh->prepare("$sqlstmt")or die "Cannot prepare statement:
$DBI::errstr\n";
$sth->execute;
cause the SQL statement in $sqlstmt to be executed while the following lines
catch the response from the SQL server. I'll probably get criticized for this
bit of code (I have before) because it probably isn't the most correct way in
the world to do it but it works for my little Perl based client-server test
application. One thing to be careful of, however, is watching where to use
double quotation marks (") and single quotation marks('). That one took me a
bit to figure out the exact syntax as the documentation is a little sparse on
that subject.
while (@row = $sth->fetchrow_array) {
$n = $row[0]; #name
$p = $row[1]; #password
....do stuff here...
}
...or here depending upon what you're up to...
NOTE: I can only get away with using $row[n] here because I know the format of
the data returned by the SQL statement happens to be the same order as in the
SQL statement. I don't know if that is always the expected behavior but from
my own explorations into DBI/DBD it has always been so. Does anybody know the
answer to that?
--John
amanda.leaman@atl.bluecross.ca wrote:
> Hi.
>
> We currently have c programs running on Unix that have embedded sql for
> querying our Oracle database. I would like to start programming this stuff
> in perl and am looking for documentation/examples of SQl embedded in perl.
> Is it the same as in c?
>
> Thanks
> Amanda
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 15 Feb 1999 23:12:56 GMT
From: silent1@bigpond.com
Subject: HELP! error: Bad name after Uname:: at shift.pl line 665
Message-Id: <36c89f52.2242996@news.bigpond.com>
Everytime I try to run my program I get the error:
Bad name after Uname:: at shift.pl line 665
this is line 665:
if ($csray{$Form{'Uname'}}[1] ne $Form{'Pword'}) {
}
and that exact line is in the program 8 times before then.
I can't work out what the problem is.... can anyone shed some light on
this please?
------------------------------
Date: Mon, 15 Feb 1999 17:40:53 -0600
From: "Bvis" <bvis@mtv.com>
Subject: Re: How do you calculate $yday if already know $mday, $mon and $year?
Message-Id: <7aab06$dt4$1@ionews.ionet.net>
James,
That was exactly something I was looking for! :) Tried it out and it works
great! Thanks James! :)
Tommy
I R A Aggie wrote in message ...
>On Mon, 15 Feb 1999 16:04:01 -0600, Bvis <bvis@mtv.com> wrote:
>
>+ I'm having trouble trying to figure out the day of the year if I already
>+ know the date(month,day,year). I've heard of an external module called
>+ Date::Manip , but I can't use external modules and need a built-in
function
>+ or some code to do the calculation. Anybody have any ideas? Any help is
>+ greatly appreciated. Thanks.
>
> NAME
> Time::Local - efficiently compute time from local and GMT
> time
>
> SYNOPSIS
> $time = timelocal($sec,$min,$hours,$mday,$mon,$year);
>
>So, just use this to get back an epoch time (remember to adjust the
>month, 'cause localtime and allies deal with 0-11 months!), which
>you can then feed into localtime and extract out the $yday value.
>
>Yes, technically speaking, Time::Local external to your program. It
>is part of the standard perl distribution, so you should have no
>problem accessing it.
>
>James
------------------------------
Date: 15 Feb 1999 22:09:04 GMT
From: "Stephen O. Lidie" <lusol@Pandora.CC.Lehigh.EDU>
Subject: Re: installing Tk module from CPAN
Message-Id: <7aa5u0$up2@fidoii.cc.Lehigh.EDU>
rolm@my-dejanews.com wrote:
> hi folks. i'm trying to install the Tk module for perl using:
> perl -MCPAN -e 'install Bundle::Tk;'
> everything works fine until i get to the point where the script asks
> for a wait server. since i don't know where any wait servers are off hand,
> (if you could provide a list of some, that would be great) I press return to
> select the default. immediately, i get the following error:
> commit: wrote c:/perl5/lib/CPAN/Config.pm Can't find string terminator "'"
> anywhere before EOF at -e line 1, <STDIN> chunk 23.
> other details : i'm running ActiveState perl5_005 for win32 on WinNT 4.0 (some
> may say that's my problem!) 8)
> if you have any ideas how what is causing this problem, and/or how to solve
> it, i'd be happy to hear from you!
Don;t use CPAN - rather, use PPM.
At a DOS prompt type:
ppm
ppm>install Tk
ppm>quit
------------------------------
Date: Mon, 15 Feb 1999 23:30:16 +0000
From: Murray <ruby@slack.net>
To: yyy <yyy@hotmail.com>
Subject: Re: IP Address of Client Machine
Message-Id: <36C8AE08.7257D6ED@slack.net>
Annoying, but sadly a fact of life - it's not possible.
Cookies could be a solution, or encoding an id number in the URL, but
both have their pluses and minues associated with them.
yyy wrote:
> I am currently facing a problem in obtaining IP address of a client
> machine that is sending a request to my server. I am using
> $ENV{REMOTE_ADDR} to obtain the IP address of the client. But what I
> am
> getting is the IP address of the proxy server to which the client is
> connected.
>
> Could anyone please suggest if there is a way out to get the actual IP
>
> address of the client.
>
> If possible pls reply at rjsing@hotmail.com
------------------------------
Date: Mon, 15 Feb 1999 23:05:08 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Making a Subject Index with Perl
Message-Id: <ebohlmanF77xGK.37M@netcom.com>
Eric Bohlman <ebohlman@netcom.com> wrote:
: WARNING! UNTESTED!
Definitely.
: foreach $term (split (/\//, $termlist)) {
foreach my $term ...
: foreach $term (sort keys %subjects) {
and here.
------------------------------
Date: Tue, 16 Feb 1999 00:43:08 GMT
From: Bosco Tsang <bosco@ipoline.com>
Subject: MySQL Perl Interface
Message-Id: <7aaeur$fq1$1@nnrp1.dejanews.com>
I am trying to compile and install Msql-Mysql-modules-1.2017 on RedHat 4.2
without success, according to it's INSTALL file, I've got the following error,
-----
2.) If the MySQL binaries are compiled with gcc or egcs (as the precompiled
binaries are), but your Perl is using another compiler, it is likely that
you receive an error message like the following when running "make test":
t/00base............install_driver(mysql) failed: Can't load
'../blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql:
../blib/arch/auto/DBD/mysql/mysql.so: undefined symbol: _umoddi3
at /usr/local/perl-5.005/lib/5.005/i586-linux-thread/DynaLoader.pm
line 168.
This means, that your linker doesn't include libgcc.a. You have the
following options:
a) Either recompile Perl or Mysql, it doesn't matter which. The important
thing is that you use the same compiler for both. This is definitely
the recommended solution in the long term.
b) A simple workaround is to include libgcc.a manually. Do a "make clean"
and "make" and in the output wait for a line like
LD_RUN_PATH="/usr/lib/mysql:/lib" egcs -o
../blib/arch/auto/DBD/mysql/mysql.so -shared -L/usr/local/lib
dbdimp.o mysql.o -L/usr/lib/mysql -L/usr/lib/mysql -lmysqlclient
-lm
Repeat the same line in the shell by adding
-L/usr/lib/gcc-lib/i386-redhat-linux/gcc-2.7.2.3 -lgcc
-----
Based on the above, I've typed in the following line,
LD_RUN_PATH="/usr/local/mysql/lib:/lib:/usr/lib/gcc-lib/i386-linux/2.7.2.1"
cc - L/usr/lib/gcc-lib/i386-linux/2.7.2.1 -lgcc
But this will give out the following error,
/usr/lib/crt1.o: In function `_start':
/usr/lib/crt1.o(.text+0x57): undefined reference to `main'
Anyone got an idea on how to fix this? Or, know where can I obtain a workable
copy of Msql-Mysql-modules-1.2017 for RedHat 4.2?
Please reply via email if possible.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 15 Feb 1999 15:53:24 -0600
From: John Warner <jwarner@tivoli.com>
Subject: Re: newbie question, basepath
Message-Id: <36C89754.1AA195ED@tivoli.com>
That should work. You would need to escape the backslashes if you were
using double quotes.
--John
weasel wrote:
> i've recently changed providers, from a unix to nt host. my script
> needs a new basepath, can it be formatted as such :
>
> $basepath = 'D:\Inetpub\wwwroot\102133\q1j8tlte\';
>
> or is there some alteration i must do to this? i have no idea.
> thanks,
> mb
------------------------------
Date: Mon, 15 Feb 1999 18:16:12 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
To: Tom Renic <trenic@nortelnetworks.ca>
Subject: Re: Parsing
Message-Id: <Pine.A41.4.02.9902151805330.36014-100000@ginger.libs.uga.edu>
On Mon, 15 Feb 1999, Tom Renic wrote:
> print FILE
> "$Proposal~$CustomerName~$OfficeAddress~$ContactName~$ContactPhone~$ContactAddress";
> # The problem begins when I get to the $OfficeAddress
> variable, since an address has usually more than one
> # line, seperated by enter characters. What I would like
> to do is replace the enter strokes with a comma.
Try 'split' and 'join':
#!/usr/local/bin/perl -w
use strict;
my $Proposal = "prop";
my $CustomerName = "name";
my $OfficeAddress = "street\ncity\nstate\nzip\n";
my $ContactName = "cname";
my $ContactPhone = "cphone";
my $ContactAddress = "caddress";
print
"$Proposal~",
"$CustomerName~",
join( ",", split( /\n/, $OfficeAddress ) ),
"~",
"$ContactName~",
"$ContactPhone~",
"$ContactAddress",
"\n";
### output
### prop~name~street,city,state,zip~cname~cphone~caddress
Regards,
-Brad
------------------------------
Date: Mon, 15 Feb 1999 23:00:08 GMT
From: scot777@my-dejanews.com
Subject: Perl program distribution
Message-Id: <7aa8tk$apk$1@nnrp1.dejanews.com>
I was wondering what is the best way to package a perl program to distribute
to other people. It uses a couple of addon modules. I've read about perlcc
but don't know if thats the way to go. I want to make it as easy as possible
to people to run the program across multiple unix platforms.
Thanks for your input.
Scot Tucker - Network Data Systems
New Hartford, New York
http://www.mvnhealth.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 15 Feb 1999 16:25:15 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl program distribution
Message-Id: <36c8acdb@csnews>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
scot777@my-dejanews.com writes:
:I was wondering what is the best way to package a perl program to distribute
:to other people. It uses a couple of addon modules. I've read about perlcc
:but don't know if thats the way to go.
Probably the easiest thing to do is something involving this:
use FindBin;
use lib $FindBin::Bin;
Or else look in a lib directory at the same level, such when your
program lives in /wherever/spectre/bin/myprog, but needs to look at
/wherever/spectre/lib for its modules:
use FindBin qw($Bin);
use lib "$Bin/../lib";
I've also been playing around with
#!/usr/bin/env perl
use strict;
BEGIN { $^W = 0 }
--tom
--
"... an initial underscore already conveys strong feelings of
magicalness to a C programmer."
--Larry Wall in <1992Nov9.195250.23584@netlabs.com>
------------------------------
Date: Mon, 15 Feb 1999 18:12:32 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Perl s///...can it be done in one line?
Message-Id: <comdog-ya02408000R1502991812320001@news.panix.com>
In article <7aa7if$bmi$1@helix.cs.uoregon.edu>, preuitt@ix.cs.uoregon.edu (Dustin Christopher Preuitt) posted:
> Okay, I'm trying to figure out if I can make the following changes with one line of code
> billy bob likes to shout, "Hey Gordo McMourdo" to his brother paul.
>
> I want to add a '!' after every capital letter in the quotes. So the modified
> line would be:
>
> billy bob likes to shout, "H!ey G!ordo M!cM!ourdo" to his brother paul.
s/"(.*?)"/ my $x = $1; $x =~ s|([A-Z])|$1!|g; qq|"$x"| /ge;
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Mon, 15 Feb 1999 15:11:45 -0600
From: "Steven T. Henderson" <stevenhenderson@prodigy.net>
Subject: Re: Perl s///...can it be done in one line?
Message-Id: <zQ1y2.55893$641.105444@news.san.rr.com>
how about:
$shoes = "billy to shout, 'Hey Gordo McMourdo' to his brother paul.";
print "before: $shoes\n";
$shoes =~ s/([A-Z])/$1!/g;
print "after: $shoes\n";
or am i missing something?
Dustin Christopher Preuitt wrote in message
<7aa7if$bmi$1@helix.cs.uoregon.edu>...
>
>Okay, I'm trying to figure out if I can make the following changes with one
line of code
>
>if the line reads like this:
>
> billy bob likes to shout, "Hey Gordo McMourdo" to his brother paul.
>
>I want to add a '!' after every capital letter in the quotes. So the
modified
>line would be:
>
> billy bob likes to shout, "H!ey G!ordo M!cM!ourdo" to his brother paul.
>
>So...I'm stuck. I can't figure out how to do more than one Capital within
>the quotes...
>
>
>$line =~ s/"([^A-Z]*)([A-Z])(what else do I need?)"/"$1.$2.???."/g
>
>Is it possible?
>
>
------------------------------
Date: 16 Feb 1999 00:16:23 GMT
From: preuitt@ix.cs.uoregon.edu (Dustin Christopher Preuitt)
Subject: Re: Perl s///...can it be done in one line?
Message-Id: <7aadcn$d33$1@helix.cs.uoregon.edu>
Steven T. Henderson (stevenhenderson@prodigy.net) wrote:
: how about:
: $shoes = "billy to shout, 'Hey Gordo McMourdo' to his brother paul.";
: print "before: $shoes\n";
: $shoes =~ s/([A-Z])/$1!/g;
: print "after: $shoes\n";
But it must only change the Caps contained inside quotes.
------------------------------
Date: 16 Feb 1999 00:31:06 GMT
From: preuitt@ix.cs.uoregon.edu (Dustin Christopher Preuitt)
Subject: Re: Perl s///...can it be done in one line?
Message-Id: <7aae8a$dfo$1@helix.cs.uoregon.edu>
Wonderful...works great.
Thanks, brian.
brian d foy (comdog@computerdog.com) wrote:
: In article <7aa7if$bmi$1@helix.cs.uoregon.edu>, preuitt@ix.cs.uoregon.edu (Dustin Christopher Preuitt) posted:
: > Okay, I'm trying to figure out if I can make the following changes with one line of code
: > billy bob likes to shout, "Hey Gordo McMourdo" to his brother paul.
: >
: > I want to add a '!' after every capital letter in the quotes. So the modified
: > line would be:
: >
: > billy bob likes to shout, "H!ey G!ordo M!cM!ourdo" to his brother paul.
: s/"(.*?)"/ my $x = $1; $x =~ s|([A-Z])|$1!|g; qq|"$x"| /ge;
: --
: brian d foy
: CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Mon, 15 Feb 1999 12:24:13 -0800
From: "Asterix" <usenet@arix.com>
Subject: reading a whole file into a string
Message-Id: <Gm%x2.3679$bP2.29230@typhoon-sf.pbi.net>
is there an easier way to do this?
open(IN, $fn); while (<>) { $s .= $_ }; close(IN);
If I do this:
open(IN, $fn); $s .= <IN>; close(IN);
I get just the first line unlike doing:
open(IN, $fn); @s .= <IN>; close(IN);
...where I get the whole file but now I have to go join @s... so, I guess
what I'm asking is: is there any way of making <IN> think he's in a list
context such that I get the whole file in $s?
- thx.
------------------------------
Date: 15 Feb 1999 16:21:51 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: reading a whole file into a string
Message-Id: <36c8ac0f@csnews>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, "Asterix" <usenet@arix.com> writes:
:is there an easier way to do this?
:
: open(IN, $fn); while (<>) { $s .= $_ }; close(IN);
:
:If I do this:
:
: open(IN, $fn); $s .= <IN>; close(IN);
:
:I get just the first line unlike doing:
:
: open(IN, $fn); @s .= <IN>; close(IN);
:
:...where I get the whole file but now I have to go join @s... so, I guess
:what I'm asking is: is there any way of making <IN> think he's in a list
:context such that I get the whole file in $s?
Either
$contents = `cat filename`;
or
$contents = do {
local(*FH, $/);
open(FH, "< filename") && <FH>;
};
I'd swear this should be in the FAQ. And I know just how to get
it there. :-)
--tom
--
char program[1]; /* Unwarranted chumminess with compiler. */
--Larry Wall in the Perl source code
(quoting Henry Spencer (quoting Dennis Ritchie (quoting Brian Kerninghan)))
------------------------------
Date: Mon, 15 Feb 1999 17:26:58 -0700
From: Mike Arms <marms@sandia.gov>
Subject: Re: reading a whole file into a string
Message-Id: <36C8BB52.58B2C921@sandia.gov>
Asterix wrote:
> is there an easier way to do this?
>
> open(IN, $fn); while (<>) { $s .= $_ }; close(IN);
>
> If I do this:
>
> open(IN, $fn); $s .= <IN>; close(IN);
>
> I get just the first line unlike doing:
>
> open(IN, $fn); @s .= <IN>; close(IN);
>
> ...where I get the whole file but now I have to go join @s... so, I guess
> what I'm asking is: is there any way of making <IN> think he's in a list
> context such that I get the whole file in $s?
Oh so close. What you want is the "$/" variable which specifies
the input record separator. It is newline by default. It may
be multi-character (but not for what you want to do here). If
you undefine it, it specifies NO input record separator so a
read of that file will slup in the entire file to your scalar
variable. I changed the ".=" assignment operator to just "=" as
it did not appear that you needed the catenation part.
undef $/; open(IN, $fn); $s = <IN>; close(IN);
print length($s) . "\n"; # Some test to see if it read whole file
--
Mike Arms
marms@sandia.gov
What is the sound of Perl? Is it not the sound of a wall that
people have stopped banging their heads against?" --lwall
------------------------------
Date: Mon, 15 Feb 1999 16:05:16 -0600
From: "William H. Asquith" <asquith@macconnect.com>
Subject: Re: REGEX $1, $2 ... array?
Message-Id: <7aa61j$8tf@enews1.newsguy.com>
Ilya and Larry, Thanks.
I have not heard of these (@+ and @-) before, will check up on this. They
are not mentioned in Perl 5.005 Pocket Reference. They must be very new?
Question that is related.
#!/usr/bin/perl -w
print "First Try\n";
my @matches1 = 'Fee, fie, foe, fum!' =~ /(\w+)\W+\w+\W+(\w+)\W+(\w+)/;
print "@matches1\n"; # Fee foe fum!
print "\@matches1 is ".scalar(@matches1)." long\n";
print "Second Try\n";
my @matches2 = 'Fee, fie, foe, fum!' =~
/(\w+)\W+\w+\W+(\w+)\W+(\w+)\W+(\w+)/;
print "@matches2\n"; # Nothing
print "\@matches2 is ".scalar(@matches2)." long\n";
__END__
Fee foe fum
@matches1 is 3 long
Second Try
@matches2 is 0 long
Logic seems to say that in the second case, I should get back
Fee foe fum undef
but instead I get nothing. I guess because the match was not a complete
'success' that none of the $1... values get loaded.
Also what exactly does the following mean from Perl5.005 Pocket Ref
$1..$9
Contain the subpatterns from the corresponding sets of parentheses
in the last pattern successfully matched. $10 and up are only
available if the match contained that many subpatterns.
This seems to imply that $1..$9 always exists (even as undef) after a match,
but $10 and up must be asked for.
Thanks for the help.
----------
In article <7aa4a9$ie4$1@mathserv.mps.ohio-state.edu>,
ilya@math.ohio-state.edu (Ilya Zakharevich) wrote:
> [A complimentary Cc of this posting was sent to William H. Asquith
> <asquith@macconnect.com>],
> who wrote in article <7a9mkp$12c@enews2.newsguy.com>:
>> Why isn't there a special array that contains
>> $1, $2, $3, etc . . . from application of a regex.
>
> @+ and @- (in contemporary Perls, note that documentation contains
> some misprints).
>
>> This would really make things easier.
>
> It does.
>
> Ilya
------------------------------
Date: 15 Feb 1999 16:37:37 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: REGEX $1, $2 ... array?
Message-Id: <36c8afc1@csnews>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
"William H. Asquith" <asquith@macconnect.com> writes:
:I have not heard of these (@+ and @-) before, will check up on this. They
:are not mentioned in Perl 5.005 Pocket Reference. They must be very new?
Here's perlredelta:
--tom
Here is a new quoting operator:
qr//
Here is a new built-in object type:
Regexp
Well, is currently *called* "Regexp" yet but expected to change without
notice, without any non-UNIVERSAL methods and without and dot-pm module.
Oh, but it's got a string overload.
Here are two new pragmata:
use locale;
use re .....
The latter being rather unclear.
Here's a new switch:
m//gc
Which is not in perlre, of course.
Here are the new embedded `extensions':
(?imsx-imsx:pattern)
(?<=pattern)
(?<!pattern)
(?{ code })
(?p{ code })
(?>pattern)
(?(condition)yes-pattern|no-pattern)
(?(condition)yes-pattern)
(?imsx-imsx)
Here are some new escapes:
\z Match only at end of string, irrespective of \n
\pP Match P, named property. Use \p{Prop} for longer names.
\PP Match non-P
\X Match eXtended Unicode "combining character sequence", \pM\pm*
\C Match a single C char (octet) even under utf8.
Note that this `property' thing not documented in perlre or perlop,
but hidden away in the manpage for the 'use utf8' pragma.
Here are the new variables. I include there `explanations'
to give you a flavor for what we madness have wrought:
@+ $+[0] is the offset of the end of the last successfull
match. $+[n] is the offset of the end of the substring
matched by n-th subpattern. Thus after a match against $_,
$& coincides with substr $_, $-[0], $+[0]. Similarly,
$n coincides with substr $_, $-[n], $+[0] if $-[n] is
defined, and $+ conincides with s ubstr $_, $-[-1], $+[-1].
One can use $#+ to find the last matched subgroup in the
last successful match. Compare with the section on @-.
@- $-[0] is the offset of the start of the last successfull
match. $-[n] is the offset of the start of the substring
matched by n-th subpattern. T hus after a match against $_,
$& coincides with substr $_, $-[0], $+[0]. Similarly,
$n coincides with substr $_, $-[n], $+[0] if $-[n] is
defined, and $+ conincides wi th substr $_, $-[-1], $+[-1].
One can use $#- to find the last matched subgroup in the
last successful match. Compare with the section on @+.
Note that $#+ and $#- appear to be undocumented, but are really $#array
notation.
$^R The result of evaluation of the last successful the section
on (?{ code }) in the perlre manpage regular expression assertion.
(Excluding those used as switches.) May be written to.
There are also these two new sections in the perlre manpage:
Repeated patterns matching zero-length substring
Creating custom RE engines
--
I believe in the waterbed theory of linguistics.
If you push down here, it pops up there.
-- <1993Jan20.181244.8680@netlabs.com>
------------------------------
Date: 16 Feb 1999 00:32:39 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: REGEX $1, $2 ... array?
Message-Id: <7aaeb7$m9l$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to William H. Asquith
<asquith@macconnect.com>],
who wrote in article <7aa61j$8tf@enews1.newsguy.com>:
> Ilya and Larry, Thanks.
>
> I have not heard of these (@+ and @-) before, will check up on this. They
> are not mentioned in Perl 5.005 Pocket Reference. They must be very new?
I do not remember when they made it into Perl. Try
perldoc perlvar
(due to the fact that 5.005_02 is useless on Solaris, we have only
5.005_54 installed. Trying 5.005_02 gives
monk:~->perl5.00502 -S perldoc perlvar
Can't locate strict.pm in @INC (@INC contains: /home/ilya/perl /home/ilya/perl/l
ib/perl5 /home/ilya/perl/lib/perl5/site_perl /home/ilya/perl/lib/perl5/site_perl
/sun4-solaris /opt/local/lib/perl5/5.00502/sun4-solaris /opt/local/lib/perl5/5.0
0502 /opt/local/lib/perl5/site_perl/5.005/sun4-solaris /opt/local/lib/perl5/site
_perl/5.005 .) at /opt/local/bin/perldoc line 5.
BEGIN failed--compilation aborted at /opt/local/bin/perldoc line 5.
Exit 2
)
> Logic seems to say that in the second case, I should get back
> Fee foe fum undef
> but instead I get nothing. I guess because the match was not a complete
> 'success' that none of the $1... values get loaded.
There is no notion of a "complete 'success'". Either it matched, or
it did not. If you can tolerate some things missing, mark with with ?.
> Also what exactly does the following mean from Perl5.005 Pocket Ref
> $1..$9
> Contain the subpatterns from the corresponding sets of parentheses
> in the last pattern successfully matched. $10 and up are only
> available if the match contained that many subpatterns.
>
> This seems to imply that $1..$9 always exists (even as undef) after a match,
> but $10 and up must be asked for.
Ask whoever wrote the reference. Or do perldoc perlvar.
Ilya
------------------------------
Date: Mon, 15 Feb 1999 23:22:08 +0000
From: Murray <ruby@slack.net>
To: Frank Di Vita <frank@divita.com>
Subject: Re: retrieving java with pearl
Message-Id: <36C8AC20.40F71D16@slack.net>
You could contrust a URL along the lines:
http://www.yourserver.com/cgi-bin/collector.pl?name=murray&city=london&age=23
and open a URL connection. Then use a standard perl CGI script - it's
just the same as entering the above URL into a browser....
Murray.
Frank Di Vita wrote:
> i am looking for a method of retrieving java applet information. Does
>
> anyone have any experience using Perl for this. If so, what shouls I
> be looking at?
>
> Any help would be appreciated.
>
> Frank Di Vita
------------------------------
Date: 15 Feb 1999 15:10:28 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: plxload -- show what files a perl program loads
Message-Id: <36c89b54@csnews>
#!/usr/bin/env perl
# plxload -- show what files a perl program loads
# tchrist@perl.com
BEGIN { $^W = 1 }
BEGIN { die "usage: $0 filename\n" unless @ARGV == 1 }
$filename = shift;
use FindBin qw($Bin);
exec "$^X -I$Bin -MDevel::Loaded -S -c $filename 2>/dev/null";
__END__
=head1 NAME
plxload - show what files a perl program loads at compile time
=head1 SYNOPSYS
$ plxload
=head1 DESCRIPTION
This program is used to show what modules a program would load at
compile time via C<use>. Because this installs an at-exit handler and
then uses Perl's B<-c> flag for compile only, it will not find modules
loaded at run-time. Use the Devel::Loaded module for that.
=head1 EXAMPLES
$ plxload perldoc
/usr/local/devperl/lib/5.00554/Exporter.pm
/usr/local/devperl/lib/5.00554/strict.pm
/usr/local/devperl/lib/5.00554/vars.pm
/usr/local/devperl/lib/5.00554/i686-linux/Config.pm
/usr/local/devperl/lib/5.00554/Getopt/Std.pm
$ plxload /usr/src/perl5.005_54/installhtml
/usr/local/devperl/lib/5.00554/Carp.pm
/usr/local/devperl/lib/5.00554/Exporter.pm
/usr/local/devperl/lib/5.00554/auto/Getopt/Long/autosplit.ix
/usr/local/devperl/lib/5.00554/strict.pm
/usr/local/devperl/lib/5.00554/vars.pm
/usr/local/devperl/lib/5.00554/Pod/Functions.pm
/usr/local/devperl/lib/5.00554/Getopt/Long.pm
/usr/local/devperl/lib/5.00554/i686-linux/Config.pm
/usr/local/devperl/lib/5.00554/lib.pm
/home/tchrist/perllib/Pod/Html.pm
/usr/local/devperl/lib/5.00554/Cwd.pm
/usr/local/devperl/lib/5.00554/AutoLoader.pm
=head1 SEE ALSO
L<Devel::Loaded> and pmload(1).
=head1 AUTHOR and COPYRIGHT
Copyright (c) 1999 Tom Christiansen
This is free software. You may modify it and distribute it
under the Perl's Artistic Licence. Modified versions must be
clearly indicated.
--
MSDOS is a Neanderthal operating system -- Henry Spencer
------------------------------
Date: 15 Feb 1999 15:17:05 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: String Compare
Message-Id: <m1hfsn9s0e.fsf@halfdome.holdit.com>
>>>>> "Paul" == Paul J Sala <psala@btv.ibm.com> writes:
Paul> I'm trying to construct a REGX that will determine if
Paul> a string contains a character other than
Paul> these: a-z A-Z 0-9 @ . _ -
I sure hope that's not to determine if a string might possibly be a
valid email address. Because that's the wrong set of characters, by a
factor of half again as many, by my count.
print "Just another Perl hacker,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Mon, 15 Feb 1999 18:30:00 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: String Compare
Message-Id: <alecler-1502991830000001@dialup-550.hip.cam.org>
In article <36C87877.B0F54B60@btv.ibm.com>, "Paul J. Sala"
<psala@btv.ibm.com> wrote:
> I'm trying to construct a REGX that will determine if
> a string contains a character other than
> these: a-z A-Z 0-9 @ . _ -
>
> I tried:
> if ($MyStr =~
> /[\W\@\._-]+/)
> { dosomething; }
>
else
> { dosomethingelse; }
>
> But it didn't work. Any suggestions.
As you stated, you want to see if the string contains at least one
character that doesn't match the specified character class. Otherwise, it
is certain that all the characters are valid.
Ex.
if ($mystr =~ /([^0-9A-Za-z@._-])/) { # or [^\w@.-]
print "Bad char found : '$1'.\n";
}
else {
print "The string is valid.\n";
}
This also works -- check if _every_ character from beginning to end of the
string is in the right class:
if ($mystr =~ /^[0-9A-Za-z@._-]+$/) {
print "The string is valid.\n";
}
else {
print "Bad char found in string.\n";
}
Notice that @ and . do not need to be escaped in a character class.
HTH,
Andre
------------------------------
Date: 16 Feb 1999 00:40:28 GMT
From: david@temss2.main.temple.edu (David Tucker)
Subject: System function call causes telnetd I/O error
Message-Id: <7aaeps$889$1@cronkite.ocis.temple.edu>
Upon using the system statement I receive the following error...
telnetd: /dev/ttyp1: I/O error
After the display of this error, the telnet session is dropped.
Does anyone know what causes this?
------------------------------
Date: Mon, 15 Feb 1999 12:36:40 -0500
From: Eric Windisch <southpark@nni.com>
Subject: Re: V-day Perl Poetry
Message-Id: <36C85B28.6D1ADD95@nni.com>
I actually installed my perl interpreter after I had posted (I
previously had an exploitable version which I had tossed for security
reasons). The script didn't run :( but after few modifications and
suggestions, I came-up with this running script (it gives one warning
however) :
open (HEART, ">for_me");
for($this-valentines-day; $you and $me; $together++) {
$you = "My special one";
$me = "Your darling";
}
%time = ($you => $me, $together => "forever");
while($you = push(@me, @away)) {
foreach(@second) {
die a_bit to my $death;
goto hell;
}
pack $my_bags, @and_leave;
package my_love;
unless(!$i_see_you) {
write YOU_SOON;
}
}
reverse keys %time;
bless me;
for(last; kill $me;) {
if($you) {
die;
}
}
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 4902
**************************************