[9138] in Perl-Users-Digest
Perl-Users Digest, Issue: 2756 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 28 23:07:22 1998
Date: Thu, 28 May 98 20:00:27 -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, 28 May 1998 Volume: 8 Number: 2756
Today's topics:
Re: "ref($proto) || $proto" considered harmful (was Re: <zenin@bawdycaste.org>
[Q] Platform independant way of writing hash to disk? (Thaths)
Certified Webmasters (Pat Tompkins)
Re: Changing users passwords <rootbeer@teleport.com>
Re: Clearly define "free software" <dformosa@st.nepean.uws.edu.au>
Re: Clearly define "free software" (Thomas Bushnell, n/BSG)
Copylefting manuals <rms@gnu.org>
Re: Copylefting manuals <tchrist@mox.perl.com>
Deleting Variables (Keith)
Re: Deleting Variables <rootbeer@teleport.com>
Re: Don't Know how to decrypt using PERL <lr@hpl.hp.com>
Have we got a good free Perl manual? <rms@gnu.org>
HELP!!!!!! <Rafkin@Hotmail.com>
Re: HELP!!!!!! <rootbeer@teleport.com>
Re: Help: Delete a file with Perl Script in WinNT <lance@nospam.net-school.com>
Re: open () and named pipes <rootbeer@teleport.com>
Re: perl monger tshirt??? <che@debian.org>
Problem Getting Shared Libs to work (Apha OSF1 V4.0) Bobd@my-dejanews.com
Re: read and write <zenin@bawdycaste.org>
Re: read and write <zenin@bawdycaste.org>
Re: Reading whole file into a scalar <merlyn@stonehenge.com>
Re: Reading whole file into a scalar (Martien Verbruggen)
Re: RegEx for breaking up HTML <merlyn@stonehenge.com>
Re: RegEx for breaking up HTML (Martien Verbruggen)
Re: Statistics for comp.lang.perl.misc <tchrist@mox.perl.com>
Re: unpack troubles <rootbeer@teleport.com>
Re: Using Perl to configure router <rootbeer@teleport.com>
Re: Visibility of "my" vars <metcher@spider.herston.uq.edu.au>
Re: Visibility of "my" vars <tchrist@mox.perl.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 29 May 1998 00:39:41 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: "ref($proto) || $proto" considered harmful (was Re: OO - explicit package name required)
Message-Id: <896402814.511928@thrush.omix.com>
[posted & mailed]
Tom Christiansen <tchrist@mox.perl.com> wrote:
: Anyway, one should call constructors "gimme", not "new".
my $toy = $yourtoy->gimme();
Hmm, doesn't read as well to me, because it "sounds" like I'm
taking your toy, but I'm not.
I like summon() myself.
my $daemon = Daemon->summon (From => 'hell');
I'd just hate to see the stack trace if anything went wrong.
--
-Zenin
zenin@archive.rhps.org
------------------------------
Date: 29 May 1998 01:42:28 GMT
From: thaths@netscape.remove_this.com (Thaths)
Subject: [Q] Platform independant way of writing hash to disk?
Message-Id: <6kl3q4$a3j1@continuity.mcom.com>
Is there a platform independant way of writing a hash to disk? I have been
having problems reading a hash on Linux from a file created on Solaris. I
use DB_File and tie to read / write the hash.
S.
--
"Revolution, n.: In politics, an abrupt change in the form of
misgovernment." -- Devils Dictionary
Sudhakar C13n http://people.netscape.com/thaths/ Indentured Slave
------------------------------
Date: Fri, 29 May 1998 00:50:31 GMT
From: ptompkins@iname.com (Pat Tompkins)
Subject: Certified Webmasters
Message-Id: <356e064a.206271118@news.firstcity.net>
I am not sure if this is the correct venue to ask this question, but I
am not sure if there is a correct venue for any question...
That blathering aside. My boss just came back from a convention and he
was told about an association which is supposed to "certify" web page
designers. He said that if a "certified webmaster", program existed
for the internet, the company would pay for this certification and he
could begin to request a for my pay raise. So you can see my interest
in getting this project moving.
If a certification process exists, I believe it would be good for all.
No more fly-by-night web site companies popping up out of no where,
with inexperienced highschool grads working for minimum wage. And I
think it would lend an air of professionalism to this otherwise
understood occupation.
Finally, an end to the blathering...
Thanks in advance for your indulgence.
/***************************
Tompkins ptompkins@iname.com
***************************/
------------------------------
Date: Fri, 29 May 1998 02:19:18 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Changing users passwords
Message-Id: <Pine.GSO.3.96.980528191727.3419C-100000@user2.teleport.com>
On Thu, 28 May 1998, Devendra Mehta wrote:
> does someone know how i can change the password on a user
Yes; you change the entry for the user's password in some file or
database. There may be a system call provided to do this.
> the file with the username and password is just a text file using the
> following style.
> username:password
Sounds as if you just need to edit the line in the text file, then. The
FAQ has information about doing that. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 28 May 1998 23:21:28 GMT
From: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: Clearly define "free software"
Message-Id: <896397683.374455@cabal>
In <pudge-2805980757190001@dynamic265.ply.adelphia.net> pudge@pobox.com (Chris Nandor) writes:
>In article <896312938.451699@cabal>, ? the platypus {aka David Formosa}
><dformosa@st.nepean.uws.edu.au> wrote:
[...]
># Then what about alogrithums? Where dose a mathimatical alogrythum become
># a program?
[...]
>Even if it simply calculated and did nothing else, you would still have
>lots in the guts of the program that are not strictly mathematical
>constructs (by the time it is compiled and executed), unless you want to
>define "mathematical constructs" loosely enough to include every string of
>0s and 1s on a computer, no matter what its purpose.
It is my view that mathmatics is far brouder then just arthmatic. I would
argue that,
sort {$a <=> $b} @rray;
is a mathmatical construct, as sorting is in its essence mathmatical.
--
I'm a perl programer; if you need perl programing, hire me.
Please excuse my spelling as I suffer from agraphia; see the url. Support NoCeM
http://www.cit.nepean.uws.edu.au/~dformosa/Spelling.html http://www.cm.org/
I'm sorry but I just don't consider 'because its yucky' a convincing argument
------------------------------
Date: 28 May 1998 22:28:54 -0400
From: tb@mit.edu (Thomas Bushnell, n/BSG)
Subject: Re: Clearly define "free software"
Message-Id: <u1hk9756c9l.fsf@buzzword-bingo.MIT.EDU>
Tom Christiansen <tchrist@mox.perl.com> writes:
> Software must be written for Z=-3 to achieve
> the desired 99.98% market saturation.
But that's only true, of course, if you want massive market
saturation. Bill Gate$ does, so his software is lousy (I think you're
argument here is right on target). But it's also possible to have
more modest goals of saturation, and then be quite satisfied with a
different product.
Thomas
------------------------------
Date: 28 May 1998 22:00:17 -0400
From: Richard Stallman <rms@gnu.org>
Subject: Copylefting manuals
Message-Id: <sd7lnrlzvj0.fsf@mescaline.gnu.org>
[I first tried to post this on Friday May 22 but it did not get through.
Paul Fisher posted it for me on Monday, but there is doubt that it was
noticed, since it did not come from me or gnu.org.]
In the GNU project, we never use the GNU GPL for manuals. The GPL was
designed for programs, and it is complicated in order to deal with the
issues that arise for programs. For manuals, that complexity is not
necessary. We recommend using a much simpler kind of copyleft for GNU
manuals. (Look at the GNU Emacs Manual, for example.)
Tom Christiansen is concerned that copylefting a manual inevitably
means that examples in it can't be copied into non-free programs.
Whether that consequence would be a bad thing is debatable; but people
should know that this is not an *inevitable* consequence of
copylefting a manual.
If you write a manual, and you want to let people copy the examples
you wrote into their own programs without any limitation, that's as
easy as can be. Just say in the manual that this is permitted, and it
is permitted.
There is complete flexibility in doing this. You can be specific, and
make this exception for particular examples, or you can be general and
do it for all the examples you wrote. You cannot, however, do it for
examples that someone else wrote, unless he gave the copyright to you.
How to handle the examples he wrote is up to him.
One other limit on your flexibility is that you can't stop people from
copying small examples no matter what you say. Small quotations from
a book are "fair use"; people don't need special permission for them.
As a result, this issue is moot for most manuals. It arises only if
the manual contains large examples that are general enough to be
useful to copy. Most manuals do not, but perhaps some do.
If you use a simple copyleft for manuals, as the GNU project does,
then an exception is technically needed even to permit copying the
examples into GPL-covered programs. We would definitely make this
exception if there is a need for it. But I don't think the GNU
manuals contain large examples that are general enough to be useful to
copy into programs. If you think you see one, please let me know.
Is it a good idea to permit using large examples in non-free programs
also? This is a complicated question, and I think the answer depends
on the details. Fairness says no; writing non-free programs is
refusing to cooperate with the free software community, so that
activity does not deserve any help from us. On the other hand, in
some limited cases, it can be useful for free software development to
permit such use--as long as we remember that we are treating the
software privateers better than their actions deserve.
------------------------------
Date: 29 May 1998 02:04:18 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Copylefting manuals
Message-Id: <6kl532$mr7$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, rms@gnu.org writes:
:Tom Christiansen is concerned that copylefting a manual inevitably
:means that examples in it can't be copied into non-free programs.
:Whether that consequence would be a bad thing is debatable; but people
:should know that this is not an *inevitable* consequence of
:copylefting a manual.
:
:If you write a manual, and you want to let people copy the examples
:you wrote into their own programs without any limitation, that's as
:easy as can be. Just say in the manual that this is permitted, and it
:is permitted.
Thank you. I shall do so.
--tom
--
X-Windows: Power tools for power losers.
--Jamie Zawinski
------------------------------
Date: Fri, 29 May 1998 02:20:54 GMT
From: barberk3@pilot.msu.edu (Keith)
Subject: Deleting Variables
Message-Id: <356e1a11.42989904@nntp.msu.edu>
If anyone can help me out, I can't seem to figure out how to delete
variables. In my script I open a file:
open(FILE,"+<sell.txt")||die "\n\n\tCould not open file: $!\n\n";
#Look for a match of $class
while (<FILE>){
if (/^$class/){
$flag=1;
($class,$name,$phone,$email,$title,$comments,$then)=split(/:/);
%line=("$class","$name","$phone","$email","$title","$comments","$then");
($month,$day,$year)=split(/\//, $then);
# If it is past a $cut_off date, I want to delete the variables, yet I
# get the error msg "delete argument is not a HASH element..."
if ($day < $cut_off){
delete FILE $class;
delete $line{"$class"};
delete $line{"$name"};
Anyone help a new guy out?
Thanks,
Keith
------------------------------
Date: Fri, 29 May 1998 02:45:37 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Deleting Variables
Message-Id: <Pine.GSO.3.96.980528194306.3419G-100000@user2.teleport.com>
On Fri, 29 May 1998, Keith wrote:
> delete FILE $class;
Are you trying to delete a line in a file? The FAQ has information about
removing lines from the middle of a text file.
Do you wish to delete the data from $class? Just assign anything else to
$class. Or, if you wish for it to be undefined, use undef.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 28 May 1998 17:51:23 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: Don't Know how to decrypt using PERL
Message-Id: <6kl0q8$ejl@hplntx.hpl.hp.com>
Larry Rosler wrote in message <6kko25$btl@hplntx.hpl.hp.com>...
...
>I started a search for C library documentation online (using +ANSI
>+library because C is ignored) and have about 50K references to sort
>through to find one or several useful archives. Perhaps this
>documentation can be gathered and made available on CPAN and
><URL:http://www.perl.com>, so that responders can point to it as
readily
>as they now point to the CGI documentation. At least then they
wouldn't
>have to respond `man 3 crypt` or whatever.
I found three useful references in this search:
C++ Tutorial: Standard Library
http://www.cs.bsu.edu/homepages/peb/cplusplus/ansilib.html
The ANSI-C Support Library
http://www.introl.com/introl-demo/Libraries/C/ANSI_C/contents.html
The GNU C Library - Table of Contents
http://www.ia.pw.edu.pl/Pl-iso/tex-info/libc/libc_toc.html
Can someone follow up by reviewing these references and adding pointers
to them appropriately, or copying them if they are public (as I
suspect)? I can't put any more time into this one.
[But they wouldn't have helped resolve the issue of `man 3 crypt`! I
should have remembered that crypt(3) didn't make it into ANSI C,
probably for the same paranoid reasons discussed here in a recent
thread. But AltaVista +crypt +function gave 7335 references. Maybe all
answers in c.l.p.m. should be "Search the Web"!]
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: 28 May 1998 22:02:52 -0400
From: Richard Stallman <rms@gnu.org>
Subject: Have we got a good free Perl manual?
Message-Id: <sd7k975zvek.fsf@mescaline.gnu.org>
[I first tried to post this on Saturday May 23 but it did not get through.
Paul Fisher posted it for me on Monday, but there is doubt that it was
noticed, since it did not come from me or gnu.org.]
Once upon a time, I thought I would learn Perl. I got a copy of a
free manual, but I found it simply unreadable, and gave up. Perl
users told me that there were better manuals, but they were not free.
Why was this? Their authors had sold the manuals to O'Reilly, instead
of contributing them to the free software community. It wasn't the
first time and (to our community's great loss) it was far from the
last. O'Reilly and other publishers have enticed a great many authors
to withhold their manuals since then. Partly as a result of this,
partly because writing good English is a skill which most good
programmers have not studied, a lack of documentation is one of the
worst deficiencies of free operating systems today.
Perl is an important piece of free software, and it ought to have a
*good* free manual. So I added this item to the GNU task list, hoping
this would encourage someone to write one.
That was a few years ago. If there is now a good free manual, that's
great. I'm always glad to remove an item from the task list because
the job has been done. I might even buy a copy of this manual, if
someone is selling them--especially if it is O'Reilly. (If we buy
O'Reilly manuals only when they are free, we can encourage O'Reilly to
publish and sell more free manuals.)
But before I start celebrating, I ought to verify the facts--in
particular, verify that the manual in question is actually free. The
criterion for free documentation is basically the same as for free
software: users have to be free to redistribute it, with or without
changes, either gratis or for a fee, in any medium.
As a general rule, I don't believe that it is essential for people to
have permission to modify all sorts of articles and books. The issues
for writings are not necessarily the same as those for software. For
example, I don't think you or I are obliged to give permission to
modify articles like this one, which describe our actions and our
views.
But there is a particular reason why the freedom to modify is crucial
for a manual for free software. The most natural use of such a manual
is to distribute it in free operating systems, along with the program
it documents. And when people exercise their right to modify the
software, and add or change its features, if they are conscientious
they will change the manual too--so they can provide accurate and
usable documentation with the modified program. A manual which
forbids people to be conscientious and finish the job, or more
precisely requires them to write a new manual from scratch, does not
do the job.
While a blanket prohibition on modification is unacceptable, some
kinds of limits on modification are ok. For example, requirements to
preserve the original author's copyright notice, the distribution
terms, or the list of authors, are ok. It is also ok to have entire
sections that may not be deleted or changed, as long as these sections
deal with nontechnical topics. (Some GNU manuals have them.) These
restrictions are not a problem because, as a practical matter, they
don't stop the conscientious programmer from adapting the manual to
fit the modified program. In other words, they are ok because they
don't block the free software community from doing its thing with the
program and the manual together.
However, it must be possible to modify all the *technical* content of
the manual; otherwise, the restrictions do block the community, the
manual is not free, and we need another manual.
To be sure, many users find non-free manuals "useful". And they can
indeed be useful, in a purely materialistic sense, just as non-free
software can. What they can't be is part of the free software
community.
I expect that I'll soon know whether Perl now has a good free manual.
I hope that the answer will be yes, and that I'll be able to delete
that item from the GNU task list. If not, I hope that someone will
change the distribution terms on an existing good manual, or write a
new one. O'Reilly is just beginning to contribute to our community;
most of what they do is still non-free, and thus no contribution. If
O'Reilly's Perl manual is still non-free, making it free would be a
fine way to take the next step in actually contributing to free
software.
Copyright 1998 Richard Stallman
Verbatim copying and distribution is permitted in any medium
provided this notice is preserved.
------------------------------
Date: 29 May 1998 02:17:31 GMT
From: "Rafkin" <Rafkin@Hotmail.com>
Subject: HELP!!!!!!
Message-Id: <01bd8aa7$293bd340$5e584dd1@donald>
Hi, I'm a sort of newbie to Perl cgi scripting.. Though i do gather a lot
of how it's done..
One thing I am having problems with is this. The server where i host (or
will host) my cgi's on does not allow telnet access. I have to upload the
cgi to my cgi-bin and then use the ws_ftp chmod command to make it
executable (755)
However, without telnet access, i find it inpossible to debug the scripts
easily, without some sort of list of errors, to point me to the right line
if not part of the line that the error resides on. All i get is an Internal
Error when i try to load the cgi in the browser.
Is there some way, some sort of program that would let me debug the scripts
locally, before i upload them, or maybe even a site on the web somewhere to
help me debug them there??
I need to find some way to find out where my scripts are going bad, so i
can fix them.
please e-mail me at Rafkin@Hotmail.com with help.. thanks..
The site, if this is inportant, is www.fsn.net (they are hosting my site,
SacRing.fsn.net)
Thanks for any help.
------------------------------
Date: Fri, 29 May 1998 02:42:39 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: HELP!!!!!!
Message-Id: <Pine.GSO.3.96.980528194021.3419F-100000@user2.teleport.com>
On 29 May 1998, Rafkin wrote:
> Subject: HELP!!!!!!
Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
> Is there some way, some sort of program that would let me debug the
> scripts locally, before i upload them,
If you write your CGI scripts with a module like CGI.pm, you'll be able to
debug them from the command line without needing either a server or a
browser. You may even use the Perl debugger to step through your code a
line at a time!
Also, when you're having trouble with a CGI program in Perl, you should
first look at the please-don't-be-offended-by-the-name Idiot's Guide to
solving such problems. It's available on CPAN.
http://www.perl.com/CPAN/
http://www.perl.org/CPAN/
http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
http://www.perl.org/CPAN/doc/manual/html/pod/
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 29 May 1998 01:13:19 GMT
From: "Lance Hollman" <lance@nospam.net-school.com>
Subject: Re: Help: Delete a file with Perl Script in WinNT
Message-Id: <01bd8a9e$b46dc300$16f586cd@myname>
PH <thidinh@erols.com> wrote in article
<6kj2co$bu6$1@winter.news.erols.com>...
> Then I use unlink() like this:
>
> unlink $file_remove;
> (or) unlink ($file_remove);
>
or unlink ($file_remove) or die "couldn't unlink $file_remove: $!\n";
Lance
------------------------------
Date: Fri, 29 May 1998 02:32:01 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: open () and named pipes
Message-Id: <Pine.GSO.3.96.980528192046.3419D-100000@user2.teleport.com>
On 28 May 1998, Scott Prater wrote:
> what is the difference between
> open(TMP, "</tmp/file")
> and
> open(TMP, "/tmp/file")?
The second is implicitly opening the file for input, while the first
is more explicit; that's all. ("Parental Warning: Explicit Text" :-)
> Yet, when reading from a named pipe, the first option works, but the
> second one doesn't.
Really? I can't duplicate that behavior on my system. If you can make a
short example program which shows this behavior under a recent version of
perl, use the perlbug program to file a bug report. Thanks!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 28 May 1998 18:30:08 -0700
From: Ben Gertzfield <che@debian.org>
Subject: Re: perl monger tshirt???
Message-Id: <ytt67ipj23j.fsf@gilgamesh.cse.ucsc.edu>
>>>>> "Jim" == Jim Allenspach <jima@MCS.COM> writes:
Jim> "F.Quednau" <quednauf@nortel.co.uk> writes:
>> Are there other Perl shirts?
Jim> There's at least one other: the "Learning Perl" shirts
Jim> from O'Reilly. Unfortunately, I don't think they're
Jim> available anymore, so I'll be keeping mine in a
Jim> climate-controlled environment (i.e., Chicago).
There are also the Programming Perl, Second Edition (erroneously printed
in pink, not blue [or teal, or whatever]) O'Reilly T-shirts that
were given out at USENIX LISA in Chicago back in '96 (is that right?
or was it early '97?).
I don't know if those were given out elsewhere.
--
Brought to you by the letters Z and F and the number 13.
"Johnny! Don't go! It's too dangerous!" "I don't care!" -- MST3K
Debian GNU/Linux -- where do you want to go tomorrow? http://www.debian.org/
I'm on FurryMUCK as Che, and EFNet and YiffNet IRC as Che_Fox.
------------------------------
Date: Fri, 29 May 1998 00:48:00 GMT
From: Bobd@my-dejanews.com
Subject: Problem Getting Shared Libs to work (Apha OSF1 V4.0)
Message-Id: <6kl0k0$vi6$1@nnrp1.dejanews.com>
Someone who knows MakeMaker and XS....
I'm trying to create a perl extension using XS and I'm having difficulty
getting the module I created to load. I keep getting "unresolved symbols"
when I attempt to test it.
I need to know what to set in Makefile.PLs so my lib will have all the links
resolved, and I've tried about everything I can think of.
The problem is that the lib I'm linking to has unresolved links which are in
some shared libs which should be resolved at run time, except I'm
unable to make it happen.
I've checked my LD_LIBRARY_PATH, it contains the libs I'm trying to link...
I've tried to link my module's lib with the required libs at ld time, but I
cannot get LD to resolve the external links.
I really don't want to static link perl to fix this problem, so is
there a way to fix this?
Thanks,
-= bob =-
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 29 May 1998 00:12:59 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: read and write
Message-Id: <896401213.4044@thrush.omix.com>
Martien Verbruggen <mgjv@comdyn.com.au> wrote:
>snip<
: Output is:
: 1 has 1 lines
: 2 has 2 lines
: 3 has 0 lines
: 4 has 2 lines
Send in a perlbug, and/or your system is broken. Your output
should be:
$ perl foo.pl
1 has 1 lines
2 has 1 lines
3 has 0 lines
4 has 1 lines
Same files, same script. Files created as such:
$ echo -n line > 1
$ echo line > 2
$ touch 3
$ echo > 4
: It does indeed seem a bit inconsistent that 3 should return a
: different result from 1.
It doensn't, unless your perl or system are broken.
: The byte sizes of the files, as reported by ls are:
: -rw-r--r-- 1 mgjv staff 5 May 29 08:50 1
: -rw-r--r-- 1 mgjv staff 6 May 29 08:50 2
: -rw-r--r-- 1 mgjv staff 0 May 29 08:56 3
: -rw-r--r-- 1 mgjv staff 2 May 29 08:50 4
Odd way of storing data. What system are you using? Here
is FreeBSD:
$ ls -l [1-4]
-rw-r--r-- 1 byron staff 4 May 28 17:07 1
-rw-r--r-- 1 byron staff 5 May 28 17:07 2
-rw-r--r-- 1 byron staff 0 May 28 17:07 3
-rw-r--r-- 1 byron staff 1 May 28 17:07 4
Here is Solaris/Sparc:
$ perl foo.pl
1 has 1 lines
2 has 1 lines
3 has 0 lines
4 has 1 lines
$ ls -l [1-4]
-rw-r--r-- 1 byron staff 4 May 28 17:12 1
-rw-r--r-- 1 byron staff 5 May 28 17:12 2
-rw-r--r-- 1 byron staff 0 May 28 17:12 3
-rw-r--r-- 1 byron staff 1 May 28 17:12 4
This might be the problem. Your file system requires end of file
markers, but your read(2)/file system isn't smart enough to handle
it correctly. -Read(2) looks like it's returning the EOF marker
as real data, which it isn't and never should be returned when
working with plain files.
Perl still works as documented and expected. If you have no more
data, you're at the end of the file. If you've run out of road,
you're at the edge of the cliff, even if you started at the cliff.
--
-Zenin
zenin@archive.rhps.org
------------------------------
Date: 29 May 1998 00:18:12 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: read and write
Message-Id: <896401525.463770@thrush.omix.com>
Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
>snip<
: It would test true at EOF. It is just that it will not signal EOF on
: the first iteration.
But once again, you're at EOF so to not signal EOF would be an
error.
If you're standing at the edge of a cliff with a blind
fold on and ask someone if it's safe to take a step forward,
you'd hope they say "no" the first time, not the second.
: Zenin wrote
: > There is no such thing as an "empty read()", except of course at
: > EOF. Read() is guaranteed not to pull that kind of cheap trick
: > on you, at least not when talking about normal files. :-)
:
: *This* is an argument. But this limitation of C looks
: counter-intuitive to me when I think Perl.
This isn't a limitation of C, it's a feature. It's a feature
that says if I'm at EOF that the system is not going to lie
about it to laugh at me as I plumet to my death off a 500 foot
cliff.
--
-Zenin
zenin@archive.rhps.org
------------------------------
Date: Fri, 29 May 1998 00:02:51 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Reading whole file into a scalar
Message-Id: <8cvhqq54gq.fsf@gadget.cscaper.com>
>>>>> "Lack" == Lack Mr G M <gml4410@ggr.co.uk> writes:
Lack> { local $/; # So we only undef our view of it, not our callers...
Lack> undef $/;
This is unnecessary. local() and my() vars are automatically undef
when declared.
Lack> $filetext = <FH>;
Lack> }
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 95 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 29 May 1998 00:26:51 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Reading whole file into a scalar
Message-Id: <6kkvcb$3f0$1@comdyn.comdyn.com.au>
In article <6kk2u7$3of$1@nntp1.ba.best.com>,
"Mike Dolan" <mdolan@best.com> writes:
> I want to read the entire contents of a text file into a single scalar so
> that I can apply regular expressions to that scalar. Do you know how to do
> this?
This question has been posted to this newsgroup about 50 odd times
during the last few months. You could have found the answer directly
if you had done a dejanews search. It is also documented:
# perldoc perlvar
/$/
# perldoc perlfaq6
/I'm having trouble matching over more than one line. What's wrong?
or
/I put a regular expression into $/ but it didn't work. What's wrong?
in short:
BLOCK_AROUND_LOCAL:
{
local($/) = undef;
open(FF, $fn) || die "$fn : $!";
$file_contents = <FF>;
close(FF);
}
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Very funny Scotty, now beam down my
Commercial Dynamics Pty. Ltd. | clothes.
NSW, Australia |
------------------------------
Date: Fri, 29 May 1998 00:09:10 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: RegEx for breaking up HTML
Message-Id: <8cra1e5467.fsf@gadget.cscaper.com>
>>>>> "Doran" == Doran L Barton <fozz@mail.xmission.com> writes:
Doran> I need a RegEx that will return a list of HTML elements and non-HTML
Doran> elements in a stream. For example, a file looks like this:
Doran> <H1>Hello</H1>
Doran> <p>My name is <i>Bob</i>.
Doran> I want the RegEx to return the following list:
Doran> ("<H1>", "Hello", "</H1>", "<p>", "My name is ", "<i>", "Bob", "</i>",
Doran> ".")
Doran> And I can't for the life of me figure it out. *screams*
You'll need to pronounce "Regex" as "module", and do the following:
$ perl -MCPAN -eshell
cpan> install HTML::Parser
... wait a few minutes, unless you already have it installed ...
cpan> quit
$ perldoc HTML::Parser
... read what comes out ...
Anything short of that is reinventing a perfectly good wheel. Don't.
You'll most likely get it wrong. I've been programming professionally
for over 20 years, and I know there are parts that *I* would get wrong
on this one.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 95 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 28 May 1998 23:42:04 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: RegEx for breaking up HTML
Message-Id: <6kksoc$34n$3@comdyn.comdyn.com.au>
In article <356DE56D.D8723BEF@mail.xmission.com>,
"Doran L. Barton" <fozz@mail.xmission.com> writes:
> I need a RegEx that will return a list of HTML elements and non-HTML
> elements in a stream. For example, a file looks like this:
>
> <H1>Hello</H1>
> <p>My name is <i>Bob</i>.
>
> I want the RegEx to return the following list:
>
> ("<H1>", "Hello", "</H1>", "<p>", "My name is ", "<i>", "Bob", "</i>",
> ".")
It's not that simple, but you might have a look at HTML::Parser, and
see how that does it. Warning: It will be a bit of a job to figure it
out. You might want to cinsider just using it.
Get it from your local CPAN: http://www.perl.com/CPAN/
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Hi, Dave here, what's the root
Commercial Dynamics Pty. Ltd. | password?
NSW, Australia |
------------------------------
Date: 29 May 1998 00:08:49 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <6kkuah$csv$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, lindahl@pbm.com (Greg Lindahl) writes:
:Have you considered the possibility that Tom's generation of flames
:has to do with the senseless nature of his initial flame,
Read my words, Mr. Greg Lindahl. Either one of two things is true:
The page was written back when only the 1st Camel
and no split-up manpages existed.
The page was written recently when split-up
manpages do exist.
In the first case, the FSF's statement that "the books' authors
are withholding them from our community" is a way to insult Larry,
since his was the only Perl book in existence at the time. Book royalties
are the only remuneration Larry got from Perl. If this is the case,
the FSF's temerity passes beyond the realm of any possible redemption.
In the second case, the page was written in either willful disregard or
surprising ignorance of the 1,000-page free book that already exists,
in which case it is merely an insult to all the rest of us woh worked
on that.
In either case, the FSF has insulted the Perl community and its authors.
They should just come out and say something like "That's old, and we'll
fix it", or "We didn't realize Perl already had a free book".
Have they done that? Have they done anything close to that?
No.
What have you done for the Perl Community lately, Mr. Greg Lindahl?
Since you seem to be so in with the FSF, I have a task for you.
Please go to them and get them to correct the error in their ways.
I can't understand why they continue to insult the Perl community.
I have an abiding suspicion that it was first an accident, and now
they can't swallow their pride.
--tom
--
"C is not a big language, and it's not well served by a big book." (Brian W.
Kernighan and Dennis M. Ritchie, in "The C programming Language", Prentice
Hall 1988)
------------------------------
Date: Fri, 29 May 1998 02:09:20 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: unpack troubles
Message-Id: <Pine.GSO.3.96.980528185352.3419A-100000@user2.teleport.com>
On Fri, 29 May 1998, Ruben I Safir wrote:
[ six screenfuls of mostly data deleted ]
While I commend you for trying to give us everything we might need to help
you to solve your problem, I suspect that nobody wants to wade through all
that text to help you to find it! If you can come up with some code with
just a few statements (or even just one statement) which shows the
anomalous behavior, it's more likely that someone will help you track down
the problem.
> FSting fields that should be 5 bits long are suddenly displaying at the
> end as single char fields? I don't unknow why. It also seems that the
> unpack command is not reacting to \0 quite as it should.
Okay, now we're getting somewhere. Try making a small example program.
Six or eight lines ought to be plenty. Just store some data into a
variable, unpack it with some format, and show that you didn't get what
you expected to get. If you can find a bug in unpack, we'll need a small
example like that in order to get it fixed.
Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 29 May 1998 02:33:49 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Using Perl to configure router
Message-Id: <Pine.GSO.3.96.980528193301.3419E-100000@user2.teleport.com>
On Thu, 28 May 1998, rickr wrote:
> open (ROUTER, "|telnet $host");
You want section 8 of the FAQ, which asks and answers the question, "Can I
use perl to run a telnet or ftp session?" Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 29 May 1998 10:24:31 +1000
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: Visibility of "my" vars
Message-Id: <356E003F.F9D6945C@spider.herston.uq.edu.au>
Tom Christiansen wrote:
>
> [courtesy cc of this posting sent to cited author via email]
>
>
>
> foo();
> foo();
>
> sub foo {
> my $a = 0;
> # sub bar { $a++ }
> {
> local $^W;
> *bar = sub { $a++ };
> }
> print bar(),"\n";
> print bar(),"\n";
> $a = 10;
> print bar(),"\n";
> print bar(),"\n";
> }
>
Just checking that I understand you correctly: bar goes onto the package
symbol table, right? That is, it's not private to foo? To make it
private to foo, you'd have to say:
sub foo {
my $a = 0;
{
my $bar = sub {$a++}
}
print $&bar(), "\n";
#etc
}
yes? And the $a in bar is a package variable, not the lexical declared
in foo.
On another, related topic, perlsub has this:
sub BEGIN {
my $secret_val = 0;
sub gimme_another {
return ++$secret_val;
}
}
Once again, I think that the second occurrence of $secret_val is a
package variable, and different from the first occurence which is a
lexical. What's puzzling me is what use that lexical could have -
unless you had other code within the BEGIN block? Isn't it hidden from
the rest of the file (and the world) by that block? What's the
difference between the example above, and this:
sub gimme_another {
return ++$secret_val;
}
sub BEGIN {
my $secret_val = 0;
}
? I know that declaring gimme_another in the BEGIN block might affect
compilation of the rest of the script, but as far as scoping is
concerned, aren't the two equivalent?
--
Jaime Metcher
------------------------------
Date: 29 May 1998 01:09:27 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Visibility of "my" vars
Message-Id: <6kl1s7$hve$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Jaime Metcher <metcher@spider.herston.uq.edu.au> writes:
:Tom Christiansen wrote:
:symbol table, right? That is, it's not private to foo? To make it
:private to foo, you'd have to say:
:
:sub foo {
: my $a = 0;
: {
: my $bar = sub {$a++}
: }
: print $&bar(), "\n";
: #etc
:}
That's not a named one. You could use local *bar = sub{...}
though.
:yes? And the $a in bar is a package variable, not the lexical declared
:in foo.
Goodness, no!
:On another, related topic, perlsub has this:
:
: sub BEGIN {
: my $secret_val = 0;
: sub gimme_another {
: return ++$secret_val;
: }
: }
:
:Once again, I think that the second occurrence of $secret_val is a
:package variable, and different from the first occurence which is a
:lexical.
No, you're confused.
:? I know that declaring gimme_another in the BEGIN block might affect
:compilation of the rest of the script, but as far as scoping is
:concerned, aren't the two equivalent?
Certainly not.
$c1 = mkcounter(20);
$c2 = mkcounter(77);
printf "next c1: %d\n", $c1->{"next"}->(); # 21
printf "next c2: %d\n", $c2->{"next"}->(); # 78
printf "next c1: %d\n", $c1->{"next"}->(); # 22
printf "last c1: %d\n", $c1->{"last"}->(); # 21
printf "old c2: %d\n", $c2->{"reset"}->(); # 77
sub mkcounter {
my $count = shift;
my $start = $count;
my $bundle = {
"next" => sub { return ++$count },
"last" => sub { return --$count },
"get" => sub { return $count },
"set" => sub { $count = shift },
"bump" => sub { $count += shift },
"reset" => sub { $count = $start },
};
$bundle->{"prev"} = $bundle->{"last"};
return $bundle;
}
--tom
--
"Twisted cleverness is my only skill as a programmer." --Elizabeth Zwicky
------------------------------
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 2756
**************************************