[18097] in Perl-Users-Digest
Perl-Users Digest, Issue: 257 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 9 14:06:39 2001
Date: Fri, 9 Feb 2001 11:05:30 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <981745529-v10-i257@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 9 Feb 2001 Volume: 10 Number: 257
Today's topics:
Re: alt.perl and correctness (was Re: hex to binary con <sneex@usa.net>
Re: Another XML::Parser Question kumar22@my-deja.com
Re: Devel DProf and " dprofpp " <godzilla@stomp.stomp.tokyo>
Error! An Exception has been caught. <rckjr@yahoo.com>
Re: Getting LWP::UserAgent to perform a sequence of eve <godzilla@stomp.stomp.tokyo>
Getting LWP::UserAgent to perform a sequence of events <pobbard@hotresponse.com>
Re: How to run Perl on Windows 2000? <hexorhaxor@vaxor.com>
Re: linked lists and recursive functions <terrence.brannon@oracle.com>
Re: Need Help Checking IP Address Syntax w/ PERL? (Joe Smith)
Re: Net::FTP error - timeout on put() lawrenceang@my-deja.com
Re: Net::FTP error - timeout on put() Lee.Lindley@bigfoot.com
newbie regexp <lxq79@hotmail.com>
Re: newbie regexp <lxq79@hotmail.com>
passing in a regex ericr@yankthechain.com
Re: Perl for the Fortran programmer (V. Balaji)
Re: perlmail vs procmail <bingalls@panix.com>
Re: Problem opening for writing, going nuts, please hel misterfive@my-deja.com
Problem with regex and if/else expression (LK)
Re: Problem with regex and if/else expression <mothra@nowhereatall.com>
Re: Problem with regex and if/else expression (LK)
Re: Problem with regex and if/else expression (LK)
Re: Q: regular expression <Jerome.Abela@free.fr>
Re: Radical readdir suggestion <iltzu@sci.invalid>
Re: Sending email from Perl Script on NT <Scharpff@Tembit.de>
Re: Specifying the length of regular expression (Greg Bacon)
Re: splitting a string on the / character <leekembel@hotmail.com>
Re: splitting a string on the / character <leekembel@hotmail.com>
the best solution? <tony@codeisland.net>
Re: the best solution? (Chris Fedde)
Re: the best solution? (John Joseph Trammell)
Re: Two dimensional arrays tunneling@my-deja.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 09 Feb 2001 17:11:58 GMT
From: Bill Jones <sneex@usa.net>
Subject: Re: alt.perl and correctness (was Re: hex to binary conversion ? Please help)
Message-Id: <B6A98F74.2AF6%sneex@usa.net>
Hash: SHA1
On 2/8/01 7:22 AM, in article m1vgqlqs8c.fsf_-_@halfdome.holdit.com,
"Randal L. Schwartz" <merlyn@stonehenge.com> wrote:
>>>>>> "Peter" == Peter J Acklam <jacklam@math.uio.no> writes:
>
> Peter> True, and that is a problem. On the other hand, alt.perl
> doesn't Peter> have the endless insults and horassments that you
> find here.
>
> I wonder how come people keep saying this.
>
> In CLPM, I see a *ton* of good questions and answers go by. And at
> that volume, there also happen to be quite a few *bad* questions
> that show up, and then the ensuing "RTFM" or "that's offtopic"
> posts that rightfully follow.
My $cents = 2;
Not having been around for a while (about a year) I see roughly
14,800 postings in here (that's just what my news server can see at
any rate...)
Out of those I would hazard that 8,000 constitute good dialog - which
is a good average in my book (I remember 1997 when it was nothing but
flame wars...)
People like Randal, not mention about 40 others, put up with those
6,000 or so off topic posts -- the least people can do is put up with
the 'Please read this manual or that' without taking it personally.
I know, I can relate from experience. The vast majority do want to
help - they just do want to do it for you.
Best;
-Sneex- :]
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
Comment: -Sneex- :]
iQA/AwUBOoQkzfRITvtATtddEQJ0OgCfdME/81h05wtVxXf3PjM5+46an4oAoLiU
8fyXf3R77w736Wm6H9RVfhxj
=6P74
-----END PGP SIGNATURE-----
------------------------------
Date: Fri, 09 Feb 2001 18:34:03 GMT
From: kumar22@my-deja.com
Subject: Re: Another XML::Parser Question
Message-Id: <961d6r$cj8$1@nnrp1.deja.com>
Okay I'm not sure if anyone cares, but I found a simple, if inelegant,
solution to my own problem:
s/&/XXXXXXX/g; #before sending the file to the parser
and
s/XXXXXXX/&/g; #after it comes back.
Duh.
-Rakesh
In article <95ssvd$88r$2@bob.news.rcn.net>,
ebohlman@omsdev.com (Eric Bohlman) wrote:
> kumar22@my-deja.com wrote:
> > Hey, does anyone know how to get the XML::Parser module NOT to
> > translate special character codes?
>
> > E.g. if I'm parsing a file with a ’ in it, I want Perl just to
> > print out ’, not some weird attempt to render the Unicode
> > character I'm coding for.
>
> You can't prevent the parser from interpreting numeric character
> references. You *might* be able to use the parser's original_string
> method, but it would probably be rather awkward. Really the best
choice
> is to look up the rules for UTF-8 encoding (they're fairly simple,
but I
> don't remember them off the top of my head) and write a little
function to
> re-entify anything that meets your criteria.
>
--
This ball of the Lords of Death -- it is just a spherical knife.
-Popol Vuh
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 09 Feb 2001 08:55:40 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Devel DProf and " dprofpp "
Message-Id: <3A84210C.F930E265@stomp.stomp.tokyo>
mothra wrote:
> Godzilla! wrote:
> [snipped]
> > I have found a reference for dprofpp. However, typical
> > of Perl documentation, it is gibberish. Additionally
> > I have discovered the syntax provided by documentation
> > for dprofpp, will not compile.
> I was able to use this utiltiy without problem. What was the error?
> Here is what I used to run the utility.
> D:\scripts>dprofpp -u -p dbitest.pl
Well, interesting. This is not the syntax exemplified
by this one piece of documentation I found for dprofpp
nor the syntax hinted by Perl documentation. Your
switches and script reference are the same.
I will have to install ActiveState again, then try
running dprofpp from a DOS command line rather than
running it as a command inside a script, as noted
by this documentation I found after a week of intense
searching. Devel DProf works fine as a script command,
as documented, under my Apache server. This dprofpp
script command line call fails to compile if
documentation syntax is used.
There is a Main Package problem with Perl trying to
interpret dprofpp as a subroutine call when this syntax
in documentation is used.
> [output of script was here]
> Total Elapsed Time = -0.00744 Seconds
> User Time = 0.283118 Seconds
> Exclusive Times
> %Time ExclSec CumulS #Calls sec/call Csec/c Name
> 38.1 0.108 0.139 3 0.0360 0.0463 main::BEGIN
> 16.6 0.047 0.047 1 0.0470 0.0470 DBD::Ingres::db::_login
(snip)
I found some explanation in a personal homepage on how
to translate this info into Plain English. It is
frustrating to find Perl Documentation to be so much
in error, consistently, and so lacking in useful comments.
> > Perl documentation indicates to read dprofpp man. There is
> > no such manual to be found, in my efforts.
> You are correct, there is no man page for this. However I was able
> to find the information on the profile format of the tmon.out file.
> It is located in the DProf.pm file ( I include only a portion of
> this due to space)
Right. Perl docs claim there is a dprofpp manual. There is
not. I've come across a significant amount of errors like
this in Perl docs. I am quite convinced those who wrote
Perl documentation don't have a clue on what they are doing.
This is one of many reasons I rarely refer anyone to Perl
documentation; it is unacceptably erroroneous in all aspects
and, so poorly written, I consider it to be gibberish.
On Devel DProf, there is no documentation on dprofpp. Typically,
Perl documentation claims there is. DProf only holds a casual
mention about using dprofpp to translate tmon.out, and nothing
else; no clues on how to use dprofpp. Running DProf per Perl
documentation does work ok. I am able to produce tmon.out file.
Something which really annoys me is my system Perl documentation,
a collection of perlpod, perltoc and such, have hyperlinks for
dprofpp, hyperlinks which go nowhere. Examination of document
source shows there is no address included.
I will try running dprofpp within a DOS box, contrary to
Perl documentation, and discover if I can enjoy this success
you have enjoyed.
Kinda figures only Mothra is brave enough to engage me in
meaningful dialog. I take it you are not a member in good
standing in this Good Ol' Boys Club, comp.lang.perl.misc.
I suspect moth balls helps to protect you against abuse
from the regulars here. Fortunately, I have none.
(great subtle pun Kira!)
Thank you for this infomation. I will give this a try.
Godzilla!
------------------------------
Date: Fri, 09 Feb 2001 18:10:38 GMT
From: Rick Kasten <rckjr@yahoo.com>
Subject: Error! An Exception has been caught.
Message-Id: <961bqk$baf$1@nnrp1.deja.com>
A procedure as simple as this:
sub FP_FixPerms
{
use Win32::Perms;
$::ThisShare = new Win32::Perms($_[0]);
undef $::ThisShare;
}
Sometimes gives the following output:
Error! An Exception has been caught.
At this point, I don't care what is causing the error. My problem is
no matter what I do to prohibit or capture the error, I get nothing but
the statement above printed to STDERR. I've tried all kinds of die and
warn statements and all that. Does anyone know what would cause the
error I'm getting and/or what I can do to capture the error or prevent
it from displaying the message?
--
Rick Kasten, MCSE Collective Resource Consultant
kasten@collectivetech.com http://www.collectivetech.com
Collective: Managed Infrastructure for the Real World
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 09 Feb 2001 09:41:03 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Getting LWP::UserAgent to perform a sequence of events (GET, POST, GET, etc.)
Message-Id: <3A842BAF.DF2B7D94@stomp.stomp.tokyo>
Philip Obbard wrote:
> I'm trying to automate the submission of a form on another
> web server via LWP, but I'm getting stuck.
> I have no problem issuing a single POST or GET command, like:
(snipped code)
> ...but the external webserver is checking the HTTP_REFERER for the post to
> retrieve.cgi, so it's redirecting the LWP client to the home page when it
> tries to do the POST. How can I first "GET" the home page (e.g.,
> 'http://data.hotresponse.com/retrieve.cgi'), and then, in the same
> *session*, have the browser POST to the next page? So the HTTP_REFERER check
> will pass?
(snipped)
LWP is a very decent module. However, I only use LWP Simple
for my scripts. I have found for more complex socket use,
it is quicker and more efficient to write my own socket.
When a referrer variable is needed, as you describe, I add
a referrer variable to my socket script to 'fool' a site
cgi which employs $ENV{REFERER} for redirection. In some
cases, adding $ENV{REFERER}, after setting a value, works.
For others, running tests will yield a variable name used
by a remote script for referrer. Use of $env_ref is very
common with programmers. A custom variable name can be
included in a socket call as well,
Research LWP and discover if there is a facility for
including a referrer variable within your script.
Godzilla!
------------------------------
Date: Fri, 9 Feb 2001 11:16:03 -0500
From: "Philip Obbard" <pobbard@hotresponse.com>
Subject: Getting LWP::UserAgent to perform a sequence of events (GET, POST, GET, etc.)
Message-Id: <9614q0$3s0$1@taliesin.netcom.net.uk>
Hi all,
I'm trying to automate the submission of a form on another web server via
LWP, but I'm getting stuck.
I have no problem issuing a single POST or GET command, like:
use LWP::UserAgent;
my $ua = new LWP::UserAgent;
$ua->agent("HotDataGrabber/0.9");
# Create a request
my $req = new HTTP::Request POST =>
'http://data.hotresponse.com/retrieve.cgi?page=331';
$req->content_type('application/x-www-form-urlencoded');
$req->content('Section=140&Style=paragraph');
#Issue the POST and print the results
my $res = $ua->request($req);
print $res->as_string;
...but the external webserver is checking the HTTP_REFERER for the post to
retrieve.cgi, so it's redirecting the LWP client to the home page when it
tries to do the POST. How can I first "GET" the home page (e.g.,
'http://data.hotresponse.com/retrieve.cgi'), and then, in the same
*session*, have the browser POST to the next page? So the HTTP_REFERER check
will pass?
I've gone through the LWP docs again and again, but I can't seem to find an
example of using LWP to GET/POST to TWO web pages in sequence, without the
web server treating it as an entirely new request.
Any help would be appreciated.
Thanks!
--Philip
------------------------------
Date: Fri, 9 Feb 2001 17:24:07 +0100
From: "Arthuro" <hexorhaxor@vaxor.com>
Subject: Re: How to run Perl on Windows 2000?
Message-Id: <9615lh$dm0$1@porthos.nl.uu.net>
"Sean" <ilogix@hotmail.com> wrote in message
news:OnUg6.5460$TR6.169244@sodalite.nbnet.nb.ca...
> Thanks for your reply. But our needs are more than met with Windows 2000
> server. All I really wanted to know is how to run Perl on Windows
> 2000.....thanks again.
>
> -Sean-
Have a look at the ActiveState perl distribution. Works fine on Win2k
Pro/Srv.
Grtz,
Arthuro.
------------------------------
Date: Fri, 09 Feb 2001 10:06:55 -0800
From: Terrence Monroe Brannon <terrence.brannon@oracle.com>
Subject: Re: linked lists and recursive functions
Message-Id: <3A8431BF.26D0C15E@oracle.com>
> Perl FAQ, part 7:
>
> "What's the difference between dynamic and lexical (static) scoping?
> Between local() and my()?"
Perhaps this should be updated to include our()?
------------------------------
Date: 9 Feb 2001 18:42:47 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: Need Help Checking IP Address Syntax w/ PERL?
Message-Id: <961dn7$chg$1@nntp1.ba.best.com>
In article <wkhf25qt55.fsf@math.uio.no>,
Peter J. Acklam <jacklam@math.uio.no> wrote:
>inwap@best.com (Joe Smith) writes:
>> I can "ping 192.18.25073" and I can "nslookup 192.18.25073" but
>> the above regex does not allow that IP address.
>
>Is it really an IP address? I thought an IP address was four
>numbers in the range 0..255, each separated by a dot...?
On a "class B" network, the first number is between 128 and 191,
the second number is between 0 and 255, and the remaining 16 bits of
network address is a number between 0 and 65535. That last part
can be specified as two parts (typical dotted-quad format), or as
a single 5-digit number.
The only thing that matters is that the end result fit into 32 bits.
-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.
------------------------------
Date: Fri, 09 Feb 2001 16:19:09 GMT
From: lawrenceang@my-deja.com
Subject: Re: Net::FTP error - timeout on put()
Message-Id: <96159h$4oh$1@nnrp1.deja.com>
In article <3A84112B.81B92F5B@udel.edu>,
John Kitchin <jkitchin@udel.edu> wrote:
> Have you tried setting the Timeout to longer? check man Net::FTP, it
> lists the default timeout at 2 minutes.
> Maybe something like:
> $ftp = Net::FTP-> new ("some.host.name" , Timeout =>10000)
> would fix it.
Hi there,
I have tried that too, but to no avail.
It seemed to me from the documentation that this timeout value is for the
initial new() command only. *shrug*
L.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 09 Feb 2001 16:31:31 GMT
From: Lee.Lindley@bigfoot.com
Subject: Re: Net::FTP error - timeout on put()
Message-Id: <961613$5ej$1@nnrp1.deja.com>
In article <9603so$9a3$1@nnrp1.deja.com>,
lawrenceang@my-deja.com wrote:
>
> $ftp_ret=$ftp->put('//ssbcsgf01/share/A_GCR/bin/perl/gcrjcl');
> if (!$ftp_ret)
> {
> $test_item="put2()";
> next;
> }
>
I use "quot site submit" which is similar, I think. When putting
to the internal reader, I have to give a second argument to put.
I don't know why. It may be a quirk of the TCP/IP implementation
we have and may not apply to you. Still, you can give it a try.
$ftp->put('local_file_name', 'x');
--
// Lee.Lindley@Bigfoot.com
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Sat, 10 Feb 2001 03:41:44 +0900
From: LXQ <lxq79@hotmail.com>
Subject: newbie regexp
Message-Id: <20010210034144.6dd54dff.lxq79@hotmail.com>
Hi,
Im trying to change all words in a file:
from desk -> table
from house -> home
from dog -> cat
The file is just like:
this is the file, deskdesk. desk desk-.
home-home-home. home+home, homehome.
dog-dog-dog test test or even dogdog
So the position is random, and it can be another letter (not space) stick
to it.
Then I wrote a script like this....
while($file = <>){
$line = s/desk/table/:
$line = s/house/home/;
$line = s/dog/cat/;
}
But it failed! Anyone can tell me how to do this correctly please? Thanks
so much :)
------------------------------
Date: Sat, 10 Feb 2001 03:53:09 +0900
From: LXQ <lxq79@hotmail.com>
Subject: Re: newbie regexp
Message-Id: <20010210035309.51dae62c.lxq79@hotmail.com>
Sorry, the while($file =<>) part should be while (line<>)
On Sat, 10 Feb 2001 03:41:44 +0900
LXQ <lxq79@hotmail.com> wrote:
> Hi,
>
> Im trying to change all words in a file:
> from desk -> table
> from house -> home
> from dog -> cat
>
> The file is just like:
> this is the file, deskdesk. desk desk-.
> home-home-home. home+home, homehome.
> dog-dog-dog test test or even dogdog
>
> So the position is random, and it can be another letter (not space) stick
> to it.
>
> Then I wrote a script like this....
> while($file = <>){
> $line = s/desk/table/:
> $line = s/house/home/;
> $line = s/dog/cat/;
> }
>
> But it failed! Anyone can tell me how to do this correctly please? Thanks
> so much :)
------------------------------
Date: Fri, 09 Feb 2001 18:53:27 GMT
From: ericr@yankthechain.com
Subject: passing in a regex
Message-Id: <961eb1$do9$1@nnrp1.deja.com>
Let's say I want to do something like this:
my $regex = shift;
$string =~ $regex;
passing the entire regular expression in as a variable. Obviously the
above example itself doesn't work, but what will?
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 9 Feb 2001 16:39:21 GMT
From: balaji@cray.com (V. Balaji)
Subject: Re: Perl for the Fortran programmer
Message-Id: <9616fp$81d$1@murrow.corp.sgi.com>
Michael Prager <Mike.Prager@noaa.gov> writes:
>I was able to borrow "Learning Perl," and although it seems a
>fine book, it has too many explanations as deltas from Unix
>shell script language or similar constructs in C to be my
>primary guide. I've ordered a copy of "Perl: the Programmer's
>Companion" and with any luck, it will be suitable for my modest
>needs (though experience shows that one man's "modest needs" are
>usually writers' "advanced features").
Sounds like you might just need the O'Reilly book 'Perl in a nutshell'.
It doesn't teach so much as just throw you in the deep end, but it worked
for me. And it's an invaluable, comprehensive reference, esp to the
CPAN modules. I never found I needed anything else.
--
Balaji 1 609.452.6516
SGI/GFDL Princeton University
------------------------------
Date: 09 Feb 2001 13:35:36 -0500
From: Bruce Ingalls <bingalls@panix.com>
Subject: Re: perlmail vs procmail
Message-Id: <wi2y9vfg0w7.fsf@mail.conde-dev.com>
abigail@foad.org (Abigail) writes:
> Why is it that so many newcomers think we should do the work to change
> what we've created in the past to suit their needs?
If you enjoy repeatedly chasing people away from comp.lang.perl.misc, and you
feel that it don't get no better than this, then don't mess with the status
quo.
It is possible that all newcomers are stupid, or revolutionaries.
It is also possible that the comp.lang.perl.misc community paradigm, as you
present it or enforce it, is counter-intuitive, or or does not fit the paradigm
of the rest of the internet.
It is clear to me that these old mistakes are as doomed to repeat, just as your
next software deadline is doomed to slip. It will take more than changing
Perl's version number from 5.6 to 6.0 for the risk of bold new mistakes to be
effective.
The 2 others, who have responded to this thread, made a good point that truth
is not beautiful. I am beginning to believe that perhaps our mis communications
may, in part be due to ugliness obscuring the truth.
--
The mentor also learns from the disciples.
------------------------------
Date: Fri, 09 Feb 2001 16:55:40 GMT
From: misterfive@my-deja.com
Subject: Re: Problem opening for writing, going nuts, please help!
Message-Id: <9617e6$6ot$1@nnrp1.deja.com>
Thanks everyone. I finally figured out what was happening.
After a lot of messing around, I found out that my routine to strip off
non-alphanumerical characters wasn't quite syntaxed properly, so it was
unable to open the file.
It never invokes the CGI die file in this case, though, which makes
debugging hard.
Thanks again!
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 09 Feb 2001 16:08:22 GMT
From: lkenny@fisheries.org (LK)
Subject: Problem with regex and if/else expression
Message-Id: <3a8413c2.2244777@wingate>
I am trying to get the program below to search a file for a match with
a regular expression. When it makes that match I want that line to be
stored in the variable $ms. I though I had programed this properly,
but I am wrong. When I run it this way, no matter what $num is, the
"else" is executed and not the "if". If I take out the "else"
portion, no matter what $num is the last line of the file is stored in
$ms.
I can't seem to get my head around this one. I am looking at it a
certain way and am having trouble taking a different angle. If anyone
could provide any help I would really appreciate it.
$num = $FORM{'msnumber'};
open(FILE, $file) || &dienice;
while(<FILE>){
if($_ !=~ /$num/){
$ms = $_;
}else{
print "Content-type: text/html\n\n";
print "<html><body>STUFF";
print "</body></html>\n";
exit;
}
}
close(FILE);
LK
------------------------------
Date: Fri, 09 Feb 2001 08:09:48 -0800
From: mothra <mothra@nowhereatall.com>
Subject: Re: Problem with regex and if/else expression
Message-Id: <3A84164C.894D792A@nowhereatall.com>
LK wrote:
>
> I am trying to get the program below to search a file for a match with
> a regular expression. When it makes that match I want that line to be
> stored in the variable $ms. I though I had programed this properly,
> but I am wrong. When I run it this way, no matter what $num is, the
> "else" is executed and not the "if". If I take out the "else"
> portion, no matter what $num is the last line of the file is stored in
> $ms.
[snipped]
> $num = $FORM{'msnumber'};
> open(FILE, $file) || &dienice;
> while(<FILE>){
> if($_ !=~ /$num/){
> $ms = $_;
[snipped]
change the if to this
if(/$num/) {
$ms = $_;
}
Hope this helps
Mothra!
------------------------------
Date: Fri, 09 Feb 2001 16:37:00 GMT
From: lkenny@fisheries.org (LK)
Subject: Re: Problem with regex and if/else expression
Message-Id: <3a841998.3739447@wingate>
On Fri, 09 Feb 2001 08:09:48 -0800, mothra <mothra@nowhereatall.com>
wrote:
>LK wrote:
>>
>> I am trying to get the program below to search a file for a match with
>> a regular expression. When it makes that match I want that line to be
>> stored in the variable $ms. I though I had programed this properly,
>> but I am wrong. When I run it this way, no matter what $num is, the
>> "else" is executed and not the "if". If I take out the "else"
>> portion, no matter what $num is the last line of the file is stored in
>> $ms.
>[snipped]
>> $num = $FORM{'msnumber'};
>> open(FILE, $file) || &dienice;
>> while(<FILE>){
>> if($_ !=~ /$num/){
>> $ms = $_;
>[snipped]
>change the if to this
> if(/$num/) {
> $ms = $_;
>}
>
>Hope this helps
>
>Mothra!
Thanks for the help, mothra. This gets me out of that problem of only
getting the final line in the file.
But there are other intereting issues that arise. else seems to take
over the program when it is kept in. No matter what $num is, the else
will execute. When I take else out, it runs properly.
Any ideas?
LK
------------------------------
Date: Fri, 09 Feb 2001 17:14:43 GMT
From: lkenny@fisheries.org (LK)
Subject: Re: Problem with regex and if/else expression
Message-Id: <3a842565.6760714@wingate>
On Fri, 09 Feb 2001 16:37:00 GMT, lkenny@fisheries.org (LK) wrote:
>On Fri, 09 Feb 2001 08:09:48 -0800, mothra <mothra@nowhereatall.com>
>wrote:
>
>>LK wrote:
>>>
>>> I am trying to get the program below to search a file for a match with
>>> a regular expression. When it makes that match I want that line to be
>>> stored in the variable $ms. I though I had programed this properly,
>>> but I am wrong. When I run it this way, no matter what $num is, the
>>> "else" is executed and not the "if". If I take out the "else"
>>> portion, no matter what $num is the last line of the file is stored in
>>> $ms.
>>[snipped]
>>> $num = $FORM{'msnumber'};
>>> open(FILE, $file) || &dienice;
>>> while(<FILE>){
>>> if($_ !=~ /$num/){
>>> $ms = $_;
>>[snipped]
>>change the if to this
>> if(/$num/) {
>> $ms = $_;
>>}
>>
>>Hope this helps
>>
>>Mothra!
>
>Thanks for the help, mothra. This gets me out of that problem of only
>getting the final line in the file.
>But there are other intereting issues that arise. else seems to take
>over the program when it is kept in. No matter what $num is, the else
>will execute. When I take else out, it runs properly.
>Any ideas?
>
>LK
Actually, I kno why it is doing this, just don' know the work around
for it yet
LK
------------------------------
Date: Fri, 09 Feb 2001 17:55:16 GMT
From: Jerome Abela <Jerome.Abela@free.fr>
Subject: Re: Q: regular expression
Message-Id: <3A842DF9.212F8024@free.fr>
matkaopas@my-deja.com a écrit :
> Perl docs didn't give much help to my particular pattern matching
> problem. I need to convert different number of same letters following
> each others to one single letter e.g.
> abbbaabbbbbaab -> acaacaac
The 'tr' operator has an option (/s), which replaces several instances
of a char into a single one: tr/b/c/s
Jerome.
------------------------------
Date: 9 Feb 2001 09:36:23 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Radical readdir suggestion
Message-Id: <981709247.24219@itz.pp.sci.fi>
In article <slrn984svj.vht.mgjv@martien.heliotrope.home>, Martien Verbruggen wrote:
>On 7 Feb 2001 15:20:43 GMT,
> Ilmari Karonen <iltzu@sci.invalid> wrote:
>>
>> Well, except for that fact that they create a loop of hard links.
>
>But a loop of hard links can be created with otherwise named entries as
>well. It is generally disallowed for regular users to create hard links
>to directories, because they are dangerous when used incorrectly, but
>that doesn't make . and .. really special.
You do seem to have a talent for understatement. I'm now wondering
whether one could find a single filesystem on this planet that had a
deliberate loop of hard links made for any purpose other than just to
show that it can be done. (Excluding "..", of course.)
I can barely see the point of having converging branches in the
directory tree, though you'd have to be careful with programs that
assume "." and "foo/.." point to the same directory, or make any other
equivalent assumption. But an actual loop? Better not let find(1)
get anywhere near it..
>> I wanted to check how File::Find deals with this, but apparently it
>> doesn't. There are other OS specific checks, but "." and ".." are
>> always skipped. So File::Find is broken on Macs, Amigas, etc.
>
>Then File::Find should be fixed, most likely by someone who actually is
>on a system where . and .. aren't special.
Well, I'm typing this on a Mac right now, but it doesn't have perl
installed. The guy in the next room does have MacPerl, maybe I could
ask him to do something about it. Not that he'd probably have any
idea what I'm talking about.
Since "." and ".." are unlikely filenames on any system, the broken
code will work 99.99% of the time just fine. So the "scratch your own
itch" development method isn't likely to get it fixed. When it does
break badly enough to be noticeable, it's likely to happen to someone
who knows absolutely nothing about Perl, Unix or File::Find, and just
happens to be using a script written by someone using a module written
by someone else.
It's not creating a specific nuisance -- it's just contibuting to the
general unreliability of computers.
>> Please ignore Godzilla and its pseudonyms - do not feed the troll.
>
>Stop mentioning it. I was still blissfully unaware of her return until
>people started mentioning it again. Even a good set of killfile rules
>isn't enough anymore, nowadays :)
It's there to warn the newbies. I don't read any threads she starts
either, but I can see them since they're only scored to -99. Useful
as killfiles are, they only fix the symptoms, not the problem. One
extra line in a signature is IMHO worth it if it keeps people from
engaging in pointless conversation with a troll.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"Certainly Pluto itself couldn't care less whether it's called a planet
or not." -- Erik Max Francis in rec.arts.sf.science
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Fri, 9 Feb 2001 19:02:09 +0100
From: "Franziskus Scharpff" <Scharpff@Tembit.de>
Subject: Re: Sending email from Perl Script on NT
Message-Id: <961b8r$iq9$1@crusher.de.colt.net>
I do not know the LWP and HTTP Package, so I can not help you directly.
What I can offer is a possibility that works under NT:
use Net::SMTP;
$smtp = Net::SMTP->new('mailhost'); # your Smtp - Server
$smtp->mail($ENV{USER}); # I write the name of the Sender
here # because some Mailer
do not accept a Mail without a complete name.
$smtp->to('postmaster'); # Display Name of Recipient
$smtp->data();
$smtp->datasend("To: postmaster\n"); # Mailadress
$smtp->datasend("\nSubject: xy \n"); # You NEED the leading \n
$smtp->datasend("\n");
$smtp->datasend("A simple test message\n");
$smtp->dataend(); $smtp->quit;
This works for me.Hope it helps you.
Franziskus
<jgunnip@my-deja.com> wrote in message news:96130h$2fq$1@nnrp1.deja.com...
>
>
> Hi,
>
> Does anyone know why the following code to send email works perfectly
> on Linux but not on Windows NT? It doesn't complain (i.e. die()) when
> I use it on NT. I just never receive the email.
>
> Thanks,
> Jon
>
> email('foo@bar.com', 'bar@foo.com', 'Hello', 'Just saying Hi!');
>
> sub email {
> use LWP::UserAgent;
> use HTTP::Request;
>
> my $to = shift;
> my $from = shift;
> my $subject = shift;
> my $message = shift or die 'Usage email($to, $from, $sub, $msg)';
>
> # mail message
> my $ua = LWP::UserAgent->new or die "$!";
> my $req = HTTP::Request->new(POST => "mailto:$to") or die "$!";
> $req->header(Subject => "$subject", From => $from);
> $req->content($message);
>
> $ua->request($req) or die "Error sending mail";
> }
>
>
>
> Sent via Deja.com
> http://www.deja.com/
------------------------------
Date: Fri, 09 Feb 2001 16:31:18 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Specifying the length of regular expression
Message-Id: <t886qmj8ggp96e@corp.supernews.com>
In article <t88253lulv9uf1@corp.supernews.com>,
Greg Bacon <gbacon@hiwaay.net> wrote:
: In article <960ji8$l4t$1@nnrp1.deja.com>,
: Ian Boreham <iboreham@my-deja.com> wrote:
:
: : You don't need the comma after the "10".
:
: Yes you do; the original spec was length greater than ten.
...and the 10 should be 11. :-)
: When matching strings from non-regular languages, I find that
: verifying the match with additional checks, e.g.,
:
: if (/^(A+B*C+)$/ && length($1) > 10) { ... }
:
: as Dominus wrote, makes for much clearer code than doing it all in the
: regular expression.
It should be possible, given the desired minimum, to generate the
corresponding NFA, but I'm having a tough time coming up with a
recurrence.
Greg
--
To be pedantic,
the word 'haiku' has three
not two syllables
-- Neko
------------------------------
Date: Fri, 09 Feb 2001 17:23:20 GMT
From: "Studio 51" <leekembel@hotmail.com>
Subject: Re: splitting a string on the / character
Message-Id: <cIVg6.115831$V22.23578366@news4.rdc1.on.home.com>
"Chris Stith" <mischief@velma.motion.net> wrote in message
news:t86at11ug87p8b@corp.supernews.com...
> The people who referred this to the man pages have read the man pages.
> That's how they know where in the man pages to look, why they themselves
> won't ask questions answered by the man pages, and why others will know
> their questions are not answered in the man pages so that no one will
> have to refer them to the manual.
How many lines long do you think all the man pages pertaining to Perl are?
Now when a newbie asks a simple question and gets "RTFM", how helpful is
that? When they ask a REALLY simple question, it probably means that half of
the man pages are over thier head anyway, so they may spend a couple hours
reading the manual, only to come back and ask again (or more likely, give up
because of the lousy response to thier first question).
> Ever heard the proverb about giving a fish and teaching someone to
> fish? Search Deja. It's a common thread here.
I agree, my point is that "RTFM" doesn't teach nearly as much as "Do it like
this, and for an in-depth explanation of why, read this part of the manual".
LKembel
------------------------------
Date: Fri, 09 Feb 2001 17:38:53 GMT
From: "Studio 51" <leekembel@hotmail.com>
Subject: Re: splitting a string on the / character
Message-Id: <NWVg6.115956$V22.23588746@news4.rdc1.on.home.com>
"Chris Stith" <mischief@velma.motion.net> wrote in message
news:t86bj87f02p880@corp.supernews.com...
> You can do the same thing without the escape, since you use different
> delimeters.
> my @temp = split[/], $direntry;
As mentioned, that doesn't work.
> What with the more code? I just showed you the same thing you did without
> the EXTRA character you added unecessarily. Come back from the Cargo Cult,
> it's not a good way to live.
I was referring to using alternate delimeters, it's more code to search
through the string and replace the delimiters. It also takes more time,
maybe quite a bit more time if the string is long enough (I don't know the
speed of s///). I don't know what "Cargo Cult" is.
> The man pages do tell you how to do it and why. Telling someone the
> man page to read gives them more info about it, too. Of course, if
> someone didn't know about TFM, then teaching them that they need to
> RTFM and maybe how to RTFM can be of a lot more help to them than
> waiting for someone else to answer the question.
If the manual can explain something that would otherwise take you all day to
type out, then by all means just refer them to the manual. But when it takes
more time to type your response referring them to the manual than it would
to just tell them what they asked for, well, that doesn't make much sense.
And especially when the question is so simple, it suggests that the poster
of the question is unfamiliar with Perl and may have a hard time
understanding the manual. In which case you've just brushed them off and
they'll probably give up rather than risk offending someone on usenet by
asking another question.
> Anyone ever notice that the least polite people are the ones with the
> least identifying info in their headers? Like a psuedonym and a free
> email service that doesn't verify who you are? ;) Of course you have.
> It's been discussed for a long time that anonymity is adouble-edged
> sword.
Are you referring to me? The free email service is for spam, which that
account gets plenty of. Studio 51 is not a pseudonym, it's the name of my
company. If it really bothers you that you don't know anything about me,
then my name is Lee Kembel and I live in Toronto.
LKembel
------------------------------
Date: Fri, 9 Feb 2001 16:34:51 -0000
From: "Tony O Sullivan" <tony@codeisland.net>
Subject: the best solution?
Message-Id: <v_Ug6.63$s4.218@news.indigo.ie>
Hi all,
I know this seems like a simple problem but I can't figure out the best way
of doing this so I thought i would seek advice!
I am searching strings for the occurances of a term, as I see it the are
(obvious) options:
1. Short loop with index of function loop while index != -1 incrementing a
counter
2. Create a temp copy of string and use the replace function to return the
number of occurances
Memory/performance is a major issue for the application, so I reckon the
temp string method is the best
I was wondering if is there a less costly method !
Any Advice would be greatly appreciated, any insults/abuse will be accepted
with a good natured smile
and a promise not to ask such simplistic questions!
------------------------------
Date: Fri, 09 Feb 2001 16:54:31 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: the best solution?
Message-Id: <bhVg6.226$M8.189004800@news.frii.net>
#/usr/bin/perl -w
#
# Please excuse jeopardy style posting
# Are you asking for something different than this?
#
$count += /\bthe\b/ig while (<DATA>);
print $count,"\n";
__END__
In article <v_Ug6.63$s4.218@news.indigo.ie>,
Tony O Sullivan <tony@codeisland.net> wrote:
>Hi all,
>I know this seems like a simple problem but I can't figure out the best way
>of doing this so I thought i would seek advice!
>
>I am searching strings for the occurances of a term, as I see it the are
>(obvious) options:
>
>1. Short loop with index of function loop while index != -1 incrementing a
>counter
>
>2. Create a temp copy of string and use the replace function to return the
>number of occurances
>
>Memory/performance is a major issue for the application, so I reckon the
>temp string method is the best
>
>I was wondering if is there a less costly method !
>
>Any Advice would be greatly appreciated, any insults/abuse will be accepted
>with a good natured smile
> and a promise not to ask such simplistic questions!
>
>
--
This space intentionally left blank
------------------------------
Date: Fri, 09 Feb 2001 17:01:08 GMT
From: trammell@bayazid.hypersloth.net (John Joseph Trammell)
Subject: Re: the best solution?
Message-Id: <slrn9886ha.6gf.trammell@bayazid.hypersloth.net>
On Fri, 9 Feb 2001 16:34:51 -0000, Tony O Sullivan <tony@codeisland.net> wrote:
> Hi all,
> I know this seems like a simple problem but I can't figure out the best way
> of doing this so I thought i would seek advice!
>
> I am searching strings for the occurances of a term,
[snip]
#!/usr/bin/perl -w
use strict;
use diagnostics -verbose;
$_ = "'Search the string there,' said another.";
print scalar(@_ = /the/g), "\n";
------------------------------
Date: Fri, 09 Feb 2001 18:08:55 GMT
From: tunneling@my-deja.com
Subject: Re: Two dimensional arrays
Message-Id: <961bnf$b0b$1@nnrp1.deja.com>
Maybe I should be more explicit. I am reading in a file that has text
in this format:
ITBFYTU
SHEOOON
ITRU D
ST E
E R
R S
T
A
N
D
There is a 7x10 matrix that exist, with null characters in many of the
cells. In my case the matrix can change sizes between files. I need to
read this file and print to a new file:
IS THIS BETTER FOR YOU TO UNDERSTAND
I was thinking of 'building' a 2D array and with some fairly simple
index manipulation printing the text an element at a time. I was
thinking of something like print each column while() a row exist.
I have this so far:
#text previously read from file and stored to @lines
$row = 0;
foreach (@lines) {
$row++;
s/(\S)/${1};/ig;
@array = split(/;/, $_);
$column = 0;
foreach (@array){
$io[$row][$column++] = $_;
}
}
When I force values to a variable $io[][] they stick, but reading them
in this way doesnt seem to work for me. Thanks for any suggestions.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 257
**************************************