[6523] in Perl-Users-Digest
Perl-Users Digest, Issue: 148 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 20 14:17:15 1997
Date: Thu, 20 Mar 97 11:00:25 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 20 Mar 1997 Volume: 8 Number: 148
Today's topics:
Re: /RE/ for Dummies - It is even hard for experts! <khawkins@ncsa.uiuc.edu>
a compile question? (Claudia Ma)
Re: a compile question? (Tad McClellan)
Re: a compile question? <rootbeer@teleport.com>
Re: Core Dump!?!? <rootbeer@teleport.com>
Re: Here Document ....How in Perl ???? (Brian L. Matthews)
Re: Here Document ....How in Perl ???? <rootbeer@teleport.com>
How to edit the data in a file? bz7328113@ntuvax.ntu.ac.sg
Re: How to edit the data in a file? <agent.email@NetTown.com>
Re: How to edit the data in a file? <agent.email@NetTown.com>
join <--> split with delimiter in variable <bwmohler@hctg.saic.com>
Re: join <--> split with delimiter in variable <jstrick@mindspring.com>
Re: overloading operators? <rootbeer@teleport.com>
Perl 100 times slower ... (Premkumar Natarajan)
Re: Perl 100 times slower ... <agent.email@NetTown.com>
Re: Perl 100 times slower ... <agent.email@NetTown.com>
Re: PERL on Windows NT <billc@tibinc.com>
Re: Problems with map and its side effects (Chip Salzenberg)
Q: How to search _VERY_ long scalars for recurring patt (Kenneth W. Lee)
Re: Q: How to search _VERY_ long scalars for recurring <agent.email@NetTown.com>
~INTERVIEW FOR ALL PERL GURUS <jneufeld@rapidnet.net>
Re: ~INTERVIEW FOR ALL PERL GURUS <jstrick@mindspring.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 19 Mar 1997 22:24:11 -0600
From: Kevin Hawkins <khawkins@ncsa.uiuc.edu>
To: Robert Schuldenfrei <sailboat@tiac.net>
Subject: Re: /RE/ for Dummies - It is even hard for experts!
Message-Id: <3330BBEA.41C67EA6@ncsa.uiuc.edu>
Okay, this is a bit kludge-y looking (oh my atrocious grammar!), but
it seems to work for me, if what you want is something that will
convert lines whose words are all caps to first-letter-only caps (I
was a bit confused as to what you wanted...):
#!/usr/bin/perl
open(IN, "test.lines") || die "Can't open input: $!\n";
while (<IN>) {
chop;
if (/^(\s*[A-Z_\-\,\!\.\?]+\s*)+$/) {
@words = split(/\s+/, $_);
shift(@words) if ($words[0] eq "");
@spaces = split(/\S+/, $_);
foreach $word (@words) {
$word =~ tr/A-Z/a-z/;
$word = ucfirst($word);
print shift(@spaces), $word;
}
print "\n";
} else {
print "$_\n";
}
}
close(IN);
Where test.lines was full of all the goofy permutations I could come
up with. I'm sure there's a more concise way to do this, but this
seems to work for me.
HTH,
Kevin
Robert Schuldenfrei wrote:
>
> I got some help from Tom Christiansen and Eric Bohlman, but neither script did
> the complete chore. Here is the script as suggested by Tom:
>
> @rem = '
> @echo off
> perl %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
> goto endofperl
> @rem ';
>
> # captest - testing ways to to change all caps to initital caps.
> # This solution was suggested by Tom Christiansen.
>
> $buffer= " THIS is regular text. ";
> $buffer=~ s/(\w+)/\L\u$1/g;
> print "Buffer: $buffer \n";
>
> __END__
> :endofperl
>
> It passed the test by converting THIS IS ALL CAPS to This Is All Caps, but also
> converted the above to This Is Regular Text. Clearly having all of my manual in
> initial caps is going overboard :)
>
> Here is Eric's code. It too solved the problem of turning THIS IS ALL CAPS into
> This Is All Caps. It was easy on the rest of the text, but had its own grief
> with the sentence below:
>
> @rem = '
> @echo off
> perl %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
> goto endofperl
> @rem ';
>
> # captest - testing ways to to change all caps to initital caps.
> # This solution was suggested by Eric Bohlman.
>
> $buffer= "It is I, said the MCS-3 system.";
> $buffer=~ s/\b([A-Z])([A-Z]+)/$1\L$2/g;
> print "Buffer: $buffer \n";
>
> __END__
> :endofperl
>
> It produced "It is I, said the Mcs-3 system. MCS-3 is the name of my production
> management system and it would be hard to repair the damage.
>
> I think that the secret to solving this is in the fact that the target is lines
> that are ALL caps on one line. It starts with ^, the beginning of the line, has
> random white space, every letter is in caps (although there may be numbers and
> dashes) and ends with a \n newline. If even one character is lower case, go on
> to the next line.
>
> I will be out for the next few days, so if anyone has a solution I will get to
> it next week.
>
> Least anyone think I am not pleased for the help that Eric and Tom gave, this IS
> NOT the case. In fact just looking at their solution was a big help to my perl
> and /RE/ education. Thank you. Bob
>
> .
> Robert Schuldenfrei
> S. I. Inc.
> 32 Ridley Road
> Dedham, MA 02026
> Voice: (617) 329-4828
> FAX: (617) 329-1696
> E-Mail: bob@s-i-inc.com
> WWW: http://www.tiac.net/users/tangaroa/index.html
--
=) Kevin Hawkins -- Senior in Computer Science, University of Illinois
(= NCSA Technology Management | e-mail to: khawkins@ncsa.uiuc.edu
=) http://gto.ncsa.uiuc.edu/khawkins/
(= PGP public key available -- finger khawkins@ncsa.uiuc.edu
------------------------------
Date: 20 Mar 1997 02:42:03 GMT
From: maclaudi@cps.msu.edu (Claudia Ma)
Subject: a compile question?
Message-Id: <5gq85r$ej8$1@msunews.cl.msu.edu>
Hi,
Can someone show me a easier way to shadow a big chunk of code
while running a script other than using lots of "#"?
Somebody told me to use "=Cut" at the beginning and end of the code
that I wanted to shadow, but it didn't work. :(
Thanks,
claudia
--
============================================================
Claudia Y. Ma, Computer Science Dept., MSU
Email: maclaudi@cps.msu.edu
URL: http://www.cps.msu.edu/~maclaudi
============================================================
------------------------------
Date: Wed, 19 Mar 1997 22:02:19 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: a compile question?
Message-Id: <bscqg5.a47.ln@localhost>
Claudia Ma (maclaudi@cps.msu.edu) wrote:
: Hi,
: Can someone show me a easier way to shadow a big chunk of code
: while running a script other than using lots of "#"?
: Somebody told me to use "=Cut" at the beginning and end of the code
^^^^
: that I wanted to shadow, but it didn't work. :(
Those are 'pod' "commands" (see the perlpod man page ;-)
I often use them as below to "comment out" a bunch of debugging
code:
=head1 DEBUGGING
ignore me.
don't run this code:
foreach (@ra) { print "$_\n"}
print "ARGV[0] is '$ARGV[0]'\n";
...
=cut
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Wed, 19 Mar 1997 22:34:54 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Claudia Ma <maclaudi@cps.msu.edu>
Subject: Re: a compile question?
Message-Id: <Pine.GSO.3.96.970319222103.5813G-100000@kelly.teleport.com>
On 20 Mar 1997, Claudia Ma wrote:
> Can someone show me a easier way to shadow a big chunk of code
> while running a script other than using lots of "#"?
It sounds as if you want to temporarily "comment out" a chunk of text.
> Somebody told me to use "=Cut" at the beginning and end of the code
> that I wanted to shadow, but it didn't work. :(
No, it wouldn't. But they were trying to tell you about pod directives
which will work. (See perlpod(1).) But here's 99% of what you need to
know:
Each pod directive has to be on a line by itself, and the line before and
after it should be completely empty. (A common pod problem is a space or
tab on a seemingly blank line.) Each pod directive starts with an equal
sign in column one. Mark your commented-out text like this...
=pod
...stuff for perl to ignore...
=cut
Note that "cut" and "for" are all lower-case. It's probably not a good
idea to leave stuff like this in your final script; instead you should
podfully include some docs. Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Wed, 19 Mar 1997 20:04:08 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "Michael C. Harris" <mikeha@ncmi.com>
Subject: Re: Core Dump!?!?
Message-Id: <Pine.GSO.3.96.970319200005.5813A-100000@kelly.teleport.com>
On Wed, 19 Mar 1997, Michael C. Harris wrote:
> We have a Perl script (5.001 patch level 1m)
Chances are very good that the problem is fixed in the upcoming version
5.004. Would you care to test the beta to find out? (You shouldn't replace
your current Perl with the beta, though, unless you're especially daring
or foolhardy.) Good luck!
news:5g7eq9$msc$1@nadine.teleport.com
http://www.perl.com/CPAN/src/5.0/unsupported/perl5.003_93.tar.gz
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 19 Mar 1997 17:39:59 -0800
From: blm@halcyon.com (Brian L. Matthews)
Subject: Re: Here Document ....How in Perl ????
Message-Id: <5gq4hf$d2k$1@halcyon.com>
In article <33301665.5DF3@netscape.com>,
Ronak Bhatt <rbhatt@netscape.com> wrote:
|How do I acheive here document feature of Shell in Perl.....
I assume you've at least read the description and numerous examples
given in perldata, so if you'd post more specifically what you don't
understand about them, maybe someone could help you.
Brian
--
Brian L. Matthews Illustration Works, Inc.
For top quality, stock commercial illustration, visit:
http://www.halcyon.com/artstock
------------------------------
Date: Wed, 19 Mar 1997 20:09:24 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Ronak Bhatt <rbhatt@netscape.com>
Subject: Re: Here Document ....How in Perl ????
Message-Id: <Pine.GSO.3.96.970319200728.5813D-100000@kelly.teleport.com>
On Wed, 19 Mar 1997, Ronak Bhatt wrote:
> From: Ronak Bhatt <rbhatt@netscape.com>
> Subject: Here Document ....How in Perl ????
I strongly suspect that your Perl documentation has something to help you.
And since you're from Netscape, you may benefit from being able to access
it in many forms, including HTML. If whoever set up Perl for you didn't
make the docs easily accessable, complain. Good luck!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Thu, 20 Mar 1997 11:47:32 +0800
From: bz7328113@ntuvax.ntu.ac.sg
Subject: How to edit the data in a file?
Message-Id: <Pine.PMDF.3.91.970320113613.656914480A-100000@ntuvax.ntu.ac.sg>
Hi! I have problem editing the data in the file. I'm using NT perl.
I use "open (FILE,">>$filename")" but this cmd only append to the file.
What I want is to overwrite the old data with the updated data. I read
the data line by line. The cmd is as follows.
open(FILE,"$filename");
@lines=<FILE>;
close FILE;
Let's say I want to update the data in the second line, what should I do?
The data format is as follows.
( Note: the field is separated by the semicolon)
kkchiang;7322222;boooks;the
Your reply is greatly appreciated.
Thanks in advance.
kkchiang.
------------------------------
Date: Wed, 19 Mar 1997 22:09:23 +0000
From: Opera Ghost <agent.email@NetTown.com>
To: bz7328113@ntuvax.ntu.ac.sg
Subject: Re: How to edit the data in a file?
Message-Id: <33306413.77E33546@NetTown.com>
bz7328113@ntuvax.ntu.ac.sg wrote:
>
> Hi! I have problem editing the data in the file. I'm using NT perl.
> I use "open (FILE,">>$filename")" but this cmd only append to the file.
> What I want is to overwrite the old data with the updated data. I read
> the data line by line. The cmd is as follows.
>
> open(FILE,"$filename");
> @lines=<FILE>;
> close FILE;
>
> Let's say I want to update the data in the second line, what should I do?
>
> The data format is as follows.
> ( Note: the field is separated by the semicolon)
>
> kkchiang;7322222;boooks;the
>
> Your reply is greatly appreciated.
>
> Thanks in advance.
>
> kkchiang.
well, u could...
open FILE, '>$outfile>';
print FILE $updateddata;
close FILE;
r, if u want to include error messages etc and will use this 'scheme'
a lot, make a package like
http://nettown.com/site_perl/alans_Util.pm
which i use like...
use alans_Util.pm
$util = new alans_Util.pm
$indata = $util->fget($filename);
$outdata = map XXX, $indata;
$util->fput($filename, $outdata);
note this gives me open or die "msg" (r maybe warn) behavior
(untested)
--
<i>Opera Ghost
<mailto:agent.email@NetTown.com>
[http://NetTown.com/site_perl/]
have a good day!
------------------------------
Date: Wed, 19 Mar 1997 22:15:54 +0000
From: Opera Ghost <agent.email@NetTown.com>
To: bz7328113@ntuvax.ntu.ac.sg
Subject: Re: How to edit the data in a file?
Message-Id: <3330659A.57A2D22A@NetTown.com>
oops...
should be
open FILE, ">$outfile";
so very sorry about that trailing >
the important part is > is used for opening a file for write.
like >> is for appending.
hope this helps!
--
<i>Opera Ghost
<mailto:agent.email@NetTown.com>
[http://NetTown.com/site_perl/]
have a good day!
------------------------------
Date: Wed, 19 Mar 1997 15:25:53 -0800
From: Bruce Mohler <bwmohler@hctg.saic.com>
Subject: join <--> split with delimiter in variable
Message-Id: <33307601.16C5@hctg.saic.com>
Dear Newsgroup,
The split and join functions are not behaving the way I expect and I
can't see what I'm doing wrong.
I have a variable to store my delimiter (a '|' right now).
$Delimiter = "|";
I create an array of name/file name pairs:
$ListOfFiles[++$#ListOfFiles] =
join $Delimiter, $Userid,$FileName;
and this works just fine (per page 181 in the Blue Camel book).
However, when I come later to split the name/file name pairs, it doesn't
work:
( $Name, $FileName ) = split $Delimiter, $ListOfFiles[$Index];
I end up getting a single character from the array data in each of the
variables. I'm baffled.
I'm running Perl 5.003m on an HP workstation running 9.05 (but it's more
likely me than Perl at this point).
Any suggestions to help me get this working? Thanks in advance.
Bruce
--
____________________________________________________________________________
Bruce W. Mohler (semperfi) _/_/ _/_/ _/ _/_/
Senior System Administrator ><> _/ _/ _/ _/ _/ _/
_/
mailto:bruce.w.mohler@cpmx.saic.com _/ _/ _/ _/ _/
619-546-6641 33 07 09 N 117 05 08 W _/_/ _/_/_/_/ _/ _/
The greatest question of our time _/ _/ _/ _/ _/
is ... whether men can live _/ _/ _/ _/ _/ _/ _/
without God. Will Durant _/_/ _/ _/ _/ _/_/
GCS/MU/L/TW C++$ UH+++$ P+++ L+ E- W+++$ N++ w+ 5++ R+ b+++ D-- h----
r+++18
____________________________________________________________________________
------------------------------
Date: Thu, 20 Mar 1997 01:14:17 -0500
From: John Strickler <jstrick@mindspring.com>
Subject: Re: join <--> split with delimiter in variable
Message-Id: <3330D5B9.F6F415A@mindspring.com>
Bruce Mohler wrote:
> The split and join functions are not behaving the way I expect and I
> can't see what I'm doing wrong.
>
> I have a variable to store my delimiter (a '|' right now).
>
> $Delimiter = "|";
>
> However, when I come later to split the name/file name pairs, it doesn't
> work:
>
> ( $Name, $FileName ) = split $Delimiter, $ListOfFiles[$Index];
>
> I end up getting a single character from the array data in each of the
> variables. I'm baffled.
Whether or not your delimiter is stored in a variable, your code is
really this:
($v1,$v2) = split("|",$some_string);
The problem is that the delimiter for split() is not a single character,
but a
regular expression. For this reason, the first argument to split is
generally
enclosed in forward slashes. The pipe char ('|') is a metacharacter in
REs,
meaning, approximately, "or", so split() is a little confused. In a
literal pattern,
you could backslash or use q() to quote the pipe; but with a variable,
you need
to use the quotemeta function like this:
($v1,$v2) = split(/qm($Delimiter)/,$some_string);
The quotemeta function turns off (or quotes) the special meaning of
metacharacters
contained within -- hence the name. HTH.
> Any suggestions to help me get this working? Thanks in advance.
You're welcome.
[rather large .sig snipped]
> GCS/MU/L/TW C++$ UH+++$ P+++ L+ E- W+++$ N++ w+ 5++ R+ b+++ D-- h----
^^^^ ????
--
John Strickler -- Perl/UNIX/C Trainer, Consultant
Jeffersonian Consortium Voice: 919-682-3401
HTTP://WWW.JCINC.COM Facsimile: 919-682-3369
------------------------------
Date: Wed, 19 Mar 1997 22:38:00 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Phil Sallee <phil@irvine.com>
Subject: Re: overloading operators?
Message-Id: <Pine.GSO.3.96.970319223535.5813H-100000@kelly.teleport.com>
On Wed, 19 Mar 1997, Phil Sallee wrote:
> Does anyone know of a way to overload operators in Perl?
Type 'perldoc overload' and see whether anything interesting happens. :-)
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 20 Mar 1997 02:45:46 GMT
From: pnataraj@emerald.tufts.edu (Premkumar Natarajan)
Subject: Perl 100 times slower ...
Message-Id: <5gq8cq$kvr$1@d2.tufts.edu>
Recently I wrote a perl tool to replace a C version (with some added
functionality). Now the extra functionality is not compute intensive. A
colleague who needs to use it regularly finds that it runs about 100 times
slower than the C version - on the average. Question for the experts ->
Is this usual or does your instinct suggest that some obvious optimizing
is required ?
Thanks,
Prem
------------------------------
Date: Wed, 19 Mar 1997 22:46:53 +0000
From: Opera Ghost <agent.email@NetTown.com>
To: Premkumar Natarajan <pnataraj@emerald.tufts.edu>
Subject: Re: Perl 100 times slower ...
Message-Id: <33306CDD.5F2A1B38@NetTown.com>
Premkumar Natarajan wrote:
>
> Recently I wrote a perl tool to replace a C version (with some added
> functionality). Now the extra functionality is not compute intensive. A
> colleague who needs to use it regularly finds that it runs about 100 times
> slower than the C version - on the average. Question for the experts ->
>
> Is this usual or does your instinct suggest that some obvious optimizing
> is required ?
>
> Thanks,
> Prem
slower? think about it...uncompilied text vs optimized machine code?
yes, much can be done to make things faster,
#1. write good code!
the perl compilier should give u an idea of what ur 'new features' costs
http://www.perl.com/perl has links to compiler and info
the best thing to do is check out the perl source code (in c)
for the parts that u think r slow. it just so happens that i have
this unzipped in
http://nettown.com/site_perl/src/perlsource/
and the pod2html files in
http://nettonw.com/site_perl/doc/perl5.003_93/
--
<i>Opera Ghost
<mailto:agent.email@NetTown.com>
[http://NetTown.com/site_perl/]
have a good day!
------------------------------
Date: Wed, 19 Mar 1997 22:53:48 +0000
From: Opera Ghost <agent.email@NetTown.com>
To: Premkumar Natarajan <pnataraj@emerald.tufts.edu>
Subject: Re: Perl 100 times slower ...
Message-Id: <33306E7C.67AF7664@NetTown.com>
if u du check out the internals of perl,
start with perlguts under
http://nettown.com/site_perl/doc/perl5.003_93/
hope this helps...
--
<i>Opera Ghost
<mailto:agent.email@NetTown.com>
[http://NetTown.com/site_perl/]
have a good day!
------------------------------
Date: Wed, 19 Mar 1997 21:41:44 -0500
From: Bill Cowan <billc@tibinc.com>
Subject: Re: PERL on Windows NT
Message-Id: <3330A3E8.755@tibinc.com>
Danny Aldham wrote:
>
> Daniel McManus (mcmanus@ait.fredonia.edu) wrote:
> : Anyone out there using WindowsNT and have PERL running.
> : I tried to set up PERL on NT and its not working. But I'm too baffeled to
> : be able to say what the symptoms are so, if there is anyone out there who
> : is doing this please contact me so I can ask you a couple of questions.
>
> It is not fair. The first time I installed Perl on a unix box I spent
> days struggling with the configure script, the hints, and the compile errors.
> "Unreferenced symbol, first found in ..." . Now to get perl running on
> an NT box all you have to do is download the 110-i86.zip file from
> www.perl.hip.com , unzip it, and run the install.bat file. That's it.
> I'll say it again. It's just not fair.
>
> Danny Aldham
I had the same easy installation that Danny had. Be careful to un-zip
with -d switch in order to create Perl directory structure. More
installation info is at:
Evangelo's Frequently Asked Questions (FAQ):
http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html
-- Bill
-----------------------------------------------------------------------
Bill Cowan <billc@tibinc.com> Voice:919-490-0034 Fax:919-490-0143
Tiburon, Inc./3333 Durham-Chapel Hill Blvd Suite E-100/Durham, NC 27707
------------------------------
Date: 19 Mar 1997 18:15:55 GMT
From: chip@rio.atlantic.net (Chip Salzenberg)
Subject: Re: Problems with map and its side effects
Message-Id: <5gpagr$hi0@news.atlantic.net>
According to mconst@soda.CSUA.Berkeley.EDU (Michael Constant):
>Here are a few other ways to copy a list, without using a
>temporary variable:
>
> @{[ @list ]}
> map $_, @list
> thaw freeze @list
>
And my personal favorite:
eval { @list }
--
Chip Salzenberg - a.k.a. - <chip@atlantic.net>
"Vacation time. Families travel east, west, north, or south."
"Some just burrow straight down." -- Crow T. Robot // MST3K
------------------------------
Date: 19 Mar 1997 23:29:48 -0500
From: kenlee@sar5.morgan.com (Kenneth W. Lee)
Subject: Q: How to search _VERY_ long scalars for recurring patterns?
Message-Id: <kenlee.858831312@sar5>
Hi,
How do you process an _extremely_ looooong scalar file
(i.e. a 3 meg ascii text file with no newlines) that has
a unique recurring regexp? (Imagine a very large
fixed-length ascii table... and now imagine that
that table has all the newline characters removed...yuck)
For simplicity, consider the example:
FOO 12345 FU
BAR 67890 MN
FOO 12345 CH
...
that is mysteriously changed to:
FOO 12345 FU BAR 67890 MN FOO 12345 CH ... ad naseum
($wc -l will return a value of zero)
Is there a method of parsing this long scalar to return
the length of the unique pattern /\w{3}\s\d{5}\s\w{2}/?
I've looked in the pink and blue camels, the big how-to,
as well as the man pages. (I'm running perl5 on SunOS
4.1.3) This is driving me nuts!
Thanks in advance,
--
Ken
--
------------------------------
Date: Thu, 20 Mar 1997 00:38:00 +0000
From: Opera Ghost <agent.email@NetTown.com>
To: "Kenneth W. Lee" <kenlee@sar5.morgan.com>
Subject: Re: Q: How to search _VERY_ long scalars for recurring patterns?
Message-Id: <333086E8.5BA64303@NetTown.com>
Kenneth W. Lee wrote:
>
> Hi,
>
> How do you process an _extremely_ looooong scalar file
> (i.e. a 3 meg ascii text file with no newlines) that has
> a unique recurring regexp? (Imagine a very large
> fixed-length ascii table... and now imagine that
> that table has all the newline characters removed...yuck)
>
> For simplicity, consider the example:
>
> FOO 12345 FU
> BAR 67890 MN
> FOO 12345 CH
> ...
>
> that is mysteriously changed to:
>
> FOO 12345 FU BAR 67890 MN FOO 12345 CH ... ad naseum
>
> ($wc -l will return a value of zero)
> Is there a method of parsing this long scalar to return
> the length of the unique pattern /\w{3}\s\d{5}\s\w{2}/?
> I've looked in the pink and blue camels, the big how-to,
> as well as the man pages. (I'm running perl5 on SunOS
> 4.1.3) This is driving me nuts!
>
> Thanks in advance,
>
> --
> Ken
>
> --
sure there is, use the ol iterator in //g...
while (/\w{3}\s\d{5}\s\w{2}/g) {
do somein with $&;
}
there is a very simuilar use running at
http://nettown.com/site_perl/doc/eg/news.string.cgi
(has link to source)
map can also do things like thisa
aside...
my wouldn't it be nice if 1 did NOT have to slurp in the whole file, ie:
$/ = /XXX/;
!
good luck!
--
<i>Opera Ghost
<mailto:agent.email@NetTown.com>
[http://NetTown.com/site_perl/]
have a good day!
------------------------------
Date: 20 Mar 1997 02:28:32 GMT
From: "Jonathan Barry Neufeld" <jneufeld@rapidnet.net>
Subject: ~INTERVIEW FOR ALL PERL GURUS
Message-Id: <01bc34d7$44695ce0$b549c2cf@ocoi>
Hi, my name is Jonathan Neufeld and I am very curious of how
people get into Perl, learn it, and use it in the future...
If you would take the time to answer a couple of questions I think
you'll greatly enlighten many people including me! So let's get
started:
1. How long have you been programming in Perl?
2. What made you start learning Perl?
3. What has learning Perl been like for you? i.e. troubles etc.
4. How has Perl changed your outlook on programming?
5. For what applications do you use Perl?
6. Overall what is your general opinion of Perl?
Thank you for your time, it is greatly appreciated by many and I
hope to conference with you some time in the future.
--
Jonathan B. Neufeld
Solar Tech Enterprises and Consulting
NT-Online Technologies http://www.ntonline.com
------------------------------
Date: Thu, 20 Mar 1997 01:21:24 -0500
From: John Strickler <jstrick@mindspring.com>
Subject: Re: ~INTERVIEW FOR ALL PERL GURUS
Message-Id: <3330D764.5B968329@mindspring.com>
Jonathan Barry Neufeld wrote:
>
> Hi, my name is Jonathan Neufeld and I am very curious of how
> people get into Perl, learn it, and use it in the future...
>
> If you would take the time to answer a couple of questions I think
> you'll greatly enlighten many people including me! So let's get
> started:
I would be much more excited about helping you if you told us why you
wanted/needed this information. Also, this would be a questionnaire,
or survey, but not an interview -- the subject is misleading.
--
John Strickler -- Perl/UNIX/C Trainer, Consultant
Jeffersonian Consortium Voice: 919-682-3401
HTTP://WWW.JCINC.COM Facsimile: 919-682-3369
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 148
*************************************