[10135] in Perl-Users-Digest
Perl-Users Digest, Issue: 3728 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 16 13:07:09 1998
Date: Wed, 16 Sep 98 10:02:32 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 16 Sep 1998 Volume: 8 Number: 3728
Today's topics:
A Better PERL for Mac? <dejah@DejahsPrivateIce.com>
Re: A Better PERL for Mac? (brian d foy)
Re: A real dumb PERL question... (Andrew M. Langmead)
Re: assigning file contents to a string (Mark-Jason Dominus)
Re: assigning file contents to a string <tchrist@mox.perl.com>
Re: COBOL and Perl (Phil Jach)
Diff between two text files <nkanth@cnd.hp.com>
Re: Help with Perl problem (Craig Berry)
Re: Houston: Web Services Manager Wanted <perlguy@inlink.com>
Re: how safe is xor encryption ? <eashton@bbnplanet.com>
Re: how safe is xor encryption ? (Mark-Jason Dominus)
Re: how safe is xor encryption ? (Abigail)
Re: how safe is xor encryption ? (Michael J Gebis)
Re: leading space (Larry Rosler)
MD5 or SHA as Perl functions? (Mike Elness)
Re: MD5 or SHA as Perl functions? (brian d foy)
reading german "umlaute" from a socket with 5.003 versu <uli.sauer@cl-ki.uni-osnabrueck.de>
Re: Regex strange behavior <r28629@email.sps.mot.com>
Re: script: scriptMangle! <rkoehler@osmre.gov>
Re: script: scriptMangle! <upsetter@ziplink.net>
Re: script: scriptMangle! <eashton@bbnplanet.com>
Re: script: scriptMangle! (Clinton Pierce)
Re: Searching a File for String (Matthew Bafford)
Re: Searching a File for String (Matthew Bafford)
Re: Searching a File for String (Mark-Jason Dominus)
Re: Shopping Cart Systems <eashton@bbnplanet.com>
Re: to greg bacon (Greg Bacon)
Un-tainting a variable for the following format bill_mcintyre@hotmail.com
Unable to install Perl on NT <rbjork@slip.net>
Re: Warning - completely non-PERL content - was Re: Sho <eashton@bbnplanet.com>
Re: While loop with regex as condition? (Larry Rosler)
Re: Who posts original posts on CLPM? <sauvin@osmic.com>
Re: Who posts original posts on CLPM? <eashton@bbnplanet.com>
Re: Why my perlgrep cannot compared to grep dizhao@my-dejanews.com
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 16 Sep 1998 10:31:51 -0500
From: Mary E Tyler <dejah@DejahsPrivateIce.com>
Subject: A Better PERL for Mac?
Message-Id: <35FFD9E5.6F95@DejahsPrivateIce.com>
I am currently using MacPERL for my interpreter... is there another one
out there for the Macintosh? Maybe a better one? One that might actually
*find* the stray ( or { instead of just telling me that i have 1 more
OPEN than LEAVE and 66 more saves than restores? oh ak! at this point,
i'd even pay money for it.
dejah, better Matthew? a better subject? a better question? Not a dumb
one?
--
i trust i make myself obscure, i have need of obscurity now- robert bolt
a heated exchange of unread mail would be welcomed by all- christensen
Skating Fiction. Featuring the highly acclaimed serial On The Edge!
http://www.DejahsPrivateIce.com
------------------------------
Date: Wed, 16 Sep 1998 12:38:26 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: A Better PERL for Mac?
Message-Id: <comdog-ya02408000R1609981238260001@news.panix.com>
Keywords: from just another new york perl hacker
In article <35FFD9E5.6F95@DejahsPrivateIce.com>, dejah@DejahsPrivateIce.com posted:
>I am currently using MacPERL for my interpreter... is there another one
>out there for the Macintosh? Maybe a better one? One that might actually
>*find* the stray ( or { instead of just telling me that i have 1 more
>OPEN than LEAVE and 66 more saves than restores? oh ak! at this point,
>i'd even pay money for it.
the program
#/usr/bin/perl
{
print 'just another new york perl hacker';
__END__
gives me the output
# Missing right bracket, at end of line
File '<AppleEvent>'; Line 5
# syntax error, at EOF
File '<AppleEvent>'; Line 5
# Execution of <AppleEvent> aborted due to compilation errors.
once you get use to the Mac port, everything should be okay. there
are a lot of tools for working with MacPerl with editors such as
BBEdit and Alpha which would make your life a bit easier as well.
good luck :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>
------------------------------
Date: Wed, 16 Sep 1998 15:04:44 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: A real dumb PERL question...
Message-Id: <EzDtvw.5xL@world.std.com>
Mary E Tyler <dejah@DejahsPrivateIce.com> writes:
>first:
>what are the keys for the Environmental valiable hash %ENV?
Whatever the keys either the parent process or the current process put
there. Since you are writing the current process, you probably know
what you put there. The only thing left to do is to figure out what
the parent put there. It can be almost anything. (I wonder, are
environment variables limited to alphnumerics? or would an NUL be the
only disallowed character?)
There may be certain interprocess protocols between a parent process
and its child that use environment variables for communication. CGI is
an example. If you want information about a certain protocol, you are
better off reading the documentation for it rather than asking on
Usenet. Questions with one undisputable answer are best left to
research sources. Questions with subjective answers are best left to
people.
--
Andrew Langmead
------------------------------
Date: 16 Sep 1998 10:57:40 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: assigning file contents to a string
Message-Id: <6tojl4$44e$1@monet.op.net>
In article <uaf41o0v8.fsf@vansel.alcatel.com>,
Brad Murray <murrayb@vansel.alcatel.com> wrote:
>$stuff = join ("", @stuff = <FH>);
It's probably always better to do
{ local $/; # Read entire file
$stuff = <FH>;
}
because it isn't much more complicated, and it doesn't have to go to
the trouble of splitting the file into lines and the putting the lines
back together again.
------------------------------
Date: 16 Sep 1998 15:03:34 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: assigning file contents to a string
Message-Id: <6tok06$5o9$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, mjd@op.net (Mark-Jason Dominus) writes:
:It's probably always better to do
: { local $/; # Read entire file
: $stuff = <FH>;
: }
Or even:
$stuff = do { local $/; <FH> };
Hm.... maybe not. :-)
--tom
--
"In 1980, a single person could understand the UNIX kernel. In
1990, a single person couldn't even lift it!"
- Steve Zucker (as qutoed by Dick Dunn )
------------------------------
Date: 16 Sep 1998 15:23:27 GMT
From: philjach@usa.net (Phil Jach)
Subject: Re: COBOL and Perl
Message-Id: <35ffd7ef.0@news1.ibm.net>
In article <6t0dk0$ep5$4@news.enterprise.net>
scm@enterprise.net (Shaun C. Murray) wrote:
[snip]
>
> as I said, shorthand.
>
What you call shorthand, IMHO, I call symbolism.
Perl uses cryptic/shorthand characters/symbols to bridge the gap between
culturally diverse speaking/writing languages. It makes it easier for a
person that doesn't know a lick of English to read my Perl program.
Can the same be said about COBOL?
Larry Wall, the creator of Perl and the person who is mainly responsible
for the future direction of Perl, discusses Perl as a global language in the
following speech. Please read it.
http://www.perl.com/pace/pub/perldocs/1998/08/show/onion.html
[snip]
----------------------
Remember being young and getting your first toy that required assembly,
wanting it together so bad but not knowing how to do it, not knowing
what instructions were or where to find them? I'm glad my Dad didn't
FLAME me for not knowing. He showed me, with kindness.
------------------------------
Date: Wed, 16 Sep 1998 10:22:50 -0600
From: Srikanth Natarajan <nkanth@cnd.hp.com>
Subject: Diff between two text files
Message-Id: <35FFE5DA.17E29064@cnd.hp.com>
Hi
Is there a way to compare two text files for differences in
Perl
I need to write code which works on both NT and UNIX
On unix I probably could have used system("diff...)
and on NT may be the command comp. But comp expects
an input from the user after diffing and I am not sure
how to handle that.
Any help will be highly appreciated.
Srikanth
------------------------------
Date: 16 Sep 1998 16:05:55 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Help with Perl problem
Message-Id: <6tonl3$r0d$1@marina.cinenet.net>
mike@debtware.co.uk wrote:
: Can anyone kelp me please. I am trying to write a perl program where I
: pass two arguments on then command line. The first is the input file
: the second is the output file.
:
: The command line reads:
:
: perl myprog.pl filename1 filename2
:
: In the code I have:
:
: $file1 = @ARGV[0]
: $file2 = @ARGV[1]
I presume you have a -w on your shebang line above that, and also are
checking the arg list to be sure it's two items long.
: open (InFile, $file1);
: open (OutFile, $file2);
: When I run it OutFile will not open. I am running perl 5 under dos.
No checking of the open result?? That's just silly, especially when
you're wondering why something won't work. Try making both lines look
like
open FOO, $foofile or die "Can't open $foofile: $!\n";
and see if the light dawns. Hint: What's the default access mode of an
opened file?
: Any suggestions please.
Always always always *always* check the return value from open!
: Can you reply by e-mail to mike@jbcs.co.ok
Nope. Ask here, read here.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| "Ripple in still water, when there is no pebble tossed,
nor wind to blow..."
------------------------------
Date: Wed, 16 Sep 1998 16:17:41 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: Houston: Web Services Manager Wanted
Message-Id: <35FFE4A5.F2A996A8@inlink.com>
Howie Doyle pissed off several people by spamming:
> Job Title: Manager of Online Services
> Location: Houston, Texas (Northwest Suburban Area)
> Description of Position: Manager of Online Services
... blah blah blah ...
> Manager of Online Services is a full-time (40-45 hours/week), salaried
> position with benefits, reporting to the owner.
... blah blah blah ...
> Starting salary: Will be commensurate with experience and ability,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
They must have REALLY low standards for hiring...
> generally in the $30K to $35K range (but not limited to this range).
^^^^^^^^^^^^
I hope this isn't the ANNUAL salary range!
- You can make damn near that at McDonald's!
My $.02
Brent
------------------------------
Date: Wed, 16 Sep 1998 15:06:46 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: how safe is xor encryption ?
Message-Id: <35FFD1A1.DFED29A6@bbnplanet.com>
Mark-Jason Dominus wrote:
> I'm not sure what you mean to imply here. If you meant to say that
> any amateur would think that you had missed the point of the question,
> then I agree.
>
> Since that was the only thing I said, I don't know what else you
> might have meant.
Yes, I probably missed the point of the question, which I believe to
have been 'How do I encrypt data over the web for credit cards'. I
perhaps overreacted but this is a bit of a mission for me. It's not that
I don't want e-commerce, but I want it to be done in a secure, sane way.
If I got the person to think about this, then it wasn't just so many
bits in the aether. If it is on-line, it is insecure. Period.
e.
"All of us, all of us, all of us trying to save our immortal souls, some
ways seemingly more round-about and mysterious than others. We're having
a good time here. But hope all will be revealed soon." R. Carver
------------------------------
Date: 16 Sep 1998 11:42:14 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: how safe is xor encryption ?
Message-Id: <6tom8m$4fp$1@monet.op.net>
In article <35FFB32E.6F33@gecm.com>, Jim Michael <jim.michael@gecm.com> wrote:
>It was proposed that each CC# would be encrypted using a different key
>supplied by the CC owner
Thanks; I missed that. It sounds a lot more useful to me now. For
example, suppose you collected the CC#s out of band, perhaps over the
phone. Then the users would never need to send CC#s over the
internet, only their pad keys. Even if sent insecurely, a snooper is
unlikely to get any value from the pad key; to do so, they must
intercept a pad key *and* acquire your database.
>However, CC#s have a common beginning number sequence which
>identifies the CC type (MC, Visa, etc.), do they not?
Yes, but I think it's only one digit long. Perhaps someone can confirm?
In any event, stronger encryption is probably more useful here.
For example, you might use the user-supplied phrase as a key for
DES-encrypting the credit card number. This is less likely to be
subject to this sort of attack.
>> 2. A cracker who has gotten into the database has probably also gotten
>> into your source code.
>
>Or your keys.
Yes, a malevolent person on your machine probably has several paths
of access to the information.
Encrypting the numbers in the database, and transmitting only the
decryption key, rather than the actual number, seems prudent to me.
Is there some problem I'm overlooking?
------------------------------
Date: 16 Sep 1998 16:05:00 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: how safe is xor encryption ?
Message-Id: <6tonjc$bcg$1@client3.news.psi.net>
Jim Michael (jim.michael@gecm.com) wrote on MDCCCXLII September MCMXCIII
in <URL: news:35FFB32E.6F33@gecm.com>:
++ Mark-Jason Dominus wrote:
++ >
++ > >say, a cracker has somehow reached to the database, full of credit card
++ > >numbers encrypted in that manner.
++ >
++ > 1. If the cracker knows any one entire credit card number, perhaps
++ > because they inserted it themselves, they can easily figure out
++ > what your secret pad is, and decrypt all the other numbers.
++
++ It was proposed that each CC# would be encrypted using a different key
++ supplied by the CC owner (CC owner will supply a phrase, credit card
++ security code (CCSC): $enc = $cc ^ $ccsc;), so deciphering one would not
++ supply the key to the others. However, CC#s have a common beginning
++ number sequence which identifies the CC type (MC, Visa, etc.), do they
++ not? By xor'ing these beginning sequences you may be able to guess the
++ ending sequence in many cases (people tend to use common words or
++ phrases for passwords) or greatly reduce the search space.
But assuming that the key has the same length as the CC#, that piece
of information gains you exactly nothing.
However, what do you gain by encrypting each CC# with a different key?
Instead of stealing the CC#, all they have to do is steal the CC#, key
combo. A task which isn't significantly harder than just stealing the
CC#. Unless you somehow have a way to store keys in a more secure way
than CC#.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: 16 Sep 1998 16:19:00 GMT
From: gebis@fee.ecn.purdue.edu (Michael J Gebis)
Subject: Re: how safe is xor encryption ?
Message-Id: <6toodk$lnb@mozo.cc.purdue.edu>
beyret@my-dejanews.com writes:
}I am about to write a simple script to encrypt/decrypt credit card numbers
}using xor and a key supplied by credit card owner. I wanted to learn your
}thoughts about it:
Why are you home-brewing your own encryption when there is so much
good code available? It's HARD to get this stuff right--a lot of very
smart people have gotten it wrong in the past. Use proven
techniques.
}10*10*10....10 (16 10's multiplied)
}that number looks pretty safe??
It appears to me that your method is vulnerable (at least) to a
dictionary attack.
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: Wed, 16 Sep 1998 07:58:38 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: leading space
Message-Id: <MPG.106971fe96ffc855989860@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <35FF76D6.3D25@ece.rutgers.edu> on Wed, 16 Sep 1998 04:29:10 -
0400, Sameer Sharma <sameers@ece.rutgers.edu> says...
> When i read an entire file into an array
> @array = <FILENAME>
> and then print this array into another file FILENAME1
> print FILENAME1(@array)
> after doing some modifications on the array, I get a leading space
> in the lines written to FILENAME1. Why is this happening? Can it be
> avoided?
I'll wager that the statement you quote above as
print FILENAME1(@array)
actually reads like this:
print FILENAME1("@array");
which would produce the behavior you describe. To see why, look in
`perldoc perlvar` for the variable $" .
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 16 Sep 1998 08:15:32 -0700
From: mike.elness@lmco.com (Mike Elness)
Subject: MD5 or SHA as Perl functions?
Message-Id: <mike.elness-1609980815320001@stealthmac.lmms.lmco.com>
Greetings, all,
I need a message digest function (one-way hash) written in Perl that I can
include in a Perl script. I know that others have developed Perl
_extensions_ (i.e., Perl interface to C code) for the two most common
ones, SHA and MD5, but I instead need one (or both ;-) of these written in
real Perl code, ideally as a function that I can just pass some text to
(and receive the message digest as the return value).
I know it'd be pretty slow in Perl due to the numerous computations
required, but I'm planning on passing only small strings to the message
digest function.
Has anyone coded up such a beast in Perl?
Thanks in advance,
Mike Elness
Lockheed Martin Enterprise Information Systems
Sunnyvale, CA
mike.elness@lmco.com
------------------------------
Date: Wed, 16 Sep 1998 12:39:40 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: MD5 or SHA as Perl functions?
Message-Id: <comdog-ya02408000R1609981239400001@news.panix.com>
Keywords: from just another new york perl hacker
In article <mike.elness-1609980815320001@stealthmac.lmms.lmco.com>, mike.elness@lmco.com (Mike Elness) posted:
>I need a message digest function (one-way hash) written in Perl that I can
>include in a Perl script. I know that others have developed Perl
>_extensions_ (i.e., Perl interface to C code) for the two most common
>ones, SHA and MD5, but I instead need one (or both ;-) of these written in
>real Perl code, ideally as a function that I can just pass some text to
>(and receive the message digest as the return value).
what's wrong with just using the modules? if you don't like the interface provided by the module, write a subroutine to act as a wrapper.
good luck :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>
------------------------------
Date: Wed, 16 Sep 1998 18:02:39 +0200
From: Ulrich Sauer <uli.sauer@cl-ki.uni-osnabrueck.de>
Subject: reading german "umlaute" from a socket with 5.003 versus 5.004
Message-Id: <35FFE11F.5EDDBD9C@cl-ki.uni-osnabrueck.de>
Dear Perl Enthusiasts,
I use a perl internet socket server on base of the examples to Larry
Walls "Programming Perl".
The Programm accepts parts of german natural language over a socket.
It runs perfectly well with 5.003 and in parts with 5.004.
Unfortunately with 5.004 the same program will not accept german
"umlaute": it is "dv|" anymore. They simply seem to disappear while
reading.
Has anybody a hint where I should start searching for information to
come up with this problem.
Thany YOU
Ulrich Sauer
------------------------------
Date: Wed, 16 Sep 1998 09:31:42 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: Regex strange behavior
Message-Id: <35FFCBCE.C459F6A0@email.sps.mot.com>
filippomorelli@my-dejanews.com wrote:
>
> $tag = '<FOO';
> $line = '<FOO_BAR></FOO_BAR>junk';
>
> $line =~ /($tag.*)>/;
> print "Found [$1]\n";
>
> This will print out, [<FOO_BAR></FOO_BAR]. What I want is [<FOO_BAR]. It
> seems that .* matches all the characters up until the last occurance of the
> remaining expression (which is the above case, is simply a greater than
> character '>').
Well, I trust you will read the free manual as others told you to. So,
here the quick answer to your question:
$line =~ /($tag[^>]*)/ # matching stop before 1st '>'
Now, go RTFM.
-TK
------------------------------
Date: Wed, 16 Sep 1998 14:54:19 GMT
From: "Rick Koehler" <rkoehler@osmre.gov>
Subject: Re: script: scriptMangle!
Message-Id: <EzDtD2.4KC@igsrsparc2.er.usgs.gov>
Elaine -HappyFunBall- Ashton wrote in message
>[snip ...]
>'Codae Obscurae' is sort of, well, pointless, unless you are
>sending the plans for WWIII encoded in music encoded in Perl. :)
>[... snip]
Darn it, who told you? There goes my master plan for world
domination through the proliferation of mindless "jingle-drivel"
via the airwaves! I knew I should've come up with a better idea
than to try to encrypt my passwords by simply compiling my code.
Ahhhh, everyday people. Where have all the cowboys gone?
Try intersplicing these with a 15ms phase shift on the latter,
sample all freqs between 440Hz and 1020Hz, reverse.
Add "white noise" (250ms) at any freq shift>492Hz, save.
Take abbreviations for author's names listed on CPAN under
"Perl Pragmatic Modules", assign to "notes" played in a certain
minor key (Larry's middle initial). Modify former sequence by
performing high bandpass filter and inserting latter sequence
in the gaps, as outlined in docs to Plot::World::Domination.
All will be revealed.
If you read the man pages ...
------------------------------
Date: Wed, 16 Sep 1998 15:07:35 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: script: scriptMangle!
Message-Id: <XuQL1.12$_c5.44064@news.shore.net>
Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> wrote:
: I don't see that as attacking. To make Perl 'unreadable' is almost
: blasphemy.
Thanks!! I needed a good laugh this morning! :)
--Art
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Wed, 16 Sep 1998 15:58:56 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: script: scriptMangle!
Message-Id: <35FFDDDC.3EF7C0D9@bbnplanet.com>
Rick Koehler wrote:
> Darn it, who told you? There goes my master plan for world
> domination through the proliferation of mindless "jingle-drivel"
> via the airwaves! I knew I should've come up with a better idea
> than to try to encrypt my passwords by simply compiling my code.
Well, actually, the Manhattan Project participants received much
information via music recitals and the code it contained.
e.
"All of us, all of us, all of us trying to save our immortal souls, some
ways seemingly more round-about and mysterious than others. We're having
a good time here. But hope all will be revealed soon." R. Carver
------------------------------
Date: 16 Sep 1998 16:26:20 GMT
From: cpierce1@cp500.fsic.ford.com (Clinton Pierce)
Subject: Re: script: scriptMangle!
Message-Id: <6toorc$s9k2@eccws1.dearborn.ford.com>
In article <35FED665.3008CAE1@bbnplanet.com>,
Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> writes:
>Craig Berry wrote:
>
>> I happen to be in sympathy with your general free software approach. I
>> just wish you'd stop attacking strawmen when criticizing the non-free
>> approach(es).
>
>I don't see that as attacking. To make Perl 'unreadable' is almost
>blasphemy.
To make perl 'unreadable' one has only to use it. ;-)
[oh wait, the Language Wars thread is down the hall to the left...]
--
+------------------------------------------------------------------------+
| Clinton A. Pierce | "If you rush a Miracle Man, | http://www. |
| cpierce1@ford.com | you get rotten miracles" | dcicorp.com/ |
| fubar@ameritech.net |--Miracle Max, The Princess Bride| ~clintp |
+------------------------------------------------------------------------+
GCSd-s+:+a-C++UALIS++++P+++L++E---t++X+b+++DI++++G++e+>++h----r+++y+++>y*
------------------------------
Date: Wed, 16 Sep 1998 10:58:34 -0400
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: Searching a File for String
Message-Id: <MPG.10699b78f741f8c398969b@news.south-carolina.net>
In article <cboL1.1301$gp1.2923370@news.rdc1.sfba.home.com> on
Tue, 15 Sep 1998 06:55:04 GMT, Steven McPherson
(stevenmc@home.com) pounded in the following text:
=> Hi all-
=>
=> I was wondering if anyone might be willing to give me a suggestion of how to
=> open and read and file for a particular string and then display what is to
=> the right of the search string.
=>
How about:
#!/usr/bin/perl -wn
$RegEx = shift @ARGV or die "You must provide a regex!\n";
print $' if /$RegEx/o;
__END__
Or, in one line:
perl -wne 'BEGIN{$RegEx=shift @ARGV or die;} print $\' if
/$RegEx/o'
=> Thanks,
=>
=> Steve
Hope This Help(ed|s)!
--Matthew
------------------------------
Date: Wed, 16 Sep 1998 11:45:47 -0400
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: Searching a File for String
Message-Id: <MPG.1069a7362267ca9098969c@news.south-carolina.net>
In article <6tobbm$sp1$1@supernews.com> on Wed, 16 Sep 1998
08:37:00 -0700, finortis (finortis@intrex.net) pounded in the
following text:
=>
=> Gees guys,
=>
=> It's not that hard to do....And some of you shouldn't have such attitudes
=> about helping out others, even if they ask pretty basic questions....Here
=> you go.
=>
=> my $filename = "actual file name";
=> open (HANDLE,"$filename") || die "can't open $filename\n";
=> my @FILE = <HANDLE>;
What if it's a 20mb file? No need for slurping, use
while (<HANDLE>)
instead.
=> my $line = "";
=> my $searchString = "whatever";
=> my $secSearch = "";
=> my @toRight = ();
=>
=> foreach $line (@FILE) {
while ( defined ( $line = <HANDLE> ) ) {
=> my @searchNum = ($line =~ m/$searchString/g;)
Hmm, this should probably be:
my @searchNum = $line =~ m/$searchString/og;
=> foreach $secSearch (@searchNum) {
=> $line =~ m/$searchString (\S+)/g;)
More )'s than needed.
=> push (@toRight,$1);
=> }
He didn't say he wanted just the word after the match, but if so,
something like this would probably be better:
while ( /$searchString\s+(\S+)/og )
{
print "$1\n";
}
=> }
=>
=> I gotta run...I haven't tested this, but I think this should work. I'll run
=> it later, and post any changes if needed.
_ALWAYS_ test your code. _ALWAYS_. What you gave wouldn't even
compile...
So, to pack it all together, you could do:
#!/usr/bin/perl -w
use strict;
my $RegEx = shift @ARGV;
unless ( defined $RegEx )
{
die "You must specify the regex as your first argument.\n";
}
while ( <> )
{
if ( m/$RegEx/o )
{
print "$ARGV :: $'";
}
}
__END__
Hope This Helps!
=> Finortis
--Matthew
------------------------------
Date: 16 Sep 1998 12:03:53 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Searching a File for String
Message-Id: <6tonh9$4mb$1@monet.op.net>
In article <cboL1.1301$gp1.2923370@news.rdc1.sfba.home.com>,
Steven McPherson <stevenmc@home.com> wrote:
>how to open and read and file for a particular string and then
>display what is to the right of the search string.
Nobody else suggested this, and it seemed interesting:
open FILE or die "Couldn't open $FILE: $!";
{ local $/ = $search_string;
<FILE>; # Discard text up to and including search string
}
print ($stuff_to_the_right = <FILE>);
One advantage of this: If the search string appears in the middle of
the line, you automatically get the stuff to the right of it on the
same line. If you use
print while <FILE>;
instead, you get the subsequent lines as well.
Another possible advantage: I think it may be more efficient than
other solutions.
Another advantage: It's amusing.
------------------------------
Date: Wed, 16 Sep 1998 15:27:53 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Shopping Cart Systems
Message-Id: <35FFD695.8A7A504A@bbnplanet.com>
Sam Holden wrote:
> 'Go away you ignorant moron, and RTFM.'
Damned if you do, Damned if you don't. See the Tom Phoenix thread and
wonder at the irony of that statement.
> But to lie seems a little pointless.
Lie? I was venting.
> Guess you must be bleeding then :
Naw, it was just a bad week a month ago Monday to stop sniffing glue. ;)
e.
"All of us, all of us, all of us trying to save our immortal souls, some
ways seemingly more round-about and mysterious than others. We're having
a good time here. But hope all will be revealed soon." R. Carver
------------------------------
Date: 16 Sep 1998 15:01:22 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: to greg bacon
Message-Id: <6tojs2$d71$2@info.uah.edu>
The CPAN module which comes with Perl can use lynx to download files.
Use the source, Luke.
Greg
--
Norm: I'm in a gambling mood, Sammy. I'll take a glass of whatever comes out
of that tap.
Sam: Oh, looks like beer, Norm.
Norm: Call me Mister Lucky.
------------------------------
Date: Wed, 16 Sep 1998 16:34:40 GMT
From: bill_mcintyre@hotmail.com
Subject: Un-tainting a variable for the following format
Message-Id: <6topb0$8bi$1@nnrp1.dejanews.com>
I am trying to un-taint a variable that I use to capure input from a user. I
want to use this input to name a file. I can get part of the way but i am
banging my head at the current obstacle. Here are some details:
$recnum is the varible that capture the user input
The user inputs in the following format: 97-143 (S5)
I can un-taint the variable this way
$recnum =~/(\w[\w.-]*)/;
$recnum ="$1";
This however makes $recnum have this value "97-143" how can I also translate
the space open paren alpanumeric close paren or (S5)?
Many Thanks in advance.
Bill
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Wed, 16 Sep 1998 09:27:54 +0100
From: "Ron Bjork" <rbjork@slip.net>
Subject: Unable to install Perl on NT
Message-Id: <6top08$gd1$1@owl.slip.net>
I have purchase the book "Cross Platform Perl" and attempted to install
Perl on my NT workstation. After unzipping the files in a directory
named perl and executing the install.bat from the command shell (in
directory c:\perl\perl5) I get the following message:
ntt\perl.exe exists=20
copy into current directory
1 file(s) copied
1 file(s) copied
Can't execute install.bat
This last message line seems to result when the 25th line in install.bat =
line is executed.
Line 25: perl.exe -S install.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
Please help
------------------------------
Date: Wed, 16 Sep 1998 15:16:47 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Warning - completely non-PERL content - was Re: Shopping Cart Systems
Message-Id: <35FFD3FB.7C86DB9B@bbnplanet.com>
Gary Mc Closkey wrote:
> >Call me cranky, but the 'I'm too tired to write my own
> >code' has gotten really old lately.
> "Cranky". If it winds you up so much (a) don't reply (b) don't reply and
> save some bandwidth. (c) breathe deeply, think calm thoughts and be
> thanksful you're not a white-house intern or bill clinton. Isn't life better
> now?
Didn't we just have an awful long thread about someone who posted RTFM
in a nice way? I had a really rotten day so sue me. I wasn't that harsh.
And, really, Clinton does nothing for my libido and I would have kept a
pen or something. :)
> Jesuits can't be women?
Well they could if they made the trip to Sweden. Wow, I'm still
wondering where that one came from....
e.
"All of us, all of us, all of us trying to save our immortal souls, some
ways seemingly more round-about and mysterious than others. We're having
a good time here. But hope all will be revealed soon." R. Carver
------------------------------
Date: Wed, 16 Sep 1998 07:45:54 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: While loop with regex as condition?
Message-Id: <MPG.10696efc94bd0e4998985f@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <9rfot6.uf1.ln@metronet.com> on Wed, 16 Sep 1998 08:52:41 -
0500, Tad McClellan <tadmc@metronet.com> says...
...
> : s/\Q$str/<A
> : HREF="$script\?manpage=$page§ion=$sec">$page($sec)<\/A>/g;
> ^ ^
> ^ ^
>
> Those are not needed.
Take another look at that second backslash. You were a bit hasty...
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 16 Sep 1998 11:02:37 -0400
From: Ben Sauvin <sauvin@osmic.com>
Subject: Re: Who posts original posts on CLPM?
Message-Id: <35FFD30D.5855BAA4@osmic.com>
Define "scientific method" within the context of him or her who bemoans its
misapplication.
Elaine -HappyFunBall- Ashton wrote:mixed motives.
# SNIP!
>
> Well suppose I was a 300lb gorilla which may, or may not, fulfill most
> geeky boyz assumptions about what geek chicks look like. You are being
> an ass without actual numbers and you are digging a bigger hole than you
> can possibly defend yourself against. HELLO, are you familiar with
> scientific method. If not, please don't apply or come back later when
> you do. Already, I have much better figures than you do and I can tell
> you that your figures are much different than mine.
>
> > There is a substantial, objective difference between the posting behavior
> > of unix users and that of Windows users. The fact that many circumstances
> > affect a user's choice of posting environment does nothing to explain
> > that difference.
>
> Bullshit. I use NT and I post from NT on occasion. You are totally
> making assumption here that bite my ass.
>
> > I don't know which behavior is better, or what causes the disparity.
>
> Yet you make assumptions you cannot prove either through numbers or
> reality. U B Smoking' crack boy.
>
# SNIP!
------------------------------
Date: Wed, 16 Sep 1998 16:26:08 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Who posts original posts on CLPM?
Message-Id: <35FFE43B.745370C4@bbnplanet.com>
Ben Sauvin wrote:
> Define "scientific method" within the context of him or her who bemoans its
> misapplication.
I could be flip here, but seriously....The 'scientific method' is a
loosely held protocol accepted by those who methodically seek to answer
questions as accurately and honestly as possible. My objection to this
person was not the data, but that he started with an assumption of a
'truth' and then sought out to prove that with raw and misleading data.
There is no demographic information, no correlation and no standard
error in his presentation of the 'facts'. Hence, there was no method,
much less scientific.
This is also somewhat applicable to Perl and how it is used. One starts
with a problem and seeks to solve it. If you have a misconception it
could waste you hours or more of programming time. All disciplines
relate.
e.
"All of us, all of us, all of us trying to save our immortal souls, some
ways seemingly more round-about and mysterious than others. We're having
a good time here. But hope all will be revealed soon." R. Carver
------------------------------
Date: Wed, 16 Sep 1998 16:36:46 GMT
From: dizhao@my-dejanews.com
Subject: Re: Why my perlgrep cannot compared to grep
Message-Id: <6topeu$97j$1@nnrp1.dejanews.com>
Tom,
As you point out, the loop overhead imposed by the interpreter is the
main reason, but my test, which only loops through the whole file and
print it out, costs only 1.9s which is only a small fraction of the
whole 9 seconds. So it shouldn't be the main reason.
Then I checked the second reason, -i. Here are the results:
(.all.2 only contains lower case 'date')
time perl -ne '/date/;' .all.2 > /tmp/null
Result: 1.850u 0.120s 0:01.98 99.4% 0+0k 0+0io 179pf+0w
time perl -ne '/date/i;' .all.2 > /tmp/null
Result: 8.310u 0.110s 0:08.42 100.0% 0+0k 0+0io 178pf+0w
Wow, so the problem is the -i switch!!! This is a big problem to me
because my goal is to reduce my perlgrep's speed to 1-2 seconds when
processing big file. How can I get around this problem and still have
the -i switch? Thanks.
In article <6tmkrb$hbp$1@csnews.cs.colorado.edu>,
tchrist@mox.perl.com (Tom Christiansen) wrote:
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc, dizhao@my-dejanews.com writes:
> : I am wondering why a perl like grep is much slower than ordinary grep.
>
> The basic reason is the general interpreter loop overhead that you don't
> have in grep.
>
> : I use Slackware 2.0.34 and perl 5.0004 and a text file of 381,906
> :lines(19,505,167 characters). The command is like this:
> : time perl -ne ' /date/i;' .all.2 > /tmp/null
>
> Well, you can do better there. /i is rather slow in Perl.
>
> % time perl -ne '/vt100/i' /etc/termcap
> 0.440u 0.000s
>
> % time perl -ne '/[vt][tT]100/' /etc/termcap
> 0.170u 0.010s
>
> --tom
> --
> "Developing fewer bugs before you ship is how you succeed. This Rule does
> not apply to Microsoft." --Rob Pike
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3728
**************************************