[10812] in Perl-Users-Digest
Perl-Users Digest, Issue: 4413 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Dec 13 11:08:16 1998
Date: Sun, 13 Dec 98 08:00:26 -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 Sun, 13 Dec 1998 Volume: 8 Number: 4413
Today's topics:
Re: 80 column conversion (Bart Lateur)
Re: a simple puzzle (I suspect) <Mukke@get2net.dk>
Re: a simple puzzle (I suspect) (Bart Lateur)
Re: a simple puzzle (I suspect) (Mika Laari)
apache problem <tomo@mops.net>
Re: apache problem (Gil Price)
ASP and PerlScript <erlangen72@hotmail.com>
Re: Can't locate auto/Net/FTP/cd.al in @INC ... <gellyfish@btinternet.com>
Change the file attribute <ales.turai@ostrava.czcom.cz>
Re: Change the file attribute (Clay Irving)
Re: file locking question <gellyfish@btinternet.com>
Flock <support@counter.w-dt.com>
Re: memory usage (Kevin Reid)
Re: New to perl - pattern matching question <jsavarino@jps.net>
Re: New to perl - pattern matching question <jsavarino@jps.net>
Re: New to perl - pattern matching question <Allan@Due.net>
Re: New to perl - pattern matching question (Clay Irving)
Re: New to perl - pattern matching question (Larry Rosler)
Re: no UnderScore (was: Re: usage of $_ within nested l <tchrist@mox.perl.com>
Re: Perl multithread/multiprocess socket server example (Kyle Cordes)
Re: Question on Skalars & Arrays (Tad McClellan)
Re: Random integer numbers (1,2,3,4,5....,.....) HOW??? <stackhou@execpc.com>
Re: script f|r newsheader Auswahl <Allan@Due.net>
Re: send e-mail by port 25 in Perl !!! HELPME !!!!! (Bart Lateur)
Splitting a line at |'s <agjemmes@extremeonline.com>
Re: Splitting a line at |'s <Allan@Due.net>
Re: Splitting a string at a certain point (David Alan Black)
Re: Stripping of the _ (Larry Rosler)
Re: What is next book to read after Learning PERL ? <w_mitchell@technologist.com>
Re: What is next book to read after Learning PERL ? <tchrist@mox.perl.com>
Re: Why Is Perl not a Language? (Bart Lateur)
Re: Writing Perl with Notepad (Bart Lateur)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 13 Dec 1998 10:45:33 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: 80 column conversion
Message-Id: <3673922a.2338706@news.skynet.be>
Jaya_Kanajan wrote:
>I would like to add something to my code that
>will take any sequence of greater then three carriage returns/newlines and
>replace it with a single newline. The problem is, the fact that I use a while
>to go through the input file makes it messy to do a counter for the newlines.
>Is there a cleaner way to do this?
Ah. I've done something like this. It leaves at most one blank line. I
needed to clean up text copied from a spreadsheet; for some bizarre
reason, it sometimes included LOTS of empty rows.
Note that if reading in more than one file at a time, the blanks count
will be passed on to the next file. Not that this matters much,
especially if no file starts with an empty line.
while(<>) {
unless (/\S/) {
# empty line
next if $blanks++;
} else {
# something on it
undef $blanks;
}
print;
}
Bart.
------------------------------
Date: Sun, 13 Dec 1998 00:07:06 +0100
From: "Thomas Turn Jensen" <Mukke@get2net.dk>
Subject: Re: a simple puzzle (I suspect)
Message-Id: <pINc2.180$Jg2.637@news.get2net.dk>
Hi.. I'm pretty new.. but try this =>
$String =~ s/(\(\"?)(.*)(\"?\))/$1.lc($2).$3/ge;
Where $String should hold the data to be changed, and will hold the changed
data afterwards.
Hope this works for you..
(btw - if you should need to upcase later on - replace lc with uc
***
Thomas Turn Jensen
Icq uin => 8128636
IRC, Undernet => Mukke
***
So long, and thanks for all the fish
***
Dan DeVries skrev i meddelelsen <3671F8A5.4319F73C@earthlink.net>...
>I need to do something that looks pretty simple, but simple me, I
>am having some trouble:
>
>I need to downcase a string that WILL be quoted by () and MAY be quoted
>by ""
>if it follows a particular string. For example, if that string is CELL:
>
> CELL(XYZ) => CELL(xyz)
> CELL("XYZ") => CELL("xyz")
> nothing else changes.
>
>I'm not much of a perl expert, appreciate some help from you gurus.
>Email
>to ddevries@pdx.mentorg.com would be nice, but I'll watch the groups.
>
>Thanks,
>
>Dan.
>
>
>
------------------------------
Date: Sun, 13 Dec 1998 14:45:19 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: a simple puzzle (I suspect)
Message-Id: <3676d10e.1994985@news.skynet.be>
Dan DeVries wrote:
>I need to downcase a string that WILL be quoted by () and MAY be quoted
>by ""
>if it follows a particular string. For example, if that string is CELL:
>
> CELL(XYZ) => CELL(xyz)
> CELL("XYZ") => CELL("xyz")
> nothing else changes.
I think you mean that the quotes may contain anything (including ")")
except quotes? And that without quotes, you're limited to a "word"?
$_ = <<'END';
CELL(XYZ)
CELL("This is a TEST")
END
s/\bCELL\(("[^"]*"|\w+)\)/CELL(\L$1)/g;
print;
Bart.
------------------------------
Date: 13 Dec 1998 14:09:07 GMT
From: mlaari@kuha.cc.lut.fi (Mika Laari)
Subject: Re: a simple puzzle (I suspect)
Message-Id: <slrn777ik3.4ru.mlaari@kuha.cc.lut.fi>
Thomas Turn Jensen <Mukke@get2net.dk> wrote:
>$String =~ s/(\(\"?)(.*)(\"?\))/$1.lc($2).$3/ge;
This helped me to solve the problem my way, which is not
so different. First, I add "CELL" to the beginning of
the re, as was suggested in the request. To let multiple
quotes appear in the string, the *-quantifier is changed
non-greedy. And last, a change was made to grouping and
to matching of "'s in order to let braces to appear in the
quote. Now here's the substitution:
$String =~ s/(CELL\()(\"?)(.*?)(\2\))/$1.$2.lc($3).$4/ge;
--
- Mika Laari -
------------------------------
Date: Sun, 13 Dec 1998 13:24:55 +0100
From: Rumpelstielzchen <tomo@mops.net>
Subject: apache problem
Message-Id: <3673B216.A2F5405A@mops.net>
I installed an apacheserver on my win95 system because I heared it is
the best one.
But everytime I am trying to run a cgi-script it gives the following
error:
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator, tomo@mops.net and inform them
of the time the error occurred, and anything you
might have done that may have caused the error.
couldn't spawn child process: d:/arac/program/cgi-bin/counter.pl
Apache/1.3.3 Server at 127.0.0.1 Port 80
what's wrong?
------------------------------
Date: Sun, 13 Dec 1998 12:35:31 GMT
From: gprice@scsn.net (Gil Price)
Subject: Re: apache problem
Message-Id: <3673b2f8.52712917@news.scsn.net>
On Sun, 13 Dec 1998 13:24:55 +0100, Rumpelstielzchen <tomo@mops.net>
wrote:
>But everytime I am trying to run a cgi-script it gives the following
>error:
>Internal Server Error
>
>The server encountered an internal error or misconfiguration and was
>unable to complete your request.
>
>couldn't spawn child process: d:/arac/program/cgi-bin/counter.pl
>what's wrong?
Check to make sure the PATH statement in autoexec.bat includes the
perl directory, in mine it's "PATH=C:\perl\bin;etc...".
Also insure the first line of your Perl script refers to the perl
path, ie "#!/perl/bin/perl" this will be different from the default
for a script originally set up on a UNIX system.
Let me know if this helps!
Gil
Gil Price
Lexngton, SC
gprice@scsn.net
------------------------------
Date: Sun, 13 Dec 1998 01:00:47 -0800
From: "ErLanGen" <erlangen72@hotmail.com>
Subject: ASP and PerlScript
Message-Id: <74vvtc$ss8$1@ash.prod.itd.earthlink.net>
Hello,
The Win32, Build 502, Doc files have some ASP samples that
are in PerlScript. I read my html Perl Docs using the PWS (4.0). It
seems that PWS expects ASP to be in VBScript and I do have the
VBScript engine. Thus I get VBscript errors when I try to run these
pages. My question is:
What can I do to default the script engine to PerlScript. I have seen
these changes recommended on Matt's page at
http://www.fastnetltd.ndirect.co.uk/Perl/asp.pm
...Change the following :
HKEY_LOCAL_MACHINE\
SYSTEM\
CurrentControlSet\
Services\
W3SVC\
ASP\
LanguageEngines\
PerlScript
============
However, Im using Win95 and I dont see the
"LanguageEngine" key. Can I just add this key?
=============
I need help with this to make ASP pages using
Perl 5.00502. Thanks in advance, Mark ICQ22542142
mpryorREM@OVEsprintmail.com
http://wwp.mirabilis.com/22542142
------------------------------
Date: 13 Dec 1998 12:40:33 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Can't locate auto/Net/FTP/cd.al in @INC ...
Message-Id: <750ck1$254$1@gellyfish.btinternet.com>
On Tue, 08 Dec 1998 15:41:22 +0100 David Van den Brande <brandeda@se.bel.alcatel.be> wrote:
> Can someone help me to solve this problem:
>
> "Can't locate auto/Net/FTP/cd.al in @INC (@INC contains:
> /usr/local/lib/perl5.004/sun4-solaris/5.004 /usr/local/lib/perl5.004
> /usr/local/lib/perl5.004/site_perl/sun4-solaris
> /usr/local/lib/perl5.004/site_perl .) "
>
I would suggest that somehow your installation of Net::FTP is broken - the
best thing to do would be to reinstall it from scratch - if this file is
missing it is very probable that others are to and you could spend hours
fixing it up whereas a reinstall should only take about ten minutes.
/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: Sun, 13 Dec 1998 13:49:46 +0100
From: "Ales Turai" <ales.turai@ostrava.czcom.cz>
Subject: Change the file attribute
Message-Id: <3673bae8.0@news.cvut.cz>
Hi all,
I need a cgi script which change the file attribute to 755. Do anybody
know how to do it?
Thanks in advance,
Ales Turai
------------------------------
Date: 13 Dec 1998 09:43:15 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Change the file attribute
Message-Id: <750jq3$1ij@panix.com>
In <3673bae8.0@news.cvut.cz> "Ales Turai" <ales.turai@ostrava.czcom.cz> writes:
> I need a cgi script which change the file attribute to 755. Do anybody
>know how to do it?
chmod 0755, @executables;
--
Clay Irving
clay@panix.com
------------------------------
Date: 13 Dec 1998 12:01:11 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: file locking question
Message-Id: <750aa7$24p$1@gellyfish.btinternet.com>
On Thu, 10 Dec 1998 20:05:59 GMT Bart Lateur <bart.lateur@skynet.be> wrote:
>
> Danger, Will Robinson. (I'm not sure where I got that quote. A newsgroup
> post, I'm sure.)
>
Its what the robot in "Lost in Space" used to say when something *bad* was
about to happen.
Actually it could be that the Space Family Robinson got in that mess because
some programmer had screwed up with the file locking on their guidance
system :-)
/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: Sun, 13 Dec 1998 02:56:22 -0600
From: Mike <support@counter.w-dt.com>
Subject: Flock
Message-Id: <36738136.C46A78CC@counter.w-dt.com>
Do you need the seek(MBOX, 0, 2); in there? What exactly does it do?
sub lock {
flock(MBOX,LOCK_EX);
# and, in case someone appended
# while we were waiting...
seek(MBOX, 0, 2);
}
------------------------------
Date: Sun, 13 Dec 1998 10:37:07 -0500
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: memory usage
Message-Id: <1djy0vk.590owq1yq15r4N@slip166-72-108-30.ny.us.ibm.net>
Boson <boson@earthlink.net> wrote:
> I have a quick question. Assume I have a (pretty big) hash called %h.
> Is my perl program using less memory if I use the hash as
>
> foreach (keys \%h) {...}
>
> unstead of the usual (for me) foreach syntax
>
> foreach (keys %h) {...}
>
>
> Thanks in advance.
>
> Boson
--
Kevin Reid. | Macintosh.
"I'm me." | Think different.
------------------------------
Date: Sun, 13 Dec 1998 00:19:47 -0800
From: Jim Savarino <jsavarino@jps.net>
To: Rick Delaney <rick.delaney@home.com>
Subject: Re: New to perl - pattern matching question
Message-Id: <367378A2.B8F82B78@jps.net>
Thanks,
Also,
$number =~ /^[-+]?(?!0)\d+$/
seems to handle single digits.
Rick Delaney wrote:
> $number =~ /^[-+]?(?!0\d)\d+$/;
>
--
Jim Savarino
http://songs.com/jims
------------------------------
Date: Sun, 13 Dec 1998 00:42:13 -0800
From: Jim Savarino <jsavarino@jps.net>
To: Rick Delaney <rick.delaney@home.com>
Subject: Re: New to perl - pattern matching question
Message-Id: <36737DE5.15959BDE@jps.net>
Oops, please disregard my earlier post - (?!0\d) the \d is necessary for
the case $number = 0
Now, what is OWTDI? Is there a glossary somewhere for this stuff?
> OWTDI:
>
> $number =~ /^[-+]?(?!0\d)\d+$/;
>
--
Jim Savarino
http://songs.com/jims
------------------------------
Date: 13 Dec 1998 13:20:43 GMT
From: "Allan M. Due" <Allan@Due.net>
Subject: Re: New to perl - pattern matching question
Message-Id: <750evb$1o7$0@206.165.165.138>
Jim Savarino wrote in message <36737DE5.15959BDE@jps.net>...
|Oops, please disregard my earlier post - (?!0\d) the \d is necessary for
|the case $number = 0
|
|Now, what is OWTDI? Is there a glossary somewhere for this stuff?
The Perl moto is: There Is More Than One Way To Do It.
TIMTOWTDI, so just lop off the TIMT.
I am not sure you will find OWTDI there but you might want to check out the
latest versin of the Jargon file.
http://www.tuxedo.org/~esr/jargon/
HTH
AmD
------------------------------
Date: 13 Dec 1998 09:39:29 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: New to perl - pattern matching question
Message-Id: <750jj1$1dq@panix.com>
In <36737DE5.15959BDE@jps.net> Jim Savarino <jsavarino@jps.net> writes:
>Now, what is OWTDI? Is there a glossary somewhere for this stuff?
$OWTDI = "One Way To Do It";
--
Clay Irving
clay@panix.com
------------------------------
Date: Sun, 13 Dec 1998 07:21:37 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: New to perl - pattern matching question
Message-Id: <MPG.10dd244f3891d32a989953@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <36737DE5.15959BDE@jps.net> on Sun, 13 Dec 1998 00:42:13 -
0800, Jim Savarino <jsavarino@jps.net> says...
...
> Now, what is OWTDI? Is there a glossary somewhere for this stuff?
This is part of a Perl mantra to be found in any of the books written by
any or all of Christiansen, Schwartz or Wall (note alphabetical order :-
).
TMTOWTDI == There's More Than One Way To Do It. Rick Delaney was
presenting One Way.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 13 Dec 1998 15:25:21 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: no UnderScore (was: Re: usage of $_ within nested loops)
Message-Id: <750m91$l11$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, bart.lateur@skynet.be (Bart Lateur) writes:
:Something is fishy.
Yes, rather. First of all, results differ in 5.004 and 5.005;
secondly, ordering seems to affect the answer in 5.005.
I'm taking this up with perl5-porters.
--tom
--
I'm not writing any more tapes, ever. --Andrew Hume
------------------------------
Date: Sun, 13 Dec 1998 13:52:04 GMT
From: kyle@kylecordes.com (Kyle Cordes)
Subject: Re: Perl multithread/multiprocess socket server example?
Message-Id: <750gq4$407m_002@news.anet-stl.com>
In article <74ukqk$1fj$1@gellyfish.btinternet.com>, Jonathan Stowe <gellyfish@btinternet.com> wrote:
>> I'm looking to build a rather simple server application in Perl. The tricky
>> part is that I want it to be a multitasking/threading/whatever server, so
>> that each incoming connection spawns another process to handle the request,
>> so more than one can be processes concurrently.
>There is an example of a server in the perlipc manpage that uses fork() to
>create a new process for each connection. Of course if you are on Win32
>then you may not be able to use fork() - threading is still considered an
>experimental feature of Perl so you might not want to use that. On Win32
>you might be able to use Win32::CreateProcess (or something like that) but
>I dont know a great deal about that stuff ...
Thanks for the pointer. That example will serve the basic purpose.
Unfortunately, it mentions but does not implement some important features,
such as watching for "zombie" child processes and killing them after a while.
If someone knows of a more complete (production-grade) socket server template,
it would be nice, but if not, the man page is a starting point...
[* kyle@kylecordes.com | For Delphi | BDE Alternatives Guide *]
[* http://www.kylecordes.com | developers: | MIDAS Alternatives Guide *]
------------------------------
Date: Sat, 12 Dec 1998 23:56:04 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Question on Skalars & Arrays
Message-Id: <ktkv47.jkf.ln@magna.metronet.com>
Papick Garcia Taboada (papick.taboada@gmx.net) wrote:
: I am new to perl and I was wondering how to do the
: following tasks:
: 1) I normaly split an \t formatted line this way:
: ( $f1, $f2, $f3) = split( /\t/ , $myRecordLine );
: By now I only have those three fields, but I am sure
: that tommorow there could be 5 or 6...
: So, I thought, it would be nice if I could store the left
: side if the assignment into an skalar, like:
: $myStructure = '( $f1, $f2, $f3)';
: Is there any way use $myStructure instead of the ( $f1, ... )???
: Somethig like @$?!myStructure = split(....);
@f = split( /\t/ , $myRecordLine );
print "$f[0]\n";
print "$f[1]\n";
...
: 2) Somewhere I define
: $sortoder = "firstname";
: Somewhere else I whant to get the contents of the skalar
: refered to by $sortorder, like:
: $curSearchKeyValue = givemewhatisin( $sortorder );
$curSearchKeyValue = $sortorder;
: Are this things possible?
It is usually best if you tell us in your post what you have
already tried, and include your code.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 13 Dec 1998 20:38:11 -0600
From: Mark Stackhouse <stackhou@execpc.com>
Subject: Re: Random integer numbers (1,2,3,4,5....,.....) HOW???
Message-Id: <750jgd$opl@newsops.execpc.com>
Marcel Ouwendijk wrote:
>
> I know that there is a function 'rand(value)' but it returns floating point
> numbers. But i need a whole integer nummer somwhere between 1 and 15.
>
> Who can help me with this one.
>
> Thanks in advance...
> Marcel
Try this:
#!/usr/bin/perl -w
srand(time()); #seed rand with time
for (1..15)
{
$number = int(rand 15)+1; #+1 eliminates 0 as a possible number
print "$number\n";
sleep 1; #not necessary :)
}
_END_
--
Mark Stackhouse
***********************************************************************
homepage: http://www.execpc.com/~stackhou
"The best things in life aren't things."
--Art Buchwald
***********************************************************************
------------------------------
Date: 13 Dec 1998 13:52:29 GMT
From: "Allan M. Due" <Allan@Due.net>
Subject: Re: script f|r newsheader Auswahl
Message-Id: <750gqt$583$0@206.165.165.138>
Nikolaus Filus wrote in message <74tvkd$bm3$3@carp.emsnet.de>...
|Hi,
|
|I heard about a script for ignoring 'newbie' postings in USENET. Where can
|I get it ?
|Thanx.
|Nikolaus
I just can't decide. Is this the driest joke I've heard in a long time? A
twisted example of recursion? A sincere, albeit inappropriately posted, plea
for help? I just can't tell.
AmD
------------------------------
Date: Sun, 13 Dec 1998 14:45:17 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: send e-mail by port 25 in Perl !!! HELPME !!!!!
Message-Id: <3675ce8b.1505384@news.skynet.be>
BondMac@hotmail.com wrote:
>HI, help me please whith one script in perl what send one mail by port 25 by
>the server SMTP is other machine (Sun1), where run the script is other Sun2
>!!! Iam have perl 5.001m !! please helpme ... Urls ????????
If you can find a machine ("Internet") address for the other machine
(you know, the 4 numbers) , you can connect through that. I guess that
"localhost" AKA "127.0.0.1" won't work in this case.
Bart.
------------------------------
Date: Sun, 13 Dec 1998 16:08:23 +0100
From: "Asbjorn Gjemmestad" <agjemmes@extremeonline.com>
Subject: Splitting a line at |'s
Message-Id: <750lds$sp2$1@readme.online.no>
I've got a plain text data file with several lines containing three pieces
of data.
The data is separated with |'s, making the data entires value1|value2|value3
I need to split these entries into three different variables. I know I need
to use the split function, but I'm not quite sure about how to make the
statement.
Any assistance would be greatly apprecciated.
Asbjorn
------------------------------
Date: 13 Dec 1998 15:31:14 GMT
From: "Allan M. Due" <Allan@Due.net>
Subject: Re: Splitting a line at |'s
Message-Id: <750mk2$g8c$0@206.165.165.138>
Asbjorn Gjemmestad wrote in message <750lds$sp2$1@readme.online.no>...
|I've got a plain text data file with several lines containing three pieces
|of data.
|The data is separated with |'s, making the data entires value1|value2|value3
|I need to split these entries into three different variables. I know I need
|to use the split function, but I'm not quite sure about how to make the
|statement.
|Any assistance would be greatly apprecciated.
What did you try? How did it fail? This is the kind of info usually provided
along with the request for assistance. Oh well, here you go, | has special
meaning in Perl so it needs to be escaped, I am guessing this is where you
went awry:
my $string = 'value1|value2|value3';
my ($one,$two,$three) = split /\|/,$string,3;
print "$one $two $three";
HTH
AmD
------------------------------
Date: 12 Dec 1998 13:26:46 -0500
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: Splitting a string at a certain point
Message-Id: <74uch6$1cs$1@pilot.njin.net>
Hello -
bart.lateur@skynet.be (Bart Lateur) writes:
>David Alan Black wrote:
>>>I think you forgot the parentheses.
>>> @pieces = $longstring =~ /(.{1,20})/g;
>>The parentheses capture to $1,$2, etc. That isn't needed here:
>>candle:~/hacking/perl$ perl -w
>>my $longstring
>> = "883170453681783178637391547125611486947630234234";
>>@pieces = $longstring =~ /.{1,20}/g;
>>print join "\n", @pieces;
>>
>>^D
>>88317045368178317863
>>73915471256114869476
>>30234234
>That's strange. What exactly does it capture then?
> @pieces = $longstring =~ /.{1,10}.{0,10}/g;
> print join "\n", @pieces;
>88317045368178317863
>73915471256114869476
>30234234
> @pieces = $longstring =~ /(.{1,10})(.{0,10})/g;
> print join "\n", @pieces;
>8831704536
>8178317863
>7391547125
>6114869476
>30234234
Let me rephrase that... with an assist from perlop:
The /g modifier specifies global pattern matching--that is, matching as
many times as possible within the string. How it behaves depends on the
context. In list context, it returns a list of all the substrings matched
by all the parentheses in the regular expression. If there are no
parentheses, it returns a list of all the matched strings, as if there were
parentheses around the whole pattern.
I was (misleadingly) describing it in terms of $1,$2... because those figured
in some other solutions (which did need to capture them). In other words,
the reason the parentheses weren't needed wasn't what I said it was, but
they still weren't :-)
David Black
dblack@pilot.njin.net
------------------------------
Date: Sun, 13 Dec 1998 00:53:58 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Stripping of the _
Message-Id: <MPG.10dd2081ee34f267989952@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <slrn776ppv.5fr.hdiwan@diwanh.stu.rpi.edu> on 13 Dec 1998
07:07:18 GMT, hdiwan@diwanh.stu.rpi.edu <hdiwan@diwanh.stu.rpi.edu>
says...
> In article <74ukvn$73v@sjx-ixn6.ix.netcom.com>, E-swap wrote:
> >I need to know if there is a simple line of code which will allow me to
> >strip out a _ and replace with a space when I am displaying something. Also
> >to put it back in if I need to elsewhere.
>
> $str=s/_/\s/; # for replacement
> print $str;
Your code is a contender for the most-errors-in-the-fewest-characters
award.
That statement does the following:
To the contents of the default string $_, substitute an 's' for the
first '_'. Assign 1 to $str if successful, otherwise 0.
Matthew Bafford posted a 100% correct solution to this question about
nine hours before you posted this untested monstrosity. Please don't
post any untested code, ever again.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sun, 13 Dec 1998 02:24:58 -0700
From: Will Mitchell <w_mitchell@technologist.com>
Subject: Re: What is next book to read after Learning PERL ?
Message-Id: <367387E9.9D3FFD4D@technologist.com>
Go try a library. IF they do not have it there put ti on hold. Then you can read
the book, or any other for that matter, without worrying about wastin money.
Then if the book is good, and functional, by all means buy it.
sofianb@my-dejanews.com wrote:
> Hello! My name is Budi Sofian. I've just finished reading "Learning PERL". I
> need recommendations for the next book to read. I have searched through the
> web and found "Programming PERL" and "CGI/PERL Cookbook" interesting, but I
> could not decide which one I should get. Or probably there are other books
> which are better than these two.
>
> By the way, my purpose of learning PERL is for CGI programming and I have
> programming experience previously (FORTRAN 77).
> Please send me your recommendation. Your help is highly appreciated.
--+----------------------------------------------+
| Will Mitchell |
| w_mitchell@technologist.com |
+----------------------------------------------+
------------------------------
Date: 13 Dec 1998 15:52:46 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: What is next book to read after Learning PERL ?
Message-Id: <750nse$m57$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
sofianb@my-dejanews.com writes:
:Hello! My name is Budi Sofian. I've just finished reading "Learning PERL". I
:need recommendations for the next book to read. I have searched through the
:web and found "Programming PERL" and "CGI/PERL Cookbook" interesting, but I
:could not decide which one I should get.
Please, please, please do not confuse the Perl Cookbook from O'Reilly
(the `Ram Book') with that other thing you have mentioned above.
There is a universe of difference between the two.
--tom
--
Blood and flood are not like food,
Nor is mould like should and would.
------------------------------
Date: Sun, 13 Dec 1998 14:45:15 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Why Is Perl not a Language?
Message-Id: <3674cba6.764995@news.skynet.be>
Daniel Grisinger wrote:
>> *My* Perl "programs" usually don't have a user interface. Just a command
>> line.
>
>A command line isn't an interface?
Well all right, it's not an "interactive interface".
Even without this expliciteness, a command line does not really qualify
as a user interface:
* A command line only allows you to make some settings (and specify
files). You enter a command line, and are finished COMPLETELY before the
program/script even starts to run. So it's not really an interface of
your program.
Or take CGI. You won't call the data passed to a GCI script (through
POST or GET) a "user interface", do you? The form is the user interface.
The CGI script doesn't even run until the user submits his data.
Therefore, the user interface is not part of the script. (Except if the
form is generated by the script.)
* I say that a program doesn't have a user interface, if the program
can run in the background without EVER requiring the user's attention. A
command line doesn't make a difference.
If you do insist that a command line is an interface, you may even
stretch it further, and pass the settings in a file, which the script
can read. In that respect, a makefile is a user interface to the program
make. Not.
This is a user interface (although a crude one):
print "What's your name? ";
chomp($name = <STDIN>);
Bart.
------------------------------
Date: Sun, 13 Dec 1998 12:36:14 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Writing Perl with Notepad
Message-Id: <3673b412.11017515@news.skynet.be>
Evan Panagiotopoulos wrote:
>Can I use Notepad or different windows editor
>for script writing? I have a class of high school students and using
>vi is like pulling teeth.
In general: try using a text editor that allows you to save the file as
PC or Unix comaptible, as you wish.
For example, the free PFE. Not much more complicated than notepad.
Bart.
------------------------------
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 4413
**************************************