[11984] in Perl-Users-Digest
Perl-Users Digest, Issue: 5584 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 6 15:07:18 1999
Date: Thu, 6 May 99 12:00:19 -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 Thu, 6 May 1999 Volume: 8 Number: 5584
Today's topics:
Re: **Free CGI Scripts!** <flavell@mail.cern.ch>
Re: **Free CGI Scripts!** <camerond@mail.uca.edu>
?= Faster??? gaving@my-dejanews.com
Extracting Emails from TXT #2 <joeyandsherry@mindspring.com>
Re: Extracting Emails from TXT <joeyandsherry@mindspring.com>
Re: FAQ 1.1: What is Perl? <cassell@mail.cor.epa.gov>
Re: FAQ 1.1: What is Perl? <uri@sysarch.com>
Re: having problems getting this script to work... (Larry Rosler)
Re: having problems getting this script to work... (Larry Rosler)
Re: having problems getting this script to work... <uri@sysarch.com>
Re: having problems getting this script to work... (Bart Lateur)
Increment a variable's name <tom@ernieball.com>
Re: ISPs that offer cgi space?? (Miles R. Fidelman)
Re: Pentium III Chips Released with IDs - Intel won't b (Sean Murphy)
Perl 5.004_05 Maintenance Update (Chip Salzenberg)
PERLFUNC: atan2 - arctangent of Y/X <perlfaq-suggestions@perl.com>
Re: Question: Win32:Registry <tye@metronet.com>
RegExp Help Please nkaiser@my-dejanews.com
Re: RegExp Help Please vepxistqaosani@my-dejanews.com
Re: split, pop, and cut (Clinton Pierce)
Re: syswrite() lies (Larry Rosler)
Re: unos problemitas (Larry Rosler)
Re: using $, (was Re: having problems) (Bart Lateur)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 6 May 1999 19:49:16 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: **Free CGI Scripts!**
Message-Id: <Pine.HPP.3.95a.990506194832.23801I-100000@hpplus01.cern.ch>
On Thu, 6 May 1999, David Cassell wrote:
> Doesn't ANYONE know the difference between CGI and Perl?
SOMEONE does. You couldn't expect ANYONE to, could you?
;-}
------------------------------
Date: Thu, 06 May 1999 13:36:02 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
To: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: **Free CGI Scripts!**
Message-Id: <3731E112.83DBC623@mail.uca.edu>
[cc'd to dc]
David Cassell wrote:
>
> IlIIIIIIII wrote:
> >
> > get free CGI scripts at:
> > http://tofs.cjb.net
>
> One question:
>
> Doesn't ANYONE know the difference between CGI and Perl?
>
Sure, 316 (dec) or 132 (hex). ;)
--
Cameron Dorey
camerond@mail.uca.edu
------------------------------
Date: Thu, 06 May 1999 18:38:42 GMT
From: gaving@my-dejanews.com
Subject: ?= Faster???
Message-Id: <7gsnjh$c7o$1@nnrp1.deja.com>
Hi, Well Im not exactly a perl newbie, but am quite baffled by something.
i was reading through my reg expression book and noticed an interesting tag.
?= Its for read ahead. So for shits and giggles I have it scan a 50000
line text file, and pit it against the standard pattern matching. I saw no
difference. I would appreciate if someone could show me the proper use, or a
better way for this thanks!
##USING ?=
open(FILE,"<filename");
foreach (<FILE>) {
if ($_ =~ /(?=^gavin)/) {
print "found";
}
}
close(FILE);
##USING Reg Pattern matching
open(FILE,"<filename");
foreach (<FILE>) {
if ($_ =~ /^gavin/) {
print "found";
}
}
close(FILE);
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 6 May 1999 14:26:45 -0400
From: <joeyandsherry@mindspring.com>
Subject: Extracting Emails from TXT #2
Message-Id: <7gsnbi$5k$1@nntp6.atl.mindspring.net>
I have a txt file which let's say is a large letter. In it are Email
addresses along with hundreds of other words. I'd like to write a script
that would read this file and everytime it recoginized an "@" it would look
for the beginning and the end, blank spaces...and write it to a separate
file...I can handle the writing it's just the reading and recognition.
Thanks!
--
Joey Cutchins
President
Trading Post.Com, L.L.C.
http://internettradingpost.com
ceo@internettradingpost.com
------------------------------
Date: Thu, 6 May 1999 14:25:58 -0400
From: <joeyandsherry@mindspring.com>
Subject: Re: Extracting Emails from TXT
Message-Id: <7gsna2$1i8$1@nntp6.atl.mindspring.net>
I have a txt file which let's say is a large letter. In it are Email
addresses along with hundreds of other words. I'd like to write a script
that would read this file and everytime it recoginized an "@" it would look
for the beginning and the end, blank spaces...and write it to a separate
file...I can handle the writing it's just the reading and recognition.
Thanks!
--
Joey Cutchins
President
Trading Post.Com, L.L.C.
http://internettradingpost.com
ceo@internettradingpost.com
------------------------------
Date: Thu, 06 May 1999 11:13:31 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: FAQ 1.1: What is Perl?
Message-Id: <3731DBCB.2DD9591E@mail.cor.epa.gov>
Tom Christiansen wrote:
>
> (This excerpt from perlfaq1 - General Questions About Perl
> ($Revision: 1.22 $, $Date: 1999/04/14 03:46:19 $)
> part of the standard set of documentation included with every
> valid Perl distribution, like the one on your system.
> See also http://language.perl.com/newdocs/pod/perlfaq1.html
> if your negligent system adminstrator has been remiss in his duties.)
>
> What is Perl?
>
> Perl is a high-level programming language with an eclectic heritage
> written by Larry Wall and a cast of thousands. It derives from the
> ubiquitous C programming language and to a lesser extent from sed,
> awk, the Unix shell, and at least a dozen other tools and
> languages
At least. Is there any language Perl hasn't derived *something*
from? I see BASIC in the formats, so that's out. COBOL? Forth?
Eiffel? Pearl?
This is a semi-serious question. Have other posters thought about
the etymology and philology of some of the interesting corners of
Perl?
> [snip of rest of text]
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: 06 May 1999 14:46:02 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: FAQ 1.1: What is Perl?
Message-Id: <x7n1zivxxx.fsf@home.sysarch.com>
>>>>> "DC" == David Cassell <cassell@mail.cor.epa.gov> writes:
DC> Tom Christiansen wrote:
>> Perl is a high-level programming language with an eclectic heritage
>> written by Larry Wall and a cast of thousands. It derives from the
>> ubiquitous C programming language and to a lesser extent from sed,
>> awk, the Unix shell, and at least a dozen other tools and
>> languages
DC> At least. Is there any language Perl hasn't derived *something*
DC> from? I see BASIC in the formats, so that's out. COBOL? Forth?
DC> Eiffel? Pearl?
DC> This is a semi-serious question. Have other posters thought about
DC> the etymology and philology of some of the interesting corners of
DC> Perl?
check back a few months for a thread i started on the origins of perl
features. it got pretty hot and heavy and was fairly educational. i
don't recall the title but search for origin and some of the language
names like basic, lisp, etc and you should find it.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Thu, 6 May 1999 11:35:24 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: having problems getting this script to work...
Message-Id: <MPG.119b80c6ec6488499899de@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <x7pv4ew2aa.fsf@home.sysarch.com> on 06 May 1999 13:12:13 -
0400, Uri Guttman <uri@sysarch.com> says...
> >>>>> "AQ" == Ala Qumsieh <aqumsieh@matrox.com> writes:
> AQ> Uri Guttman <uri@ibnets.com> writes:
> >> this is the first time i have seen $, used for good and not for evil.
>
> AQ> I am a regular user of $, $" $/ and $\
> AQ> My usual use for $, is as follows:
>
> AQ> { local $, = ', '; print @array }
I would have written that as:
{ local $" = ', '; print "@array" }
As you observed in your previous post, the documentation of '$,' refers
to the commas in a list, and one can't use '$"' on a list. So the list
would seem to be the proper venue for '$,'.
> and i would do:
>
> print join( ', ', @array);
>
> which is shorter and faster. and probably clearer as most people don't
> use $,
That it should be so fast is startling to me. It constructs what may be
a huge scalar, then hands it to 'print', whereas the other locutions
hand a list to 'print'. Evidently bigger is faster.
> so show me where $, is more useful than join. again i can only imagine
> awkish type -p/-n loops with maybe autosplit in there.
Good question!
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 6 May 1999 11:38:26 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: having problems getting this script to work...
Message-Id: <MPG.119b817bfedebf609899df@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <3733cafd.483394@news.skynet.be> on Thu, 06 May 1999 17:03:19
GMT, Bart Lateur <bart.lateur@skynet.be> says...
> Larry Rosler wrote:
> BL>> {
> BL>> local $\ = "\n";
> BL>> print OUT foreach @data;
> BL>> }
>
> LR>Is your computer busted? I posted the benchmark code, as always, and
> LR>several others have already posted variants.
>
> Is your brain busted? ;-)
>
> This variant is one that I didn't see. Note that $\ is set, but $, not.
> Therefore it prints $_, not "$_\n".
Are we communicating? If you didn't see it in the benchmark, you copy-
and-paste the benchmark into a text editor, add the variant you want,
and then run it.
Let us know what happens, though. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 06 May 1999 14:56:46 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: having problems getting this script to work...
Message-Id: <x7iua6vxg1.fsf@home.sysarch.com>
>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
LR> [Posted and a courtesy copy mailed.]
LR> In article <x7pv4ew2aa.fsf@home.sysarch.com> on 06 May 1999 13:12:13 -
LR> 0400, Uri Guttman <uri@sysarch.com> says...
LR> I would have written that as:
LR> { local $" = ', '; print "@array" }
LR> As you observed in your previous post, the documentation of '$,' refers
LR> to the commas in a list, and one can't use '$"' on a list. So the list
LR> would seem to be the proper venue for '$,'.
the doc refer to the mnemonic of , in a list. but allowing a single
@array to be a list of fields is a gray area IMO.
>> and i would do:
>>
>> print join( ', ', @array);
>>
>> which is shorter and faster. and probably clearer as most people don't
>> use $,
LR> That it should be so fast is startling to me. It constructs what may be
LR> a huge scalar, then hands it to 'print', whereas the other locutions
LR> hand a list to 'print'. Evidently bigger is faster.
i think it is more to do with the general purpose nature of print
vs. the specific nature of join. print has to check for all kinds of
things between printing each value in @array: is $, set? then use it;
copying things to the output buffer; conversions to strings, etc.
join just does a tight loop copying to a single buffer with the required
separator between the values. then print does a simple output of the big
string.
that is why join always beats join simulators like "@array" and $,
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Thu, 06 May 1999 18:51:21 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: having problems getting this script to work...
Message-Id: <3734e358.1148097@news.skynet.be>
Larry Rosler wrote:
>Is your computer busted? I posted the benchmark code, as always, and
>several others have already posted variants.
Oh well. I've done it myself. Of course, it's a different (much slower!)
computer, plus a different Perl port, and I don't know how it compares
to other computers. I've added a few variants myself.
timethese(1 << (shift || 10), {
For => sub { print OUT "$_\n" for @data },
Map => sub { print OUT map "$_\n", @data },
Vars => sub { local($,, $\) = ("\n", "\n"); print OUT @data },
ForVars => sub { local $\ = "\n"; print OUT foreach @data },
Join => sub { local($\) = "\n"; print OUT join("\n",@data) },
JoinImplicit => sub { local($") = ("\n","\n"); print OUT "@data\n" },
});
__END__
I've edited the output, and ordered them in in ascending time needed.
Vars: 7 wallclock secs ( 6.81 usr + 0.00 sys = 6.81 CPU)
Join: 7 wallclock secs ( 6.87 usr + 0.00 sys = 6.87 CPU)
ForVars: 7 wallclock secs ( 7.36 usr + 0.00 sys = 7.36 CPU)
JoinImplicit: 8 wallclock secs ( 7.58 usr + 0.00 sys = 7.58 CPU)
For: 9 wallclock secs ( 8.19 usr + 0.00 sys = 8.19 CPU)
Map: 12 wallclock secs (11.65 usr + 0.00 sys = 11.65 CPU)
Well, my new version doesn't do so badly. I find it's the most readable
version, anyway.
Bart.
------------------------------
Date: Thu, 06 May 1999 11:48:01 -0700
From: Tom Pape <tom@ernieball.com>
Subject: Increment a variable's name
Message-Id: <3731E3E1.F11997FA@ernieball.com>
Is there a way I can increment a variable's name? The form I am
processing can have a different number of quantity variables depending
on the number of items listed. If I have $i number of items can I
assign values to a variable that might look like qty$i? I need to
incerment the variables name by 1 each time a loop runs, for example:
qty1, then qty2, then qty3 ....
Thank you for your help
Tom Pape
Ernie Ball, Inc. / MusicMan
tom@ernieball.com
------------------------------
Date: Thu, 6 May 1999 18:12:40 GMT
From: fidelman@world.std.com (Miles R. Fidelman)
Subject: Re: ISPs that offer cgi space??
Message-Id: <FBBp94.93D@world.std.com>
David Cassell (cassell@mail.cor.epa.gov) wrote:
: Miles R. Fidelman wrote:
: > Mike Flaherty (mflaherty2@earthlink.net) wrote:
: > : I am looking to start a web site for public use. I know there are plenty
: > : of ISPs that offer web space - even for free. However, I want to use CGI
: > : scripts and I will need access to a command line in order to develop/debug
: > : them. This is a non issue for the stuff I write at work but do commercial
: > : ISPs allow that kind of access?
: > You might also try asking on:
: > comp.infosystems.www.servers.unix
: > comp.infosystems.www.authoring.cgi
: But his question is not appropriate for the *other* newsgroups you
: named. Now he's liable to go pester more people who don't want to see
: such posts in their newsgroups either. I trust you feel appropriately
: guilty about this. :-)
David,
I'm sorry to disagree, but I've seen that precise question come up in both
of those newsgroups, and it's always struck me as quite appropriate.
Personally, my standard response to postings I personally feel are
inappropriate is to killfile them.
Miles
------------------------------
Date: Thu, 06 May 1999 17:57:11 GMT
From: smurphy*NOSPAM*@schange.com (Sean Murphy)
Subject: Re: Pentium III Chips Released with IDs - Intel won't budge
Message-Id: <3731cf35.68486969@news.ultranet.com>
Anybody who really wants to "Pose as you" on the Internet can do it
with or with out this PIII Id Number. There are a whole host of
Numbers you system transmits out to the web when you are surfing.
Some of these you have control over some you don't.
FWIW - Any body who can get you PIII Machine to give up the ID to then
and then cause his Machine transmit it (or a simulation of it). Has
enough knowledge of PCs and the Internet to get all of info he needs
to "pose as you" Even if you don't have a PIII.
As far as your buying and surfing habits on the web. That is also
already available to anybody willing to pay for it. Most ISPs will
sell that data in flash. Oh, they may say they don't but do you
really believe that.
These new chips aren't going to present any new issues for your
"On-line privacy" on the web. This is just easy enough that the media
can some what understand it and cause the public to get all freaked
out with their Misinformation and Misrepresentation of the facts.
People love to hate companies like, Intel and Microsoft but most of
them don't know why. Chances are if you are reading this. You and
using at least one chip (most likely more) made by Intel, and AT LEAST
ONE software package made by Microsoft. Just take a minute and think
about the ways These two "unthinkable monsters" have affected your
life. .... (I'll wait)
That's what I thought. Life is a whole lot nicer with them around.
Isn't it? Well, I guess we could go back to the Commodore 64s right.
That's my $0.02
S
On Wed, 05 May 1999 21:07:19 GMT, Intelz@nospam.net (Intel No Privacy)
wrote:
>
> Pentium III chip with the individual serial number that can
>track your web surfing and buying habits can now have the ID number
>turned on and off by software. Following some links I found the
>www.fightdivx.com website and noticed that they have a Intel Boycott
>page with links, quotes and info on why you should boycott the
>invasion of privacy Pentium III chips. Just like everyone suspected,
>the ID number can be taken without a customers knowledge. Just like
>cellular phone fraud, once someone has your unique ID number, they
>could pose as you on the internet. Do not be fooled by reports that
>this problem is fixed because Intel disabled this feature by software
>on their up coming chips. Information is power. They want to know
>your surfing and buying habits. That is what this is all about. Here
>is the link to the page with the boycott info and links.
>
>http://www.fightdivx.com/intelboycott.htm
>
>Also you will find a Boycott Intel screen saver and banner on their
>page above. Spread it around.
>
>
>
------------------------------
Date: 6 May 1999 18:00:14 GMT
From: chip@perlsupport.com (Chip Salzenberg)
Subject: Perl 5.004_05 Maintenance Update
Message-Id: <7gslbe$vtl$1@play.inetarena.com>
The fifth maintenance update for Perl 5.004 was released on April 29,
1999, and is now available worldwide from the Comprehensive Perl
Network Archive (CPAN). Note that the current version of Perl is
5.005; however, 5.004 continues under active maintenance. To select
from a list of CPAN sites, go to:
http://www.perl.com/CPAN
Note the absence of a trailing `/'. The actual file can be found at:
http://www.perl.com/CPAN/authors/id/CHIPS/perl5.004_05.tar.gz
This release is binary compatible with previous 5.004 releases.
+---------------------------------------------------------+
| SUMMARY OF CHANGES IN PERL 5.004 MAINTENANCE UPDATE 5 |
+---------------------------------------------------------+
BETTER SECURITY
* When Perl is built to emulate set[ug]id scripts, it now honors
filesystem mount options that disallow execution of set[ug]id
programs.
* The substitution operator could sometimes untaint its target.
Now it doesn't. Also, the "-U" flag again works correctly. (But
please don't use "-U" unless you really know what you're doing.)
* The "-e" command line option no longer creates a temporary file.
BETTER PERFORMANCE
* The sort operator now uses a very fast/safe built-in qsort,
instead of depending on the one in the local C library.
* Other miscellaneous improvements.
MORE SCRIPT PORTABILITY
* Scripts with CR LF line endings (a la MS-DOS/Windows) work on
Unix.
MORE PLATFORM PORTABILITY
* Many Configure updates
* Updated hints for:
AIX, BSD/OS, DEC OSF/1, FreeBSD, HP/UX, Irix, Linux, MachTen,
NetBSD, OS/2, PowerUX, QNX, SCO Unix, Solaris 2.x, SunOS 4.1,
System V Release 4, UNICOS
MORE VERSION PORTABILITY
* Some 5.005 language features:
EXPR foreach LIST
"PackageName::" bearword
"use attrs" pragma (stub)
"use re" pragma (stub)
* Some 5.005 internals/XS features for XS authors:
ERRSV, ERRHV, DEFSV, SAVE_DEFSV, dTHR
SMARTER WARNINGS
* Automatic insertion of defined() in while($var = <>)
* No more warnings on:
$x{shift} # $x{'shift'}
ne => 1 # 'ne' => 1
-f => 1 # '-f' => 1
NEW MODULES
* File::Spec Portable operations on file names
* Test A simple framework for writing test scripts
* Tie::Handle Base class for tied handles
UPDATED MODULES
* CGI 2.42
* CPAN 1.40
* Getopt::Long 2.19
NEW DOCUMENTATION
* perlhist Perl History
* perlmodinstall Installing CPAN Modules
* perlport Portability Guide
ENHANCED UTILITIES
* Many enhancements for h2ph, perldoc, perlbug, etc.
BUG FIXES
* Too many to enumerate.
Share and enjoy!
--
Chip Salzenberg - a.k.a. - <chip@perlsupport.com>
-> Ask me about Perl training and consulting <-
"It's a dangerous game we play." "You mean, like, Jarts?!" //MST3K
------------------------------
Date: 6 May 1999 12:20:04 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: PERLFUNC: atan2 - arctangent of Y/X
Message-Id: <3731dd54@cs.colorado.edu>
(This excerpt is from the perlfunc manpage, part of the standard set of
documentation included with every valid Perl distribution--like the one on
your own system. See also http://language.perl.com/newdocs/pod/perlfunc/
if your negligent system adminstrator has been remiss in his duties.)
NAME
atan2 - arctangent of Y/X
SYNOPSIS
atan2 Y,X
DESCRIPTION
Returns the arctangent of Y/X in the range -PI to PI.
For the tangent operation, you may use the `POSIX::tan()' function,
or use the familiar relation:
sub tan { sin($_[0]) / cos($_[0]) }
--
There ain't nothin' in this world that's worth being a snot over.
--Larry Wall in <1992Aug19.041614.6963@netlabs.com>
------------------------------
Date: 6 May 1999 13:28:03 -0500
From: Tye McQueen <tye@metronet.com>
Subject: Re: Question: Win32:Registry
Message-Id: <7gsmvj$hps@fumnix.metronet.com>
"Matthias Weindorf" <m.weindorf@mainz.netsurf.de> writes:
) require "NT.ph";
This is the old way and shouldn't be used any more.
) use Win32::Registry;
[...]
) Win32::RegOpenKeyEx( &HKEY_LOCAL_MACHINE, $path,$type, &KEY_ALL_ACCESS,
) $LocalHandle);
I'd suggest HKEY_LOCAL_MACHINE() and KEY_ALL_ACCESS() instead,
but the "why" is a long story.
Using C<Win32::RegOpenKeyEx()> is the old way and doesn't work
anymore [unless one is using a really old version of Perl or
Win32::Registry, like you must be]. ActiveState [or whatever
they were called way back then] didn't understand a lot of things
about Perl when they wrote Win32::Registry and so there really
wasn't a way to provide full backward compatibility in any of
the modern versions of Perl.
I suggest you upgrade to a modern version of Perl before too long.
) Win32::RegQueryValueEx($LocalHandle, $key, 0 ,$type , $value);
The source of the problem that you complained about is that you
don't check the return value from these calls. But Win32::Registry
doesn't come with any documentation, so you almost have a good
excuse. If you get a modern version of Perl then you'll get a
modern version of libwin32 which includes Win32API::Registry which
comes with documentation. It also includes Win32::TieRegistry
which makes playing with the Registry easier.
) return $value;
) }
--
Tye McQueen Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
------------------------------
Date: Thu, 06 May 1999 17:47:24 GMT
From: nkaiser@my-dejanews.com
Subject: RegExp Help Please
Message-Id: <7gskja$9aq$1@nnrp1.deja.com>
This seems so simple, but I can't get it to work....
I want to replace %WHATEVER% with "+WHATEVER+"
Here's what I have:
$str="name1=%val1%&name2=%val2";
$str=~s/%(.*)%/"+$1+"/g;
It's not working. It prints out:
name1="+val1%&name2=%val2+"
It's only looking at the first and last %'s.
Thanks.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 06 May 1999 17:59:42 GMT
From: vepxistqaosani@my-dejanews.com
Subject: Re: RegExp Help Please
Message-Id: <7gslac$9tt$1@nnrp1.deja.com>
Being new to this myself, I spend a lot of time with my nose in the Camel and
Hip Owls books. You should, too.
Perl matches greedily unless you use ?: that is, it's _supposed_ to look only
at the first and last %'s. So try (tested)
s/%(.*?)%/"+$1+"/g;
(why the /g?)
Fred
In article <7gskja$9aq$1@nnrp1.deja.com>,
nkaiser@my-dejanews.com wrote:
> This seems so simple, but I can't get it to work....
>
> I want to replace %WHATEVER% with "+WHATEVER+"
>
> Here's what I have:
>
> $str="name1=%val1%&name2=%val2";
> $str=~s/%(.*)%/"+$1+"/g;
>
> It's not working. It prints out:
> name1="+val1%&name2=%val2+"
>
> It's only looking at the first and last %'s.
>
> Thanks.
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 06 May 1999 18:21:13 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: split, pop, and cut
Message-Id: <3734dd13.793160834@news.ford.com>
On Thu, 06 May 1999 12:26:02 -0400, Peter Eisengrein
<prsinfo@profrecovery.com> wrote:
>I am looking for a way to split not by delimiter (which is like the UNIX
>'cut -d'), but instead by character count, like the UNIX 'cut -c'
>command. I know I can cut off the end with pop, but that isn't exactly
>right either.
>
>I can't find this anywhere in the man pages or on the Web. Any help you
>can offer is greatly appreciated. Thanks.
Long answer: perldoc perlfaq5
Short answer: perldoc -f substr
c.l.p.m. a gigantic "English-to-manpage" machine...
--
Clinton A. Pierce "If you rush a Miracle Man, you get rotten
clintp@geeksalad.org Miracles." -- Miracle Max, The Princess Bride
http://www.geeksalad.org
------------------------------
Date: Thu, 6 May 1999 11:19:23 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: syswrite() lies
Message-Id: <MPG.119b7d0a60eacbee9899dd@nntp.hpl.hp.com>
[WARNING: This post contains lengthy excerpts from Perl documentation,
in a good cause, I hope! Skip to the CONCLUSION, if you must. I don't
believe in 'Executive Summary's.]
In article <x7vhe6w3dn.fsf@home.sysarch.com> on 06 May 1999 12:48:36 -
0400, Uri Guttman <uri@sysarch.com> says...
> >>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
...
> LR> The CP/M decision was to retain the literal meaning of LF (which
> LR> simplifies the TTY driver a smidgen) and to translate the "\n" to CR/LF
> LR> not only in the TTY driver but also in the external-storage drivers.
...
> you are missing a little history here. cp/m derived from dec's RT-11 and
> all of dec's OS's used cr/lf in the files. the different behavior of the
> 2 chars is still evident in glass tty's where a printed bare cr will do
> just that, move the cursor to the beginning of the line. unix's genius
> here was in moving the knowledge of translating \n to cr/lf into the
> driver and using only lf in the files and in c which makes for simpler
> coding.
Thanks for pushing the horizon for this decision back further than CP/M.
I had assumed it was comparable to the arbitrary xNU (x's Not Unix)
command-line-interface decisions, such as \ for /, / for -, and 'copy'
for 'cp'. It makes more technological sense in the era before device-
independent data and intelligent device drivers.
> and there are no differences in files on winblows, only in how you
> interpret them. you can read any file with/without binmode. only one way
> will make sense for any given file. since the default is text mode with
> cr/lf translation in the io library, and most files processed by perl
> are text, this leads to the fine complacency of winblows perl
> hackers. then they get bit by not understanding their platforms and
> perl.
Pervasive examples showing 'open a binary file; binmode the filehandle'
as a Perl idion (The Way To Do It) would certainly help a lot.
> as for the docs stating to use binmode in open, open doesn't care about
> the file format. the i/o and platform care so the hacker should know
> about those things. and since we have empirical proof that winblows perl
> hackers don't rtfm (except you larry), we have an impasses.
I am not a 'winblows perl hacker' in any sense. I have never used a
Win32 module for example (or many other modules, so that doesn't prove
much :-). I would much prefer to consider myself a 'portable-Perl
hacker', as I became a 'portable-C hacker'.
I hate Micro$oft, I despise Windows systems, and I nevertheless now use
them exclusively for everything except programming (which I do by
telnetting from the Windows systems to Unix boxes :-)! I like Perl, and
want to see it pervasive.
> but a
> mention there might be in order so we can lower the noise level of this
> issue.
It would certainly help. For example, the only mention of 'binary' in
perlfaq5: "How do I randomly update a binary file?" shows an 'open'
without a 'binmode'. Surprise, surprise!
Here is the relevant paragraph from the perlfunc entry for 'open', and
the perlfunc entry for 'binmode' in its entirety:
If you're unfortunate enough to be running Perl on a system that
distinguishes between text files and binary files (modern operating
systems don't care), then you should check out binmode for tips for
dealing with this. The key distinction between systems that need
binmode() and those that don't is their text file formats. Systems like
Unix, MacOS, and Plan9, which delimit lines with a single character, and
which encode that character in C as "\n", do not need binmode(). The
rest need it.
binmode FILEHANDLE
Arranges for the file to be read or written in ``binary'' mode in
operating systems that distinguish between binary and text files. Files
that are not in binary mode have CR LF sequences translated to LF on
input and LF translated to CR LF on output. Binmode has no effect under
many sytems, but in MS-DOS and similarly archaic systems, it may be
imperative--otherwise your MS-DOS-damaged C library may mangle your
file. The key distinction between systems that need binmode() and those
that don't is their text file formats. Systems like Unix, MacOS, and
Plan9 that delimit lines with a single character, and that encode that
character in C as "\n", do not need binmode(). The rest may need it. If
FILEHANDLE is an expression, the value is taken as the name of the
filehandle.
If the system does care about it, using it when you shouldn't is just as
perilous as failing to use it when you should. Fortunately for most of
us, you can't go wrong using binmode() on systems that don't care about
it, though.
****
Note 'modern operating systems don't care', the description of MS-DOS as
'archaic', the C library as 'MS-DOS-damaged', and the gratuitous mention
of Plan9, for God's sake. How useful! But 'Windows' doesn't appear at
all. Except for the snide 'for most of us' in the last sentence under
'binmode', that sentence is correct and should be plastered everywhere.
For completeness, here is an excerpt from the *new* document called
perlopentut:
Binary Files
On certain legacy systems with what could charitably be called
terminally convoluted (some would say broken) I/O models, a file
isn't a file--at least, not with respect to the C standard I/O
library. On these old systems whose libraries (but not kernels)
distinguish between text and binary streams, to get files to behave
properly you'll have to bend over backwards to avoid nasty
problems. On such infelicitous systems, sockets and pipes are
already opened in binary mode, and there is currently no way to
turn that off. With files, you have more options.
Another option is to use the `binmode' function on the appropriate
handles before doing regular I/O on them:
binmode(STDIN);
binmode(STDOUT);
while (<STDIN>) { print }
Passing `sysopen' a non-standard flag option will also open the
file in binary mode on those systems that support it. This is the
equivalent of opening the file normally, then calling `binmode'ing
on the handle.
sysopen(BINDAT, "records.data", O_RDWR | O_BINARY)
|| die "can't open records.data: $!";
Now you can use `read' and `print' on that handle without worrying
about the system non-standard I/O library breaking your data. It's
not a pretty picture, but then, legacy systems seldom are. CP/M
will be with us until the end of days, and after.
On systems with exotic I/O systems, it turns out that,
astonishingly enough, even unbuffered I/O using `sysread' and
`syswrite' might do sneaky data mutilation behind your back.
while (sysread(WHENCE, $buf, 1024)) {
syswrite(WHITHER, $buf, length($buf));
}
Depending on the vicissitudes of your runtime system, even these
calls may need `binmode' or `O_BINARY' first. Systems known to be
free of such difficulties include Unix, the Mac OS, Plan9, and
Inferno.
*****
This speaks for itself, except for the addition of Inferno to the list
of blessed systems.
CONCLUSION
There is only one conclusion to be drawn from all this BIGOTRY: We
collectively are diminishing the utility of Perl by biasing its
documentation in this way. I urge a bunch of *real* 'winblows perl
hackers' to put together documentation patches that will deal with this
BIGOTRY, and force the patches into the Perl corpus. And I urge Perl
writers and teachers to use 'binmode' in each and every example of
opening a binary file -- without disparagement!
Then, maybe, the noise level here about binary files will begin to
diminish. (Except for Jove's thunder, and his lightning, which will
strike me dead.)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 6 May 1999 11:50:48 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: unos problemitas
Message-Id: <MPG.119b8460e1baadab9899e0@nntp.hpl.hp.com>
In article <37319B7E.95E92D76@mail.uca.edu> on Thu, 06 May 1999 08:39:10
-0500, Cameron Dorey <camerond@mail.uca.edu> says...
> Tom Christiansen wrote:
> > In comp.lang.perl.misc, bart.lateur@skynet.be (Bart Lateur) writes:
> > : open (FILE, ">$fn") || print "Problemo: $!";
> >
> > Cool -- a new language! "problemo" is not a word in any language I have
> > ever heard of. What language was that?
> >
> > [etymology lesson snipped]
>
> Well, I don't find "modulo" in Webster's (or Cassell's), either, but you
> seem to find it used around here quite a bit. ;)
You need to get a new (or old???) dictionary.
Webster's Seventh New Collegiate Dictionary (based on Webster's Third
International Dictionary), Merriam, 1961:
modulo \'maj-u-lo\ adv [NL, abl. of modulus]: with respect to a modulus.
The American Heritage Dictionary (computerized):
mod7u7lo (m<j-l=) prep. Mathematics. With respect to a specified
modulus: 18 is congruent to 42 modulo 12 because both 18 and 42 leave 6
as a remainder when divided by 12. [Latin modul=, ablative of modulus,
diminutive of modus, measure. See MODE.]
They don't agree on whether it's an adverb or a preposition. As it
refers to a noun (e.g., twelve), it must be the latter.
> BTW, "problemo" predates the Simpsons or other TV shows I've seen listed
> in this thread by quite a few years. I remember hearing/using it 35-40
> years ago, when I was a kid. Pig-Spanish, I think.
Someone suggested Esperanto. Plural 'problemoj' ??? :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 06 May 1999 18:51:18 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: using $, (was Re: having problems)
Message-Id: <3733e2fe.1057855@news.skynet.be>
Uri Guttman wrote:
>but as i said, join has been shown to be faster. i have created many tab
>seperated files (and today i will be creating a new script to do another
>one) and i will use join.
Are you sure?
I can remember the discussion about "@data" versus join, but not with
regards to $,. "@data" is internally converted to { join($",@data) }
anyway.
The benchmark I just posted in the original thread, seems to indicate
that $, is indeed a bit faster than join, which in it's turn is still
slower than "@data" (using $").
That's what I would expect. { print @data } does NOT require
construction of the whole string. Instead, it can print out one array
item at a time. Therefore it can be faster.
>so what advantage does it have over join unless you want all output to
>have $, used?
Readbility. I think
print @data;
looks a LOT less horrible (and is therefore less error-prone) than
print join("\t",@data)."\n";
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 5584
**************************************