[8568] in Perl-Users-Digest
Perl-Users Digest, Issue: 2186 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 26 10:08:15 1998
Date: Thu, 26 Mar 98 07:00:59 -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, 26 Mar 1998 Volume: 8 Number: 2186
Today's topics:
Re: "Newbie" Crib Notes <jprenis@voicenet.com>
2$b || !2$b ? ; <david@thames.com>
Bad interaction between perl and gdbm in cgi script? (James Martino)
Bidirectional Filehandle??? <TobiasBugala@swol.de>
Re: Days of the Week <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: GD.pm <d080048@ec.hokudai.ac.jp>
Re: Going Rates for PERL Programming??? <jdporter@min.net>
Re: Going Rates for PERL Programming??? <jdporter@min.net>
Re: Going Rates for PERL Programming??? (Mike Heins)
Re: help with Hardware ethernet addresses please ( Mark Kucera)
Re: help with Hardware ethernet addresses please (Jason Gloudon)
Re: help with Hardware ethernet addresses please <dbrowne@indiana.edu>
Re: Need sorting routine in Perl <amar@iss-gmbh.de>
Re: Need sorting routine in Perl <jdporter@min.net>
Re: Need sorting routine in Perl (Jason Gloudon)
Re: Need sorting routine in Perl <jdporter@min.net>
Re: noetebook /perl-cgi module ??? <mglenn@no.spam.zbzoom.net>
Re: Perl Databases... <jdporter@min.net>
Re: Problems with handling Mac/PC/Unix line breaks (Lasse =?ISO-8859-1?Q?Hiller=F8e?= Petersen)
Re: Problems with handling Mac/PC/Unix line breaks (Chris Nandor)
Re: Problems with handling Mac/PC/Unix line breaks (Andrew M. Langmead)
Re: PROPOSAL: The Perl Dictionary <*@qz.to>
Re: regular expression <jdporter@min.net>
Re: Unlink on WinNT/95 (Andrew M. Langmead)
Re: verifying email address -- how? <jdporter@min.net>
Re: || and 'or' - implications? (Ian Macdonald)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 26 Mar 1998 14:43:20 GMT
From: John Prenis <jprenis@voicenet.com>
Subject: Re: "Newbie" Crib Notes
Message-Id: <cQtS.1559$tR.4595524@news2.voicenet.com>
Mark's notes and Abigail's comments saved with appreciation- I don't
have time to read more than a fraction of what appears here.
In defense of "incomplete, poorly-thought-out solutions", the simple
solution may be the easiest for a newbie to grasp. And sometimes it's
perfectly adequate. A module may get the job done better, but the
newbie isn't going to learn basic Perl that way.
Of course learning -why- the simple solution won't always work is even
better!
--
John Prenis "Just another Perl newbie"
------------------------------
Date: Thu, 26 Mar 1998 14:51:25 -0000
From: "David Rayner" <david@thames.com>
Subject: 2$b || !2$b ? ;
Message-Id: <6fdpps$bd$1@plug.news.pipex.net>
2$b || !2$b ? ;
I'm having trouble get this Perl script to work, in fact it's
turning out to something of a tragedy <G>
------------------------------
Date: 24 Mar 1998 19:41:33 GMT
From: jrm@chow.mat.jhu.edu (James Martino)
Subject: Bad interaction between perl and gdbm in cgi script?
Message-Id: <6f929d$4oh@news.jhu.edu>
Situation: linux (debian 1.3.1 with most recent stable debian perl and gdbm).
I have been experiencing a very strange effect which occurs when using
the foreach statement in perl in conjunction with gdbm. I would
appreciate it if anyone could tell me whether:
a) This is a FAQ (in which case, Sorry!)
b) This is a fixed bug
c) This is a reported bug.
d) Anyone else has experienced this
e) I'm overlooking sopmething really basic (in which case, Sorry!)
Apparently something in the interaction between perl and gdbm causes
the supposedly private index variable for the foreach loop to be
clobbered on the last pass through the loop. (Reasons for this guess
follow).
Here a simulated perl code snippet which produces the problem. Names
have been changed to protect the innocent. Following that is a
kludge^Whack^Wworkaround which works correctly, but should be
equivalent to the broken snippet.
Thanks very much for any help,
Jim
======================================================================
my $record;
foreach $record (@theList){
unless ($record =~ /\S/) {next;}
chomp $record;
my @theListRecord=&getRecord($record);
my($lots, $of, $fields, $in, $here)= @theListRecord;
if(&someCondition)) {
print " This is a bogus error message\n";
}
elsif (&someCallUsingGdbm) {
print " Another bogus error message\n";
}
else {
&anotherCallUsingGdbm;
print "We did this cool thing for you\n";
}
}
If one comments out both of the calls to subroutines using gdbm and
inserts print statements to display the current record, the printed
info is correct. If one then uncomments either of the calls using
gdbm, all printed records are correct except the last one - it
disappears and is replaced by a 1. Of course, the subroutines produce
weird output on the last pass through also when the statements are
uncommented.
The following produces correct output - it is believed that the
explicitly unclobberable nature of the loop index variable is the
reason why the output is now correct.
my $i;
for($i=0; $i<@theList; $i++){
my $record=@theList[$i]; #same as the above from here down
unless ($record =~ /\S/) {next;}
chomp $record;
my @theListRecord=&getRecord($record);
my($lots, $of, $fields, $in, $here)= @theListRecord;
if(&someCondition)) {
print " This is a bogus error message\n";
}
elsif (&someCallUsingGdbm) {
print " Another bogus error message\n";
}
else {
&anotherCallUsingGdbm;
print "We did this cool thing for you\n";
}
}
--
James R. Martino * VOICE: (410) 516-7881
Director of Undergraduate Studies in Mathematics * FAX: (410) 516-5549
Department of Mathematics * EMAIL:James.Martino@jhu.edu
The Johns Hopkins University *
------------------------------
Date: Thu, 26 Mar 1998 15:49:08 +0100
From: Tobias Bugala <TobiasBugala@swol.de>
Subject: Bidirectional Filehandle???
Message-Id: <351A6AE4.2689@swol.de>
Hi,
I have a file in wich a incremeting number is saved. Now I should open
it once for Read AND Write.
I tested something like:
...
open (FILE, "+>$filename") or die ...
$number = <FILE>;
chop $number;
$number++;
print FILE "$number\n";
close (FILE);
...
And in the $filename - File should be s.th. like:
Before:
12345
After:
12346
TOBI
------------------------------
Date: 26 Mar 1998 15:02:26 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Days of the Week
Message-Id: <7xg1k5y2h9.fsf@beavis.vcpc.univie.ac.at>
Re: Days of the Week, Mike <strepsil@very.net> said:
Mike> Anyone out there got a neat little snippet of code, or
Mike> just a method I can use to find out what day of the
Mike> week a given date fell on?
Date::DateCalc
Date::Manip
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, AT | http://www.vcpc.univie.ac.at/
"Everything I am, I learned on the back of cereal boxes" ~ RJ, "Over the Hedge"
------------------------------
Date: Thu, 26 Mar 1998 22:41:42 +0900
From: Kazunori Nozaki <d080048@ec.hokudai.ac.jp>
Subject: Re: GD.pm
Message-Id: <351A5B16.40348383@ec.hokudai.ac.jp>
Kazunori Nozaki wrote: >perl pie.cgi
> Can't find loadable object for module GD in @INC (/home/soccer
> /home/soccer/lib /home/soccer/GD-1.18
> /blib /home/soccer/GD-1.18 /usr/local/lib/perl5/sun4-solaris/5.00402
> /usr/local/lib/perl5 /usr/local
> /lib/perl5/site_perl/sun4-solaris /usr/local/lib/perl5/site_perl .) at
> pie.cgi line 5
> BEGIN failed--compilation aborted at pie.cgi line 5.
>
> so,I can't solve this problem by myself.
> Please teach me!!!
>
I could have solved!Thank you!
------------------------------
Date: Thu, 26 Mar 1998 09:05:54 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Going Rates for PERL Programming???
Message-Id: <351A60C2.4ADC@min.net>
brian d foy wrote:
>
> [...] some economists say that
> they don't beleive that there is a shortage of high-tech
> workers because there is not evidence of "upward wage
> pressure".
They're full of crap, whatever their reasons.
> [...] people trying to break into
> the Perl world might be the same way - they'll do anything
> to be able to do Perl a lot and employers or business might
> take advantage of these (e.g. all these posts for a Perl
> scripter in exchange for equity or ad revenues). is part
> of the absence of the "upward wage pressure" due to
> Perl programmers selling themselves short?
I think you've hit the nail on the head.
Well, actually there's two nails. The other one is that
employers don't see perl programming as "real" programming
because perl is "interpreted", and it is used for WWW --
which, as everyone knows, is lightweight stuff. (Yeah right.)
They want to pay the perl cgi guy the same as their dos batch
guy.
John Porter
------------------------------
Date: Thu, 26 Mar 1998 09:13:36 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Going Rates for PERL Programming???
Message-Id: <351A6290.1543@min.net>
Peter Perchansky wrote:
>
> My point is that time is time is time... it is fixed, unmutable, etc. If
> you are skilled at what you do, then the value of what you do should be the
> same.
That completely ignores economics. The value of what I produce
may be the same in either case, but I should charge what I can
to do it. That's supply and demand. If I ask 100/hr to do what
everyone else is charging 45/hr for, I'm out. Who decides what
the "value" is of what I produce, in $/hour?
Time doing something I love (and would do for free if I didn't
have rent to pay), and time doing something I loathe, they are
not they same.
John Porter
------------------------------
Date: 26 Mar 98 14:55:29 GMT
From: mikeh@minivend.com (Mike Heins)
Subject: Re: Going Rates for PERL Programming???
Message-Id: <351a6c61.0@news.one.net>
John Porter <jdporter@min.net> wrote:
> Well, actually there's two nails. The other one is that
> employers don't see perl programming as "real" programming
> because perl is "interpreted", and it is used for WWW --
> which, as everyone knows, is lightweight stuff. (Yeah right.)
> They want to pay the perl cgi guy the same as their dos batch
> guy.
My experience has been that outstanding Perl CGI programmers
are able to command 100 usd+ rates. YMMV, but that is what I
see.
And I probably should raise my rate because I am too busy. 8-)
--
Mike Heins http://www.minivend.com/ ___
Internet Robotics |_ _|____
There ain't nothin' in this world 131 Willow Lane, Floor 2 | || _ \
that's worth being a snot over. Oxford, OH 45056 | || |_) |
--Larry Wall <mikeh@minivend.com> |___| _ <
513.523.7621 FAX 7501 |_| \_\
------------------------------
Date: Fri, 27 Mar 1998 02:02:21 GMT
From: kucera@mindsrping.com ( Mark Kucera)
Subject: Re: help with Hardware ethernet addresses please
Message-Id: <351b080d.830404@news.mindspring.com>
On Thu, 26 Mar 1998 03:07:09 GMT, jgloudon@manitoba.bbn.com (Jason
Gloudon) wrote:
>Mark Kucera <kucera@mindsrping.com> wrote:
>>is there a perl utility or function that can retrieve a remote
>>ethernet address accros a network/ the internet??
>
>Ethernet Adress of what ?
>A machine you have the hostname for on the other side of the room / world ?
>
>The first is doable, the second is not.
>
>You should take your question to a networking related newsgroup,
>as your question shows that you don't understand what you expect
>from this utility.
>
>--
>Jason Gloudon
Actually i do know what i want from this application. i am looking for
some sort of utility/function, like ping that will "ping a host, from
its hostname" and query the ethernet of that computer. . this
program would be used across campus at a college/university for
several buildings. they are all connected to a subnetwork, which
connects them to the internet...
is this possible?
mk
------------------------------
Date: Thu, 26 Mar 1998 14:33:35 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: help with Hardware ethernet addresses please
Message-Id: <slrn6hkpnc.o6r.jgloudon@manitoba.bbn.com>
Mark Kucera <kucera@mindsrping.com> wrote:
>On Thu, 26 Mar 1998 03:07:09 GMT, jgloudon@manitoba.bbn.com (Jason
>Gloudon) wrote:
>Actually i do know what i want from this application. i am looking for
>some sort of utility/function, like ping that will "ping a host, from
>its hostname" and query the ethernet of that computer. . this
>program would be used across campus at a college/university for
>several buildings. they are all connected to a subnetwork, which
>connects them to the internet...
You should try doing a search on the web for "arp and perl".
The first hit on www.lycos.com is a tool that does exactly this.
You could have saved yourself a day by doing this on your own.
--
Jason Gloudon
------------------------------
Date: Thu, 26 Mar 1998 09:47:55 -0500
From: "Doug Browne" <dbrowne@indiana.edu>
Subject: Re: help with Hardware ethernet addresses please
Message-Id: <6fdq86$vim$1@flotsam.uits.indiana.edu>
>Mark Kucera <kucera@mindsrping.com> wrote:
>>On Thu, 26 Mar 1998 03:07:09 GMT, jgloudon@manitoba.bbn.com (Jason
>>Gloudon) wrote:
>>Actually i do know what i want from this application. i am looking for
>>some sort of utility/function, like ping that will "ping a host, from
>>its hostname" and query the ethernet of that computer. . this
>>program would be used across campus at a college/university for
>>several buildings. they are all connected to a subnetwork, which
>>connects them to the internet...
>
If they're NT machines, you can do it rather simply with a `getmac` command
and format, print, etc with perl.
Doug Browne
NT/Info Systems Guy
Indiana University
dbrowne@indiana.edu
------------------------------
Date: Thu, 26 Mar 1998 14:23:31 +0100
From: Amar Subramanian <amar@iss-gmbh.de>
Subject: Re: Need sorting routine in Perl
Message-Id: <351A56D3.4B1B@iss-gmbh.de>
Gabor wrote:
>
> In comp.lang.perl.misc, Didiek <didiek@intouch.co.id> wrote :
> # Hi,
> #
> # Does anyone know how or where can I get a sample perl script for sorting
> # numbers. I plan to build a link list and display them in a top referrer
> # order basis. Just like top50 or top100 or whatever.
>
> What's wrong with the built in 'sort'?
>
i don't think there is an opportunity to use sort with a linked list, or
is there any ? if ther is one please let me know.
regards amar
------------------------------
Date: Thu, 26 Mar 1998 09:16:41 -0500
From: John Porter <jdporter@min.net>
To: Didiek <didiek@intouch.co.id>
Subject: Re: Need sorting routine in Perl
Message-Id: <351A6349.5D56@min.net>
Didiek wrote:
>
> Does anyone know how or where can I get a sample perl script for sorting
> numbers. I plan to build a link list and display them in a top referrer
> order basis. Just like top50 or top100 or whatever.
Get and read "Learning Perl", by Randal Schwartz.
And visit www.perl.com.
John Porter
------------------------------
Date: Thu, 26 Mar 1998 14:35:14 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: Need sorting routine in Perl
Message-Id: <slrn6hkpqg.o6r.jgloudon@manitoba.bbn.com>
Didiek <didiek@intouch.co.id> wrote:
>Hi,
>
>Does anyone know how or where can I get a sample perl script for sorting
>numbers. I plan to build a link list and display them in a top referrer
>order basis. Just like top50 or top100 or whatever.
Why don't you look around on the web ?
http://www.perl.com/CPAN-local/doc/FMTEYEWTK/sort.html.
--
Jason Gloudon
------------------------------
Date: Thu, 26 Mar 1998 09:45:54 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Need sorting routine in Perl
Message-Id: <351A6A22.3D6F@min.net>
Amar Subramanian wrote:
>
> Gabor wrote:
> >
> > In comp.lang.perl.misc, Didiek <didiek@intouch.co.id> wrote :
> > #
> > # Does anyone know how or where can I get a sample perl script for sorting
> > # numbers. I plan to build a link list and display them in a top referrer
> > # order basis. Just like top50 or top100 or whatever.
> >
> > What's wrong with the built in 'sort'?
> >
> i don't think there is an opportunity to use sort with a linked list, or
> is there any ? if ther is one please let me know.
What's this linked list you speak of?
They should be storing their data in an array or hash; and either case
the intrinsic 'sort' will do the job.
If they insist on cobbling up some linked list package, then the sort
routine is very specific to the implementation, and should be part of
it.
John Porter
------------------------------
Date: Thu, 26 Mar 1998 07:37:37 -0800
From: "Mike Glenn" <mglenn@no.spam.zbzoom.net>
Subject: Re: noetebook /perl-cgi module ???
Message-Id: <6fdm7q$otc$1@news0-alterdial.uu.net>
This is a multi-part message in MIME format.
------=_NextPart_000_0068_01BD588A.0CC4FF10
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
What exactly do yo mean by Notebook-like. I have a script that takes =
input from a text box on a form and puts a time stamp on it then creates =
a time ordered list of theses entrys on a web page, latest being first =
and working down. I use it for doing news updates, on the latest =
happenings for a project I work on. It lets me write just the update, =
and not have to worry about formating the update into the html doc.
If you would like a copy just let me know...
Mike Glenn
mglenn@zbzoom.net
Gabor.V.Gulyas wrote in message <351A02CC.D8C9D75F@robiomat.com>...
Hello ,=20
I'm looking for some "Note-book"-like solutions using perl/cgi =
modules.=20
Are there any similar things in the Perl-World ???=20
thank you every infos,=20
Gabor=20
=20
--=20
#########################################################################=
###=20
# Gabor V. Gulyas | RoBioMat | P-TEAM =
#
# actual localization: via Matteotti, 10 |25034.ORZINUOVI(BS) | ITALY =
#
# p/f :(Italy)-30-941264 | mail : gabor@robiomat.com =
|cheops@robiomat.com #
# =
-------------------------------------------------------------------------=
#
# We use 100% pure Linux/UNIX systems =
#
# LINUX =3D=3D FREEDOM ! FREEDOM =3D=3D POWER ! =
#
#########################################################################=
###
=20
------=_NextPart_000_0068_01BD588A.0CC4FF10
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>
<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.72.2106.6"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT color=3D#000000 face=3DArial size=3D2>What exactly do yo mean =
by=20
Notebook-like. I have a script that takes input from a text box on a =
form and=20
puts a time stamp on it then creates a time ordered list of theses =
entrys on a=20
web page, latest being first and working down. I use it for doing news =
updates,=20
on the latest happenings for a project I work on. It lets me write just =
the=20
update, and not have to worry about formating the update into the html=20
doc.</FONT></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>If you would like a copy just let me=20
know...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Mike Glenn</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><A=20
href=3D"mailto:mglenn@zbzoom.net">mglenn@zbzoom.net</A></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 solid 2px; MARGIN-LEFT: 5px; PADDING-LEFT: =
5px">
<DIV>Gabor.V.Gulyas<CHEOPS@ROBIOMAT.COM> wrote in message <<A=20
=
href=3D"mailto:351A02CC.D8C9D75F@robiomat.com">351A02CC.D8C9D75F@robiomat=
.com</A>>...</DIV>Hello=20
,=20
<P>I'm looking for some "Note-book"-like solutions =
using=20
perl/cgi modules. <BR>Are there any similar things in the Perl-World =
???=20
<P> thank you every infos,=20
=
<BR> &nb=
sp; &nbs=
p;  =
; =
=20
Gabor <BR> <PRE>--
#########################################################################=
###
# Gabor V. Gulyas | RoBioMat | =
P-TEAM &=
nbsp; &n=
bsp; #
# actual localization: via Matteotti, 10 |25034.ORZINUOVI(BS) | =
ITALY #
# p/f :(Italy)-30-941264 | mail : gabor@robiomat.com =
|cheops@robiomat.com #
# =
-------------------------------------------------------------------------=
#
# =
We use 100% pure =
Linux/UNIX =
systems =
#
# =
LINUX =3D=3D FREEDOM ! =
FREEDOM =3D=3D POWER =
! =
#
#########################################################################=
###</PRE> =20
</BLOCKQUOTE></BODY></HTML>
------=_NextPart_000_0068_01BD588A.0CC4FF10--
------------------------------
Date: Thu, 26 Mar 1998 08:54:53 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Perl Databases...
Message-Id: <351A5E2D.69A5@min.net>
Andrew F. Lee wrote:
>
> > Bill Lewis <Bill.Lewis@mci.com> wrote:
> >
> > > Then in the script I assign keys and values like such:
> > >
> > > %info = $key => $value;
> >
> > $info{$key} = $value;
> >
>
> %info = ($key => $value);
>
> maybe it was a typo ....
Maybe, but it's still wrong. With that assignment,
%info will never have more than one key.
John Porter
------------------------------
Date: Thu, 26 Mar 1998 14:58:32 +0100
From: lassehp@imv.aau.dk (Lasse =?ISO-8859-1?Q?Hiller=F8e?= Petersen)
Subject: Re: Problems with handling Mac/PC/Unix line breaks
Message-Id: <lassehp-2603981458320001@ra.imv.aau.dk>
In article <rmcassid-2503981450450001@dante.eng.uci.edu>, rmcassid@uci.edu
(Robert Cassidy) wrote:
>Fairly newbie using MacPerl, but will likely have to deal with it on unix
>as well.
>
>I'm trying to figure out how to deal with files that have, without prior
>knowledge, Mac/DOS/unix line breaks. The problem is that some of the files
>I deal with run into the tens and hundreds of megabytes so just grabbing
>the whole file and looking for \n or \r is a wee bit impractical. I can
>make some safe assumptions about how many characters before a break should
>occur, though.
I can think of two ways. BTW, when dealing with cross-platform files, do
so in the right, cross-platform way: be specific and use \012 and \015 for
LF and CR. With MacPerl "\n" is "\015" for good reasons!
1. Use read to read a good measure (more than one line) of data from the
file, and look for presence of "\012", "\015" or "\015\012" to identify
the origin (Unix, Mac or DOS) of the file, then set $/ accordingly, rewind
the file and read on.
2. Use read to read the whole file block by block (decide a suitable block
size) and use split/\015\012?|\012/ to split at Mac/DOS linebreaks or Unix
linebreaks, concatenating the last item of the split with the next block
read, before splitting.
If $/ could be set to a regexp, the last one would be easier and
cleaner-looking, but unfortunately it can't. (And frankly I can't see any
reason why Perl should be inferior to awk in this regard! Each time I see
that comment in the perlvar page, I get slightly annoyed.)
Here's a test example to inspire you:
perl -e 'print "Line1\012Line2\012"' >unixfile
perl -e 'print "Line1\015Line2"' > macfile
perl -e 'print "Line1\015\012Line2"' > dosfile
perl -e '$/ = ""; $_ = <>; @lines = split/\015\012?|\012/;' \
-e 'print map{ $i++; "Line $i: $_\n"; } @lines;' < macfile
(That's a 113 character one-liner on my 132 columns terminal window!)
I'm sure that if there's anything wrong with this approach, the real Perl
wizards (of which I do not consider myself one) will rush in and tell us.
-Lasse
TMTOWTDI, but there are more ways to do it wrong than to do it right.
------------------------------
Date: Thu, 26 Mar 1998 07:42:27 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Problems with handling Mac/PC/Unix line breaks
Message-Id: <pudge-2603980742280001@ppp-48.ts-1.kin.idt.net>
In article <rmcassid-2503981450450001@dante.eng.uci.edu>, rmcassid@uci.edu
(Robert Cassidy) wrote:
# Fairly newbie using MacPerl, but will likely have to deal with it on unix
# as well.
#
# I'm trying to figure out how to deal with files that have, without prior
# knowledge, Mac/DOS/unix line breaks. The problem is that some of the files
# I deal with run into the tens and hundreds of megabytes so just grabbing
# the whole file and looking for \n or \r is a wee bit impractical. I can
# make some safe assumptions about how many characters before a break should
# occur, though.
You SHOULD be safe by simply looking for the first occurence of
(?:\015?\012?). Maybe if you don't find that after a certain amount of
bytes, then you can fail. If $1 eq "\015\012", it's Windows, if "\012",
it's Unix, if "\015", it's Mac.
Yes, you should use \015 and \012, not \r and \n, as the values
represented by \r and \n differ across platform. You may only use this
program on one platform, but it is a good habit to get into: use \n only
to mean "the local newline for this machine". For networking code or
specific newlines for a given platform, use the octal or decimal or hex
notation.
--
Chris Nandor pudge@pobox.com http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10 1FF7 7F13 8180 B6B6'])
#== MacPerl: Power and Ease ==#
#== Publishing Date: Early 1998. http://www.ptf.com/macperl/ ==#
------------------------------
Date: Thu, 26 Mar 1998 14:53:18 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Problems with handling Mac/PC/Unix line breaks
Message-Id: <EqFLCu.7wC@world.std.com>
rmcassid@uci.edu (Robert Cassidy) writes:
>I can
>make some safe assumptions about how many characters before a break should
>occur, though.
If you are going to assume that the line breaks before a certain
number of characters, you might as well use stat() to determine the
desired block size for the filesystem the file is on and read that
amount. Since hitting the disk is going to involve the largest amount
of overhead, and since reading 200 bytes and reading a full block will
probably take about the same amount of time, why not have 16K or 32K,
whatever the OS wants to give you.
--
Andrew Langmead
------------------------------
Date: 26 Mar 1998 13:35:21 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: PROPOSAL: The Perl Dictionary
Message-Id: <eli$9803260824@qz.little-neck.ny.us>
Lasse =?ISO-8859-1?Q?Hiller=F8e?= Petersen <lassehp@imv.aau.dk> wrote:
> In article <eli$9803251350@qz.little-neck.ny.us>, Eli the Bearded
> <*@qz.to> wrote:
> >perl -e 's ssqqprint qq\0just another new york perl hacker\n\0see'
> Bareword found where operator expected at -e line 1, near "s ssqqprint qq\0just"
...
> It seems perl is being perlturbed by your perlformance.
No, I think something *else* was perlturbed by the embedded backspaces
in that. The following two lines are identical in my editor, but one is
two bytes longer than the other.
perl -we 's ssqqprint qq\0just another new york perl hacker\n\0see'
perl -we 's ssqq^Hprint qq\0just another new york perl hacker\n\0^Hsee'
Both Randal and Chip seemed perlturbed to learn that <s>, <BS>, and <NUL>
are perfectly good delimiter characters.
Elijah
------
would have bare nulls in this if he thought newsservers could cope
------------------------------
Date: Thu, 26 Mar 1998 08:53:37 -0500
From: John Porter <jdporter@min.net>
Subject: Re: regular expression
Message-Id: <351A5DE1.76EC@min.net>
Craig Berry wrote:
>
> 8($J$Z6!*:2VE]$} (NortonNg.bbs@CHS.Dorm10.NCTU.edu.tw) wrote:
> : just a simple question: how can I write a perl script to identify
> : all strings of 0's and 1's that do not contain the substring 011 ?
Hope the kid gets an A for your work.
John Porter
------------------------------
Date: Thu, 26 Mar 1998 14:27:07 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Unlink on WinNT/95
Message-Id: <EqFK57.BHy@world.std.com>
scott@softbase.com writes:
>>While (-f counter.lock) {
>This is baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaad news. Suppose instance A
>starts, locks the file, and there's a power failure. Your machine
>reboots, but the lock file is there. Then programs B, C, D, E, ....
>all block on this while loop and spin their wheels forever. All locks
>should have a reasonable wait period in them after which they give up
>and delete the lock file.
That isn't the least of the problems. Also since the testing of the
lock and getting the lock are two separate operations, two processes
can both think they have they lock. If you can test and create in one
system call, and if file creation is an atomic operation (probably
true on a local filesystem on Windows 95, it isn't on NFS
filesystems.) then you can try to create the file, and if you do so
successfully, then you have the lock.
Also, for the problem of stale locks, what many versions of UUCP do is
insert the PID of the processes owning the lock in the lock file
itself. When a process finds the lock file, it can then read the PID
of the owner, and check if the owner still exists. You still have the
potential for a process being locked out of an available
resource. (what if one process tries to get the lock and dies without
releasing it. Then sometime later a long running process starts with
the same PID as the crashed process, but has no need for the locked
resource. Later if someone is looking for access to the lock, it will
see the process that re-used the originial PID, and think it was the
owner.)
And this reminds me of a project that I keep thinking about, but never
have time to research and implement. I wonder if it would be of some
use to mimic flock() under Win95 with named semaphores. Nothing other
than other perl scripts would honor the locking scheme, but that
doesn't make it much different than Unix advisory locks (in that you
need all processes to lock for it to work.)
--
Andrew Langmead
------------------------------
Date: Thu, 26 Mar 1998 09:41:18 -0500
From: John Porter <jdporter@min.net>
Subject: Re: verifying email address -- how?
Message-Id: <351A690E.7AF9@min.net>
Yash Khemani wrote:
>
> could you provide a suggestion about how to verify the validity of
> an email address?
A. Don't bother trying.
> - could the address provided be valid? by this, i mean - is this a
> syntactically valid address?
Impossible.
> - is the address provided actually valid? this means connecting to
> the mail server on port 25 and using the VRFY command. the problem
> here, however, is that this is not always possible. you have to
> end up looking at mx records and it all gets very ugly.
Yes, frequently not possible, and unreliable in the extreme, as a
solution.
The only thing that comes close to a reasonable solution -- and
which is not useful in many cases -- is to send a message to
the address asking for a reply, and see if you ever get one.
John Porter
------------------------------
Date: 26 Mar 1998 11:52:45 GMT
From: ian@caliban.org (Ian Macdonald)
Subject: Re: || and 'or' - implications?
Message-Id: <slrn6hkgcd.3j4.ian@caliban.xs4all.nl>
On Thu, 26 Mar 1998 00:54:36 -0500, Ronald J Kimball
<rjk@coos.dartmouth.edu> wrote:
>Ian Macdonald wrote:
>>
>> Can someone explain to me in lucid terms what the implications are of
>> using the symbolic and literal forms [of the logical operators]?
>> If I develop good practice now, I won't have to unlearn bad habits later.
>
>The only difference between the symbolic (&&, ||) and literal (and, or)
>operators, aside from readability, is precedence. && and || have high
>precedence, and and or have low precedence.
Thanks for the prompt responses and clear explanations, guys. I
understand this a lot better now.
Ian
--
Ian Macdonald | Don't give in to spammers.
http://www.caliban.org/ | Use your real e-mail address
PGP key available from public servers | on Usenet.
Linux 2.0.33 on an i686 |
------------------------------
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 2186
**************************************