[18608] in Perl-Users-Digest
Perl-Users Digest, Issue: 776 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 26 21:06:03 2001
Date: Thu, 26 Apr 2001 18:05:11 -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: <988333510-v10-i776@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 26 Apr 2001 Volume: 10 Number: 776
Today's topics:
Re: [Very OT] Sex and apathy (Tim Hammerquist)
Re: Am I in the perl Debugger? (Abigail)
Re: binary operations (Abigail)
Re: binary operations (Jay Tilton)
DBD::DB2 and CLOB? <shah@typhoon.xnet.com>
Re: Foreing Newbie: How can I convert a perl source cod <mececo99@tamarugo.cec.uchile.cl>
Re: Getting partition size from perl script (Abigail)
Help: PPM on unix? u518615722@spawnkill.ip-mobilphone.net
Re: Help: PPM on unix? <Jonathan.L.Ericson@jpl.nasa.gov>
Re: How to down size /usr/bin/perl ? <centreman_19@NOSPAMyahoo.com>
Re: How to down size /usr/bin/perl ? <pally@axtronics.com.tw>
Re: How to enclose scalar for readability? <bart.lateur@skynet.be>
Re: How to enclose scalar for readability? (Anno Siegel)
Re: loop variable scope (Jay Tilton)
Re: loop variable scope (Anno Siegel)
Re: loop variable scope <Jonathan.L.Ericson@jpl.nasa.gov>
Re: re-sizing GIF images on the fly (Abigail)
Re: Regexp Question <hpya78@postoffice.pacbell.net>
Re: Regexp Question <bart.lateur@skynet.be>
Re: Regular expression for zip code <notmyrealemail@fake.com>
Re: Regular expression for zip code <notmyrealemail@fake.com>
Re: Regular expression for zip code <notmyrealemail@fake.com>
Re: Regular expression for zip code <notmyrealemail@fake.com>
Re: Regular expression for zip code (Gary E. Ansok)
Re: Regular expression for zip code <sharding@ccbill.com>
Re: Regular expression for zip code <sharding@ccbill.com>
Re: Regular expression for zip code <notmyrealemail@fake.com>
Re: Regular expression for zip code <notmyrealemail@fake.com>
Re: removing the \n from the data obtained from a text <chrisw+usenet@dynamite.com.au>
require "file.pl" (vs use ?) to access subroutine in fi <squid@panix.com>
revision of first CGI <vtbowes@superaje.com>
Re: revision of first CGI <centreman_19@NOSPAMyahoo.com>
Re: run by click in linux (Abigail)
Re: s///g count <martin@djernaes.net>
Re: So what do YOU use Perl for? (E.Chang)
Re: Tcl is faster then perl. (Tim Hammerquist)
Re: total newbie <johnno@nospam.casebook.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 26 Apr 2001 23:49:20 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: [Very OT] Sex and apathy
Message-Id: <slrn9ehdc2.i57.tim@vegeta.ath.cx>
I've seen some strange threads in this group, but damn.
Someone wrote:
> Uri Guttman wrote:
>
> > sounds as if you haven't had enough sex yourself.
>
> Whatever.
>
> > why don't you go into
> > the corner and masturbate for an hour or so?
>
> Please. An hour? Won't take me that long... Thirty seconds should
> suffice, surely - and that includes set-up and mop-up. Hmm, the tone is
> unnecessarily lowering here...
>
> > i am sure you do it better
> > than you code perl and the chill will do you good.
>
> Ooh! Casting aspersions on my sex life and my Perl code. I must
> attempt to defend both!!
>
> Ah, fuck it. Who cares, really?
Ok, this was weak.
--
-Tim Hammerquist <timmy@cpan.org>
Perl gives you enough rope to hang yourself and your neighbor.
-- Randal L. Schwartz
------------------------------
Date: Thu, 26 Apr 2001 22:16:39 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Am I in the perl Debugger?
Message-Id: <slrn9eh7i7.jr5.abigail@tsathoggua.rlyeh.net>
Broc Seib (bseib@icd.cc.purdue.edu) wrote on MMDCCXCV September MCMXCIII
in <URL:news:9c9mpk$8js$1@mozo.cc.purdue.edu>:
:) I need my code to behave a little different if I am running it
:) in the perl debugger.
Wouldn't that break the point of having a debugger in the first place?
If your code behaves differently, you are suddenly debugging a
different program.
:) Is there a variable I can check to know for
:) sure if I am in the debugger or not?
All special variables are discussed in man perlvar.
Abigail
--
perl -le 's[$,][join$,,(split$,,($!=85))[(q[0006143730380126152532042307].
q[41342211132019313505])=~m[..]g]]e and y[yIbp][HJkP] and print'
------------------------------
Date: Thu, 26 Apr 2001 22:19:08 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: binary operations
Message-Id: <slrn9eh7ms.jr5.abigail@tsathoggua.rlyeh.net>
RayJ (rayj00@yahoo.com) wrote on MMDCCXCV September MCMXCIII in
<URL:news:3AE831DE.8020705@yahoo.com>:
][
][
][ Ok, getting a little farther but still stuck on this:
][
][ my $infomask = hex '1f';
][ my $codemask = hex '60';
][
][ # at this point, @bits = 10000000
That's one hell of a large array. How much memory does your computer have?
][ if ((@bits & $infomask) == 0x0) {do something because bottom 5 bits are
][ zero }
][
][ I am failing this test and not executing the then part.
I bet you fail to understand what the value of an array in scalar
context is. I also fail to see the intend of your code.
Abigail
--
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))
------------------------------
Date: Thu, 26 Apr 2001 22:24:15 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: binary operations
Message-Id: <3ae89184.53532955@news.erols.com>
On Thu, 26 Apr 2001 11:18:17 -0400, RayJ <rayj00@yahoo.com> wrote:
>I did a: $bits = unpack("B*",pack("H*",$values[$usi+$octet]));
>and $bits now equal 10000000
>Still don't work.
You misunderstood a key sentence of Bart's reply, which was...
>Bart Lateur wrote:
>>It should be a number with that as a binary representation.
You got it backwards. $bits now contains a string that is a binary
representation of the integer, not the integer itself.
Try it after changing 'B*' to 'C' in the unpack.
------------------------------
Date: Thu, 26 Apr 2001 23:11:13 +0000 (UTC)
From: Hemant Shah <shah@typhoon.xnet.com>
Subject: DBD::DB2 and CLOB?
Message-Id: <9ca9uh$250$1@flood.xnet.com>
Folks,
How can I insert the array into a CLOB column?
Here is my table definition:
CREATE TABLE "BILLING "."DOCUMENTS"
("INVOICE_NUM" CHAR(15) NOT NULL,
"DOC_TYPE_ID" CHAR(5) NOT NULL,
"DOC" CLOB(2097152) LOGGED NOT COMPACT) IN USERSPACE1 ;
In my perl script is create array as follows:
sub Function1
{
# Do something
@RthArray;
}
sub Function2
{
# Do something
@RthArray;
}
sub Function3
{
# Do something
@RthArray;
}
push(@Documents, Function1());
push(@Documents, Function2());
push(@Documents, Function3());
$InsertDocumentsStmt = "INSERT INTO BILLING.DOCUMENTS
(INVOICE_NUM,DOC_TYPE_ID,DOC)
VALUES
(?,?,?)
;";
$InsertDocumentsStmtHandle = $DbHandle->prepare($InsertDocumentsStmt);
$InsertDocumentsStmtHandle->bind_param(1,$InvoiceNum);
$InsertDocumentsStmtHandle->bind_param(2, "COV");
$InsertDocumentsStmtHandle->bind_param(3,@Documents,SQL_CLOB);
$InsertDocumentsStmtHandle->execute();
$InsertDocumentsStmtHandle->finish;
$DbHandle->commit;
When I run the script I get following error:
phase4.pl: ERROR DBI bind_param: invalid number of parameters: handle + 7
Usage: $h->bind_param($parameter, $var [, \%attr]) at ./phase4.pl line 525.
Line 525 is the bind_param(3,@Documents,SQL_CLOB); line.
I the lines as follows:
$InsertDocumentsStmtHandle->bind_param(1,\$InvoiceNum);
$InsertDocumentsStmtHandle->bind_param(3,\@Documents,SQL_CLOB);
I get following error:
phase4.pl: ERROR DBD::DB2::st execute failed: [IBM][CLI Driver] CLI0109E
String data right truncation. SQLSTATE=22001 at ./phase4.pl line 526.
Thanks in advance.
--
Hemant Shah /"\ ASCII ribbon campaign
E-mail: NoJunkMailshah@xnet.com \ / ---------------------
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.
------------------------------
Date: Thu, 26 Apr 2001 17:59:30 -0400
From: "Gian Paulo Rondanelli" <mececo99@tamarugo.cec.uchile.cl>
Subject: Re: Foreing Newbie: How can I convert a perl source code in a binary file
Message-Id: <9ca6gb$sbt$1@news.cec.uchile.cl>
Thanks, I am sure that it was what looked for !
------------------------------
Date: Thu, 26 Apr 2001 22:20:41 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Getting partition size from perl script
Message-Id: <slrn9eh7pp.jr5.abigail@tsathoggua.rlyeh.net>
Robert Fonda (rlf@proimages.net) wrote on MMDCCXCV September MCMXCIII in
<URL:news:3AE8809F.578BD38D@proimages.net>:
}} What is the best way for a perl script to obtain the size of free space
}} on a partition?
system df => '-k';
Abigail
--
map{${+chr}=chr}map{$_=>$_^ord$"}$=+$]..3*$=/2;
print "$J$u$s$t $a$n$o$t$h$e$r $P$e$r$l $H$a$c$k$e$r\n";
------------------------------
Date: Thu, 26 Apr 2001 19:33:57 GMT
From: u518615722@spawnkill.ip-mobilphone.net
Subject: Help: PPM on unix?
Message-Id: <l.988313637.1283294677@[198.138.198.252]>
On windows NT, we have a PPM to
manager the module, do you have
similar utility on unix?
thanks
--
Sent by dbadba62 from hotmail included in com
This is a spam protected message. Please answer with reference header.
Posted via http://www.usenet-replayer.com/cgi/content/new
------------------------------
Date: 26 Apr 2001 23:42:54 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Help: PPM on unix?
Message-Id: <86oftjns75.fsf@jon_ericson.jpl.nasa.gov>
u518615722@spawnkill.ip-mobilphone.net writes:
> On windows NT, we have a PPM to
> manager the module, do you have
> similar utility on unix?
cpan
Jon
------------------------------
Date: Thu, 26 Apr 2001 15:20:57 -0700
From: "Brandon Thornburg" <centreman_19@NOSPAMyahoo.com>
Subject: Re: How to down size /usr/bin/perl ?
Message-Id: <9ca797$152$1@fremont.ohsu.edu>
*looks paranoiacally for Billy Goats Gruff*
"Pally Kuo" <pally@axtronics.com.tw> wrote in message
news:9c8lg8$1fsq$1@ccreader.nctu.edu.tw...
> Hello,
> I wanna down size perl interpreter /usr/bin/perl
> the original size is about 502k
> I must make it to below 200k, in order to post into flash rom...
> Is there any way to do that ?
>
>
>
------------------------------
Date: Fri, 27 Apr 2001 08:27:43 +0800
From: "Pally Kuo" <pally@axtronics.com.tw>
Subject: Re: How to down size /usr/bin/perl ?
Message-Id: <9caea9$2n89$1@ccreader.nctu.edu.tw>
what should I do if all I want is socket function ?
"Andy Dougherty" <doughera@maxwell.phys.lafayette.edu> ¼¶¼g©ó¶l¥ó
news:slrn9egg9b.cnu.doughera@maxwell.phys.lafayette.edu...
> In article <9c8lg8$1fsq$1@ccreader.nctu.edu.tw>, Pally Kuo wrote:
> >Hello,
> >I wanna down size perl interpreter /usr/bin/perl
> >the original size is about 502k
> >I must make it to below 200k, in order to post into flash rom...
> >Is there any way to do that ?
>
> No, not really. You need to get rid of approximately 60% of perl to
> make it fit. You could start chopping out parts that you know you
> don't want (e.g. if you don't want to do pattern matching, you can
> replace all of reg*.c with simple empty stubs) but even such radical
> surgery is unlikely to get rid of anywhere near enough.
> To be concrete, on my system, toke.o alone is over 300k. It doesn't
> look feasible to squeeze all of perl into 200k.
>
> --
> Andy Dougherty doughera@lafayette.edu
> Dept. of Physics
> Lafayette College, Easton PA 18042
------------------------------
Date: Thu, 26 Apr 2001 22:06:11 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How to enclose scalar for readability?
Message-Id: <sv6hetoe2040uh08kb7pg5a0u7d7btapqn@4ax.com>
Abigail wrote:
>// but this works, too:
>//
>// "$together\Er"
>
>
>Really? Now, where is that documented? Or did you typo?
"r" too much.
The "\E" provides a break, but doesn't insert anything by itself.
--
Bart.
------------------------------
Date: 26 Apr 2001 22:17:48 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to enclose scalar for readability?
Message-Id: <9ca6qc$mt9$1@mamenchi.zrz.TU-Berlin.DE>
According to Bart Lateur <bart.lateur@skynet.be>:
> Anno Siegel wrote:
>
> >> print "${togethe}r${here}";
> >>
> >> Note that the braces around $here aren't strictly necessary, but they
> >> seem to provide balance. YMMV.
> >
> >Side note: It's interesting that this construct is not a case of
> >the ${ BLOCK } dereferencing syntax. While the latter would work
> >for ${togethe}, it would involve the bareword "togethe" (hmm, how
> >to quote a bareword?) and a symref to $togethe. The behavior
> >against warnings and strict shows that it is special-cased.
>
> Plus: it works for lexicals, too. As Anno should know: symbolic
> references, don't.
Oh, right. This shows that it doesn't just exempt the bit from
warnings and strictures and otherwise relies on the ${ BLOCK}
mechanism.
Anno
------------------------------
Date: Thu, 26 Apr 2001 22:46:36 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: loop variable scope
Message-Id: <3ae89be9.56194474@news.erols.com>
On 26 Apr 2001 20:50:25 GMT, rasunci@qual-pro.no-spam.com wrote:
>I'm hoping someone can explain. Consider:
>
>use strict;
>my $a = '';
>my @ar = ('1');
>print $a;
>foreach $a (@ar) { print $a; }
>print $a;
>
>Inside the loop, $a = elements in @ar. Outside the loop,
>$a = value before the loop. I would expect $a to keep its
>last value inside the loop.
This behavior is documented in perlsyn.
$a is implicitly localized to a for loop when used as an alias for $_,
even though it may have had a lexical scope declared earlier.
>Same thing happens when using,
>
>while($a=shift(@ar)) {...}
The same thing is most definitely not happening, though your code may
make it look that way. The original value of $a is obliterated from
the beginning. When there are no elements in the array, shift returns
undef, so that's what is in $a when the loop exits.
Whether $a = '' or $a = undef, print $a gives the same appearance.
>But if I use,
>
>while(@ar) { $a=shift(@ar); ... }
>
>I get the result I want. What's going on?
That's different again. In the previous example, $a is assigned as
part of the loop condition. Here, it is not assigned until the loop
condition has passed.
------------------------------
Date: 26 Apr 2001 22:51:28 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: loop variable scope
Message-Id: <9ca8pg$qas$1@mamenchi.zrz.TU-Berlin.DE>
According to <rasunci@qual-pro.no-spam.com>:
> Hi,
>
> I'm hoping someone can explain. Consider:
>
> use strict;
> my $a = '';
> my @ar = ('1');
> print $a;
> foreach $a (@ar) { print $a; }
> print $a;
>
> Inside the loop, $a = elements in @ar. Outside the loop,
> $a = value before the loop. I would expect $a to keep its
> last value inside the loop.
The variable $a is implicitly localized by foreach, as the
documentation in perlsyn says.
> Same thing happens when using,
>
> while($a=shift(@ar)) {...}
No, quite a different thing happens here. Unlike foreach, while
does no explicit localization (also documented). The loop is
exited when $a becomes boolean false. If you look closely, you
will find that after the loop $a is undefined, whereas it was an
empty string before.
Also note that the loop will exit prematurely (presumably) when
one of the elements of @ar has a value that is boolean false.
> But if I use,
>
> while(@ar) { $a=shift(@ar); ... }
Now this is better. Loop control ensures that the loop is only
ended when @ar is fully used up. Then the loop isn't entered
again, so $a retains the last element of @ar.
Anno
------------------------------
Date: 26 Apr 2001 22:05:37 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: loop variable scope
Message-Id: <86hezb1fm6.fsf@jon_ericson.jpl.nasa.gov>
rasunci@qual-pro.no-spam.com writes:
> Hi,
>
> I'm hoping someone can explain. Consider:
>
> use strict;
> my $a = '';
> my @ar = ('1');
> print $a;
> foreach $a (@ar) { print $a; }
> print $a;
>
> Inside the loop, $a = elements in @ar. Outside the loop,
> $a = value before the loop. I would expect $a to keep its
> last value inside the loop.
From perlsyn:
The "foreach" loop iterates over a normal list value and
sets the variable VAR to be each element of the list in
turn. If the variable is preceded with the keyword "my",
then it is lexically scoped, and is therefore visible only
within the loop. Otherwise, the variable is implicitly
local to the loop and regains its former value upon exit-
ing the loop. If the variable was previously declared
with "my", it uses that variable instead of the global
one, but it's still localized to the loop.
Jon
------------------------------
Date: Thu, 26 Apr 2001 22:13:09 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: re-sizing GIF images on the fly
Message-Id: <slrn9eh7bl.jr5.abigail@tsathoggua.rlyeh.net>
Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMDCCXCV
September MCMXCIII in <URL:news:9c9uvb$fca$4@mamenchi.zrz.TU-Berlin.DE>:
)) According to Andrew Boswell <graham@dragroup.com>:
))
)) > ...then creates a thumbnail of it on the fly. ...
))
)) Animal tormentor! What will they think of next?
Bees humming advertisements and porn lady bugs.
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'
------------------------------
Date: Thu, 26 Apr 2001 16:50:10 -0700
From: Peter White <hpya78@postoffice.pacbell.net>
Subject: Re: Regexp Question
Message-Id: <3AE8B432.36B615F9@postoffice.pacbell.net>
Here is my script
File:
aa 45 23 22
bb 2 12 67
dd 99 98 100
ff 101 99 100
mm 56 87 1
nn 10000 999 1
------------------------
Ouput should be:
aa 45 23 22
bb 2 12 67
dd 99 98 100
mm 56 87 1
#!/user/bin/perl -w
open(FILE, "abc.txt") || die "Cannot open\n";
@abc=(<FILE>);
foreach $info(@abc)
{
($word, @nums)=split(/\s+/, $info);
foreach $digit(@nums)
{
if($digit>= 0 && $digit <=100)
{
print " $word @nums\n";
}
}
}
Bernard El-Hagin wrote:
> On Wed, 25 Apr 2001 00:44:27 -0700, Peter White <hpya78@postoffice.pacbell.net>
> wrote:
> >Hi,
> >
> >I have a file like:
> >
> >File:
> > 10 20 30 40
> > 100 20 50 66
> > 200 300 400 500
> >
> >How to write a Regexp to get the record between 0 and 100?
>
> Show us what you've tried so far and we'll help you fix it.
>
> Cheers,
> Bernard
> --
> perl -e's;;s,,Just another Perl hacker,;and$\="\r"and
> $$=q!print${"\x27"}!;$;=qq.$0..q.v..qq!al $$!;$;=~s-\---;
> /^....*(?{$|=eval$;;select($Just,$another,$Perlhacker,0.1)}).{25}/x;'
------------------------------
Date: Fri, 27 Apr 2001 00:43:36 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Regexp Question
Message-Id: <n7ghet86qnsc2b4kb7c3q4mvuq0nkan6ap@4ax.com>
Peter White wrote:
>I have a file like:
>
>File:
> 10 20 30 40
> 100 20 50 66
> 200 300 400 500
>
>How to write a Regexp to get the record between 0 and 100?
There's no need to repeat that question in a new thread. Thank you.
--
Bart.
------------------------------
Date: Thu, 26 Apr 2001 22:18:16 GMT
From: "BarryK" <notmyrealemail@fake.com>
Subject: Re: Regular expression for zip code
Message-Id: <I81G6.30497$U4.6511202@news1.rdc1.tn.home.com>
A solution.
s< (\b\d{5}(?!-)\b) | (\b\d{5}-\d{4}\b) > <X>xg;
"BarryK" <notmyrealemail@fake.com> wrote in message
news:65YF6.28957$U4.6334726@news1.rdc1.tn.home.com...
> I want to create a regular expression that will replace any legitimate zip
> code in either five digit format or 5-4 digit format with something.
>
> The following regular expression does not work!
>
> s< (\b\d{5}\b) | (\b\d{5}-\d{4}\b) > <X>x;
>
> From the number "12345-1234", it will return "X-1234".
>
> Any ideas?
>
>
------------------------------
Date: Thu, 26 Apr 2001 22:30:52 GMT
From: "BarryK" <notmyrealemail@fake.com>
Subject: Re: Regular expression for zip code
Message-Id: <wk1G6.30538$U4.6519848@news1.rdc1.tn.home.com>
None of these last four work, it pains me to say!
"Ren Maddox" <ren@tivoli.com> wrote in message
news:m3n193ttso.fsf@dhcp9-172.support.tivoli.com...
> On Thu, 26 Apr 2001, sharding@ccbill.com wrote:
>
> > "BarryK" <notmyrealemail@fake.com> wrote in message
> >>
> >> The following regular expression does not work!
> >>
> >> s< (\b\d{5}\b) | (\b\d{5}-\d{4}\b) > <X>x;
> >>
> >> From the number "12345-1234", it will return "X-1234".
> >
> Also, depending on your exact need you are probably better off just
> using a single set of capturing parens around the entire "|" expression
> (and the "\b"-s can be moved outside of the expression):
>
> s< \b (\d{5}-\d{4} | \d{5}) \b > <X>x;
>
> Of course, Shay's suggestion, with a slight modification for capturing
> parens, plus a fix to prevent things like 12345-1234-1234, is probably
> better:
>
> s< \b ( \d{5} (?: -\d{4} )? ) \b > <X>x;
>
> Finally, all of these fail -- in my opinion -- to properly account for
> the fact that "-" adjacent to a digit is a word boundary, so they
> change "123-12345-123" to "123-X-123". Here's one that is more
> strict, though I'm not sure what the best definition is in this case:
>
> s/ (?: ^ | (?<= \s ) ) ( \d{5} (?: -\d{4} )? ) (?= \s | $ ) /X/x;
>
> More permissive:
>
> s/ (?: ^ | (?<= [^\d-] ) ) ( \d{5} (?: -\d{4} )? ) (?= [^\d-] | $ )
/X/x;
>
> That last allows for things like "Zip:12345-6789" or "12345-6789, "
> but still blocks "12345-6789-123".
>
> --
> Ren Maddox
> ren@tivoli.com
------------------------------
Date: Thu, 26 Apr 2001 23:04:24 GMT
From: "BarryK" <notmyrealemail@fake.com>
Subject: Re: Regular expression for zip code
Message-Id: <YP1G6.30615$U4.6541713@news1.rdc1.tn.home.com>
I popped this in my code:
==
use warnings;
use diagnostics;
$_ = "12345 12345-1234 123-12345-4444 12345-1234-1234 Zip:12345-6789 ";
s< \b\d{5}(?!-)\b | \b(?<! -)\d{5}-\d{4}(?!-)\b > <X>xg;
print $_;
==
this solution ought to work, but unfortunately it won't compile. What gives?
------------------------------
Date: Thu, 26 Apr 2001 23:05:45 GMT
From: "BarryK" <notmyrealemail@fake.com>
Subject: Re: Regular expression for zip code
Message-Id: <dR1G6.30617$U4.6542836@news1.rdc1.tn.home.com>
The best solution I've found:
==
use warnings;
use diagnostics;
$_ = "12345 12345-1234 123-12345-4444 12345-1234-1234 Zip:12345-6789 ";
s< \b\d{5}(?!-)\b | \b[^-]\d{5}-\d{4}(?!-)\b > <X>xg;
print $_;
------------------------------
Date: 26 Apr 2001 23:43:14 GMT
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: Regular expression for zip code
Message-Id: <9cabqi$pqc@gap.cco.caltech.edu>
In article <YP1G6.30615$U4.6541713@news1.rdc1.tn.home.com>,
BarryK <notmyrealemail@fake.com> wrote:
> s< \b\d{5}(?!-)\b | \b(?<! -)\d{5}-\d{4}(?!-)\b > <X>xg;
>
>this solution ought to work, but unfortunately it won't compile. What gives?
When you use <> (or any other balanced pair) as a delimiter for
the substitution, matching, or quoting operators, those
characters must balance exactly. The extra "<" from your
look-behind clause throws this balance off.
Escaping the < as \< would make the delimiters match,
but of course then you'd lose the regular-expression magic.
If you were to use [] delimiters, it should work (since you don't
use those characters). Or it should work with {} delimiters
(since those are balanced).
This is intended to let you write expressions like
qq(See the (extra) parentheses?) , but it can surprise you
if you're not expecting it.
-- Gary Ansok
------------------------------
Date: Thu, 26 Apr 2001 17:25:06 -0700
From: "Shay Harding" <sharding@ccbill.com>
Subject: Re: Regular expression for zip code
Message-Id: <9cado3$5pg$1@node17.cwnet.frontiernet.net>
"BarryK" <notmyrealemail@fake.com> wrote in message
news:dR1G6.30617$U4.6542836@news1.rdc1.tn.home.com...
> The best solution I've found:
>
> ==
> use warnings;
> use diagnostics;
>
> $_ = "12345 12345-1234 123-12345-4444 12345-1234-1234 Zip:12345-6789 ";
>
> s< \b\d{5}(?!-)\b | \b[^-]\d{5}-\d{4}(?!-)\b > <X>xg;
>
> print $_;
The above expression, for me, produced very strange results. Maybe I copied
it incorrectly? I did notice that none of the expressions I saw so far
account for something like '12345-12345'. With this string all digits after
the '-' are replaced so '12345-X' is the result.
This expression works... mostly:
s/\b(?<!-)\d{5}(-\d{4})*(?!-)\b/X/g;
It is amost the same as a previous expresion except the OR is gone (hmm,
which would be more efficient?, or maybe the regex code expands the above to
the equiv of an OR?).
I said it works 'mostly' because this doesn't catch instances of 'A=12345'
or the like. It will still happily return 'A=X'.
Shay
------------------------------
Date: Thu, 26 Apr 2001 17:53:09 -0700
From: "Shay Harding" <sharding@ccbill.com>
Subject: Re: Regular expression for zip code
Message-Id: <9cafcm$192c$1@node17.cwnet.frontiernet.net>
>
> s/\b(?<!-)\d{5}(-\d{4})*(?!-)\b/X/g;
>
Sorry, my last (above) expression won't work without changing the '*' into a
'?'. Darn greedy little guy.
s/\b(?<!-)\d{5}(-\d{4})?(?!-)\b/X/g;
Shay
------------------------------
Date: Fri, 27 Apr 2001 01:01:43 GMT
From: "BarryK" <notmyrealemail@fake.com>
Subject: Re: Regular expression for zip code
Message-Id: <Xx3G6.30691$U4.6631660@news1.rdc1.tn.home.com>
You, sir, are a genius. To me.
"Gary E. Ansok" <ansok@alumni.caltech.edu> wrote in message
news:9cabqi$pqc@gap.cco.caltech.edu...
> In article <YP1G6.30615$U4.6541713@news1.rdc1.tn.home.com>,
> BarryK <notmyrealemail@fake.com> wrote:
> > s< \b\d{5}(?!-)\b | \b(?<! -)\d{5}-\d{4}(?!-)\b > <X>xg;
> >
> >this solution ought to work, but unfortunately it won't compile. What
gives?
>
> When you use <> (or any other balanced pair) as a delimiter for
> the substitution, matching, or quoting operators, those
> characters must balance exactly. The extra "<" from your
> look-behind clause throws this balance off.
>
> Escaping the < as \< would make the delimiters match,
> but of course then you'd lose the regular-expression magic.
>
> If you were to use [] delimiters, it should work (since you don't
> use those characters). Or it should work with {} delimiters
> (since those are balanced).
>
> This is intended to let you write expressions like
> qq(See the (extra) parentheses?) , but it can surprise you
> if you're not expecting it.
>
> -- Gary Ansok
------------------------------
Date: Fri, 27 Apr 2001 01:04:53 GMT
From: "BarryK" <notmyrealemail@fake.com>
Subject: Re: Regular expression for zip code
Message-Id: <VA3G6.30698$U4.6635301@news1.rdc1.tn.home.com>
SOLUTION TO ZIP CODE PROBLEM (FINALLY!!)
use warnings;
use diagnostics;
$_ = <<'ENDIT';
12345 12345-1234 123-12345-4444 12345-1234-1234 Zip:12345-6789 A=12345
and this is the next line.
ENDIT
s[ \b\d{5}(?!-)\b | \b(?<! -)\d{5}-\d{4}(?!-)\b ] [X]xg;
print $_;
------------------------------
Date: Fri, 27 Apr 2001 11:01:21 +1000
From: "Chris W" <chrisw+usenet@dynamite.com.au>
Subject: Re: removing the \n from the data obtained from a text area in a form
Message-Id: <kz3G6.6$xB6.86101@news.interact.net.au>
"Richard Antreasian" <insmov@tiac.net> wrote in message
news:insmov-ya02408000R2204011246090001@news.tiac.net...
> I tried to replace all \n by subsituting \n with <p> using a regular
expression
> $data{thestory}=~s/\n/<P>/g;
> This dosent seem to make the text into one line,
Works fine for me under Activestate Build 623:
#!perl
use strict;
use warnings;
my $formdata = "first line\nsecond line\nthird line\n\nfourth line\n";
$formdata =~ s/\n/<P>/g;
print $formdata;
__END__
prints:
first line<P>second line<P>third line<P><P>fourth line<P>
Are you sure the data you're getting into the equivalent of $formdata is
what you think it is?
------------------------------
Date: 26 Apr 2001 20:35:49 -0400
From: Yeoh Yiu <squid@panix.com>
Subject: require "file.pl" (vs use ?) to access subroutine in file.pl ?
Message-Id: <oxg1yqf2n8a.fsf@panix1.panix.com>
In the code below, m.pl is the main program and s.pl contains a
subroutine to be called by m.pl . (I've simplified the code
as much as I could and still demonstrate my error
-- please, no flames like 'that's a lame sub(), it only returns 3'.
I want to run m.pl, and have it call the sub chk_ps(); I'm not
interested in running anything else in s.pl other than
chk_ps().
This code works as intended if I leave this block in s.pl:
my $result = chk_ps("bashing");
open (NULL, ">/dev/null") or die "No null ! $! \n";
print NULL "Result = $result\n";
close(NULL);
If I comment out these filehandle lines, as shown below, I get
$ ./m.pl
s.pl did not return a true value at ./m.pl line 3.
$
Interestingly, my perldoc -f require gives no example of the form
require "filename.pl";
So do I need s.pl to return a value to m.pl, or do I need only
chk_ps() to return the value ?
Or is 'require' not the best way to import subroutines, and use/eval
somehow more apropos ?
And why does writing to a filehandle provide a return value in this manner ?
==============================
#!/usr/bin/perl -w
use strict;
# this is s.pl
my $result = chk_ps("bashing");
# open (NULL, ">/dev/null") or die "No null ! $! \n";
# print NULL "Result = $result\n";
# close(NULL);
sub chk_ps {
my @ps_oi = @_; # p of interest
my $ecode = 3; # simple logic
return $ecode;
}
==============================================
#!/usr/bin/perl -w
use strict;
require "s.pl";
# this is m.pl
my $result1 = chk_ps("httpd"); # 1 running, 0 not, 3 zombie
print "Result1 = $result1\n\n";
==============================================
$ ./m.pl
s.pl did not return a true value at ./m.pl line 3.
$
==============================================
$ ./m.pl
Result1 = 3
$
YY
squid @ panix . com
------------------------------
Date: Thu, 26 Apr 2001 18:22:04 -0500
From: "Tom Bowes" <vtbowes@superaje.com>
Subject: revision of first CGI
Message-Id: <ne1G6.2344$w7.774480@e3500-chi1.usenetserver.com>
#!/usr/bin/perl -w
use diagnostics;
use strict;
use CGI ':standard';
print header();
print start_html();
sub write{
open (APPEND, ">>messages.htm") or die "$! error trying to append";
print APPEND "Name:" or die "$!";
print APPEND (param("name")) or die "$!";
print APPEND (param("message")) or die "$!";
}
print "Name: ",textfield('name');
print "Message: ",textfield('message');
#here I need toknow how to get as ubmit button and get it to call the write
sub
print end_html();
can you help me with that one line and anything else you see wrong?
------------------------------
Date: Thu, 26 Apr 2001 15:31:12 -0700
From: "Brandon Thornburg" <centreman_19@NOSPAMyahoo.com>
Subject: Re: revision of first CGI
Message-Id: <9ca7se$1f8$1@fremont.ohsu.edu>
I think this will help you...
http://www.perl.com/pub/doc/manual/html/lib/CGI.html#CREATING_A_SUBMIT_BUTTO
N
"Tom Bowes" <vtbowes@superaje.com> wrote in message
news:ne1G6.2344$w7.774480@e3500-chi1.usenetserver.com...
> #!/usr/bin/perl -w
> use diagnostics;
> use strict;
> use CGI ':standard';
>
> print header();
> print start_html();
> sub write{
> open (APPEND, ">>messages.htm") or die "$! error trying to append";
> print APPEND "Name:" or die "$!";
> print APPEND (param("name")) or die "$!";
> print APPEND (param("message")) or die "$!";
> }
> print "Name: ",textfield('name');
> print "Message: ",textfield('message');
> #here I need toknow how to get as ubmit button and get it to call the
write
> sub
> print end_html();
>
> can you help me with that one line and anything else you see wrong?
>
>
>
>
>
------------------------------
Date: Thu, 26 Apr 2001 22:35:18 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: run by click in linux
Message-Id: <slrn9eh8l6.jr5.abigail@tsathoggua.rlyeh.net>
Ying Hu (yhu@mail.nih.gov) wrote on MMDCCXCV September MCMXCIII in
<URL:news:3AE85FA5.62F9FC08@mail.nih.gov>:
,, hi,
,, how can I run one perl script by click the icon in Linux. Thanks
Write the following C program, assuming your Perl program is in
"/path/to/program".
# include <unistd.h>
int main (int argc, char * argv []) {
execvp ("/path/to/program", argv);
exit (1);
}
Compile it, and then go to comp.lang.c and ask:
How can I run one C program by click the icon in Linux.
Alternatively, one can install Windows. That's pointy-clicky.
Abigail
------------------------------
Date: Thu, 26 Apr 2001 15:32:44 -0700
From: Martin Djernaes <martin@djernaes.net>
Subject: Re: s///g count
Message-Id: <3AE8A20C.6680BB57@djernaes.net>
Hi,
Anno Siegel wrote:
> Do you mean, something is replaced by itself? That is one way, but
> more complex situations exist. It can't be too hard to construct
> a s///g that changes "a" to "an" and "norange" to "orange", thereby
> busily transforming "anorange" into itself.
That's what I meant. Mine can't do that, and therefore I guess that the
check if the replace do something is faster (not that I actually do a
lot of them, but...)
Martin
------------------------------
Date: Fri, 27 Apr 2001 00:19:40 GMT
From: echang@netstorm.net (E.Chang)
Subject: Re: So what do YOU use Perl for?
Message-Id: <Xns908FCE5E715F8echangnetstormnet@207.106.92.86>
gbacon@HiWAAY.net (Greg Bacon) wrote in
<tedo83kg616877@corp.supernews.com>:
> In article <Xns908AD0E0378F1echangnetstormnet@207.106.92.86>,
> E.Chang <echang@netstorm.net> wrote:
>
> : [...] (Oh, and a hint: .html is preferred over .htm as an extension
> : for web documents - unless you're running your server on a Windows 3.x
> : machine)
>
> Think again. There's no necessary mapping between URIs and filenames.
> ObPerl: with Apache and mod_perl, it's trivial to create all sorts of
> cool mappings. grep /Lincoln Stein/, @WWW;
Didn't mean to suggest that there was - just trying to give a hint about
"rename 's/htm$/html/' *.htm" was doing without being too explicit.
--
Memo to self: Will you ever learn? Do _not_ attempt humor.
------------------------------
Date: Fri, 27 Apr 2001 00:11:15 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: Tcl is faster then perl.
Message-Id: <slrn9ehel6.i57.tim@vegeta.ath.cx>
Wenzel, Joel [CAR:VS11:EXCH] <coopvs14@americasm01.nt.com> wrote:
> Everyone was ignoring my question when I said perl was faster then Tcl
> so I switched it around.
* plonk *
--
-Tim Hammerquist <timmy@cpan.org>
Your question doesn't make any sense. You might as well ask whether
it is possible to grow vegetables from a painting, without becoming
Wednesday first.
-- Abigail, c.l.p.misc
------------------------------
Date: Wed, 25 Apr 2001 20:01:29 +1000
From: "Johnno" <johnno@nospam.casebook.org>
Subject: Re: total newbie
Message-Id: <3ae6a11d$0$25502$7f31c96c@news01.syd.optusnet.com.au>
"Gil G." <gil@nospam-keskydee.com> wrote:
> PS: Don't forget, the first line of your scripts probably should be:
> #!/usr/bin/perl
Or:
#!/usr/bin/perl -w
:-)
--
Johnno (johnno@nospam.casebook.org)
http://johnno.casebook.org
------------------------------
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 776
**************************************