[6659] in Perl-Users-Digest
Perl-Users Digest, Issue: 283 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 11 21:17:26 1997
Date: Fri, 11 Apr 97 18:00:37 -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 Fri, 11 Apr 1997 Volume: 8 Number: 283
Today's topics:
Re: "Bad free()" warning, splitting on variable delimit (Ilya Zakharevich)
Re: "Bad free()" warning, splitting on variable delimit <rra@stanford.edu>
Re: @array as input symbol in <@array> (Tad McClellan)
Re: At-sign cancels backslash? <rra@stanford.edu>
Re: Equivalent perl functions as C <rra@stanford.edu>
Re: handling image files? <rra@stanford.edu>
Re: Is this a bug??? posix_types.ph <rra@stanford.edu>
LISP as the ultimate fractal language (Was: Reply to Ou (Mike Meyer)
Re: LWP - again... <tchrist@mox.perl.com>
Newbie: Why tr/+/ / Instead of s/+/ / ? <jeffo@execpc.com>
Re: Ousterhout and Tcl lost the plot with latest paper (cosc19z5@bayou.uh.edu)
Re: Parsing a file backwards (Tim Gim Yee)
Re: Parsing a file backwards (Tad McClellan)
PERL 5.003 Link? <folmsbee@cjnetworks.com>
Re: Perl regression test weirdness. <scotth@sgi.com>
Re: Perl regression test weirdness. (Walter Roberson)
Reading another line in an input loop? <eladner@goldinc.com>
Re: Reading another line in an input loop? (brian d foy)
Re: repeat pattern in one line (Tad McClellan)
Re: Reply to Ousterhout's reply (was Re: Ousterhout and (Alaric B. Williams)
Re: Reply to Ousterhout's reply (was Re: Ousterhout and (cosc19z5@bayou.uh.edu)
Re: Reply to Ousterhout's reply (was Re: Ousterhout and <johns@cnet.com>
Re: Reply to Ousterhout's reply (was Re: Ousterhout and (Roy Smith)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 11 Apr 1997 22:39:34 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: "Bad free()" warning, splitting on variable delimiters
Message-Id: <5imej6$k9d$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Russ Allbery
<rra@stanford.edu>],
who wrote in article <qumiv1tjmlt.fsf@cyclone.stanford.edu>:
> > However, I'm still curious as to why the error only appeared in
> > the case where I split on the variable delimiters. I'd expect to get an
> > error ALL the time!
>
> Bad free() errors are not Perl code errors, and while changing your code
> may make them go away, that's only a workaround. They're caused by
> problems with the malloc() that Perl is using. If you have the ability to
> recompile Perl, try compiling it to use your system malloc() if it's
> currently using Perl's malloc(), and Perl's malloc() if it's currently
> using the system malloc().
Quite the contrary. They are problems in C code (most probably external
libraries, like DB) which are unravelled by perl malloc, and remain
unnoticed by the system malloc.
It is because of the system malloc being so lousy that these problems
in external libraries remain unnoticed - until somebody tries to use
these libraries with Perl.
Ilya
------------------------------
Date: 11 Apr 1997 15:57:02 -0700
From: Russ Allbery <rra@stanford.edu>
To: Ilya Zakharevich <ilya@math.ohio-state.edu>
Subject: Re: "Bad free()" warning, splitting on variable delimiters
Message-Id: <qumsp0xi2wx.fsf@cyclone.stanford.edu>
[ Posted and mailed. ]
Ilya Zakharevich <ilya@math.ohio-state.edu> writes:
> Russ Allbery <rra@stanford.edu> wrote:
>> Bad free() errors are not Perl code errors, and while changing your
>> code may make them go away, that's only a workaround. They're caused
>> by problems with the malloc() that Perl is using. If you have the
>> ability to recompile Perl, try compiling it to use your system malloc()
>> if it's currently using Perl's malloc(), and Perl's malloc() if it's
>> currently using the system malloc().
> Quite the contrary. They are problems in C code (most probably external
> libraries, like DB) which are unravelled by perl malloc, and remain
> unnoticed by the system malloc.
I would call that a "problem with" malloc, although it's not a "problem
caused by" malloc. :) Besides, if something detects a bug you can't fix,
is it a feature or a bug?
--
Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: Fri, 11 Apr 1997 16:38:33 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: @array as input symbol in <@array>
Message-Id: <p0bmi5.dof.ln@localhost>
Laurel Shimer (autopen@quake.net) wrote:
: Well I'm fully willing to be one of those 'clueless idiots' you refer to
: in your next message, but I can't find any reference in my Camel book
: index to (<*.c>) . What is that? Can you give me something to look up? I
^^^^^^^^^^^^^^^^^^^^
glob()
: looked all through the parenthesis section....
: In article <5i5tg7$81t@picasso.op.net>, mjd@plover.com (Mark-Jason
: Dominus) wrote:
: > Someone recently sent me a code sample that included
: >
: > while (<@array>) {
: > print $_, "\n";
: > }
: >
: > and when I saw it, I said, ``Well, no wonder your program doesn't
: > work; you can't treat an array like a filehandle.'' But then I tried
: > it and it *did* work.
: >
: > So I wondered how I could have missed this feature in my extensive and
: > dilligent perusal of the manual, and I went back to chack, and I
: > couldn't find it in the manual this time either. I have the manual
: > that came with 5.003_22, and the blue camel book, and I couldn't find
: > it in either place.
: >
: > Yes, I know about while (<*.c>) ..., but this isn't like that either.
: > It's something else.
: >
: > What I want to know is: *Is* this in the manual? If so, where is it?
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 11 Apr 1997 16:36:01 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: At-sign cancels backslash?
Message-Id: <qumlo6pi13y.fsf@cyclone.stanford.edu>
David Winfrey [munged address] writes:
> "Bother" isn't really the right word; I just wondered if @ had some
> magic meaning in that context.
@ does have a magic meaning in double-quoted strings, namely as the start
of an array variable. I'd recommend always escaping it with a backslash
in double-quoted strings unless that's the meaning you intend.
--
Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: 11 Apr 1997 16:50:26 -0700
From: Russ Allbery <rra@stanford.edu>
To: jason.kruse@teldta.com
Subject: Re: Equivalent perl functions as C
Message-Id: <qumiv1ti0fx.fsf@cyclone.stanford.edu>
[ Posted and mailed. ]
jason kruse <jason.kruse@teldta.com> writes:
> I create two sockets, a and b, bind them to two different ports, and set
> them into a list, incomming, using FD_SET(). I use this list to
> select() on them. If a is set, I set the resulting socket from the
> accept() into the incomming set. If b, I add it into a separate set,
> outgoing, for sockets which are listening.
> I like the structure of FD_* and select in C (You just get used to these
> things I guess) and was wondering if there were an easy way to get this
> kind of interface into perl or if it already exists.
Did you check man perlfunc under select? It works very close to the same
way in Perl as it does in C:
select RBITS,WBITS,EBITS,TIMEOUT
This calls the select(2) system call with the bit masks
specified, which can be constructed using fileno() and vec(),
along these lines:
$rin = $win = $ein = '';
vec($rin,fileno(STDIN),1) = 1;
vec($win,fileno(STDOUT),1) = 1;
$ein = $rin | $win;
If you want to select on many filehandles you might wish to
write a subroutine:
sub fhbits {
local(@fhlist) = split(' ',$_[0]);
local($bits);
for (@fhlist) {
vec($bits,fileno($_),1) = 1;
}
$bits;
}
$rin = fhbits('STDIN TTY SOCK');
The usual idiom is:
($nfound,$timeleft) =
select($rout=$rin, $wout=$win, $eout=$ein, $timeout);
or to block until something becomes ready just do this
$nfound = select($rout=$rin, $wout=$win, $eout=$ein, undef);
Most systems do not bother to return anything useful in
$timeleft, so calling select() in a scalar context just
returns $nfound.
Any of the bit masks can also be undef. The timeout, if
specified, is in seconds, which may be fractional. Note: not
all implementations are capable of returning the $timeleft. If
not, they always return $timeleft equal to the supplied
$timeout.
You can effect a sleep of 250 milliseconds this way:
select(undef, undef, undef, 0.25);
WARNING: Do not attempt to mix buffered I/O (like read() or
<FH>) with select(). You have to use sysread() instead.
> A second problem I seem to be having is the way that accept is used in
> perl. What should you pass to it as the newsocket? If you attempt to
> reuse the call a second time while the first is connected you get an
> error.
Create a new file handle each time with:
$fh = new FileHandle;
That's probably the easiest way. (You may want to use IO::Handle instead
if you want to be 5.004ish.) There are examples of select and accept in
the perlipc man page.
--
Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: 11 Apr 1997 17:30:29 -0700
From: Russ Allbery <rra@stanford.edu>
To: "ian hothersall" <ian@orangenet.co.uk>
Subject: Re: handling image files?
Message-Id: <qum912phyl6.fsf@cyclone.stanford.edu>
[ Posted and mailed. ]
ian hothersall <ian@orangenet.co.uk> writes:
> I've just written my first perl script - a page counter that out-puts
> HTML. However I have noticed that other page counters are called from
> within an HTML page using <img src="cgi-bin/counter.pl>. Presumably
> these scripts read-in and write-out gif files. How is this done? Can I
> download any examples?
Since this a Perl newsgroup, I presume you want an answer dealing with the
Perl language. That answer is that Perl has no difficulty reading and
printing out binary files, so you read a GIF file and print it out in Perl
precisely the same way you would read in and print out a text file.
If you want information on how to do this in a CGI script, you've posted
to the wrong newsgroup. Try comp.infosystems.www.authoring.cgi, since the
answer will be the same regardless of what language you use and is not
related to Perl.
Also, have you tried checking Yahoo for counter scripts, downloading one
of the literally hundreds that are already out there, and seeing how it
works?
--
Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: 11 Apr 1997 17:19:47 -0700
From: Russ Allbery <rra@stanford.edu>
To: klaus@klaus.privat.de (Klaus Mueller)
Subject: Re: Is this a bug??? posix_types.ph
Message-Id: <qumenchhz30.fsf@cyclone.stanford.edu>
[ Posted and mailed. ]
In comp.lang.perl.misc, Klaus Mueller <klaus@klaus.privat.de> writes:
> I use Perl 5.003 with a Linux system. There is a problem with the
> posix_types.ph file. This file contains original the following line:
> eval 'sub NULL {(( &void *) 0);}';
You don't need this line at all unless you intend to use NULL in your Perl
program (and there isn't much point in that). If you really want to fix
it, just make it:
eval 'sub NULL {0;}';
h2ph is an inexact process at best.
--
Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: Fri, 11 Apr 1997 13:47:35 PST
From: bouncenews@contessa.phone.net (Mike Meyer)
Subject: LISP as the ultimate fractal language (Was: Reply to Ousterhout's reply (was Re: Ousterhout and Tcl ...))
Message-Id: <19970411.7E8EE90.C8CE@contessa.phone.net>
In <hbaker-1004971904150001@10.0.2.1>, hbaker@netcom.com (Henry Baker) wrote:
> Lisp is the ultimate 'fractal' language, because it is good at all levels,
> from microcode to shell scripts.
This is more a property of the implementations than the language per
se. You also get help from the name "LISP" being so flexible. Last
time I looked, the shortest and longest ANSI language specs were both
for LISP (is that still true?).
Without a high-quality compiler (or microcode generator), it wouldn't
be a good language for "systems programming" (or writing microcode.
Without the typing aids one finds in LISP implementations, it doesn't
make a good QAD hacking language
That the language has good support for programming in the large makes
it possible to build implementations that are good for programming in
the large.
Given that support, it's possible to build implementations of any
given language that are good for all those environments.
The interesting question is then why has the LISP community
fractalized this way whereas most other programming languages
communities haven't?
<mike
--
Do NOT reply to the address in the From: header. Reply to mwm instead
of bouncenews at the same machine. You have been warned. Sending
unsoliticed email I consider commercial gives me permission to
subscribe you to a mail list of my choice.
------------------------------
Date: 11 Apr 1997 20:10:03 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: LWP - again...
Message-Id: <5im5qr$nm7$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Alex Schajer <schajer@dircon.co.uk> writes:
:Hi,
:
:I'm trying to user the LWP library and in particular the HTTP/Header
:part.
:All I want to do is go through a list of URL's and check when they were
:last modified. It says in the LWP manual user
:
:if ($h->last_modified < time - 60 *60 {
:...
:}
:
:However how do I tell the script what webpage to look at?
#!/usr/bin/perl -w
#
# surl -- tchrist@perl.com
#
# sort URLs fed via stdin or in files on command line, e.g.
# $ surl file_with_list_of_urls nuther_such_file
# $ perl -lne 'print $1 while /HREF\s*=\s*"(http.*?)"/gi' file.html | surl
#
# retrieve Perl source from
# http://www.perl.com/CPAN/src/5.0/latest.tar.gz
# retrieve the LWP library from
# http://www.perl.com/cgi-bin/cpan_mod?module=LWP
use strict;
require 5.002;
require LWP::UserAgent;
require HTTP::Request;
my($url, %Date);
while ( $url = <> ) {
my($req, $ua, $ans);
chomp $url;
warn "FETCHING $url\n";
$req = new HTTP::Request "HEAD", $url;
$ua = new LWP::UserAgent;
$ans = $ua->request($req);
if ($ans->is_success) {
$Date{$url} = $ans->last_modified || 0; # unknown
} else {
warn "$url: Error [", $ans->code, "] ", $ans->message;
}
}
foreach $url ( sort { $Date{$b} <=> $Date{$a} } keys %Date ) {
printf "%-25s %s\n", $Date{$url}
? (scalar localtime $Date{$url})
: "<NONE SPECIFIED>",
$url;
}
__END__
--
Tom Christiansen tchrist@jhereg.perl.com
"For it, that's now" --Larry Wall
------------------------------
Date: 12 Apr 1997 00:54:07 GMT
From: "Jeff Oien" <jeffo@execpc.com>
Subject: Newbie: Why tr/+/ / Instead of s/+/ / ?
Message-Id: <01bc46dd$1081f3c0$7442cfa9@Pjeffo.execpc.com>
Hi,
I was wondering why form mail scripts always use
tr/+/ /
instead of
s/+/ /
with only one character, wouldn't they be the same?
Thanks,
--
Jeff Oien, WebDesigns
http://www.execpc.com/webdesigns/
jeffo@execpc.com
------------------------------
Date: 11 Apr 1997 23:08:30 GMT
From: cosc19z5@Bayou.UH.EDU (cosc19z5@bayou.uh.edu)
Subject: Re: Ousterhout and Tcl lost the plot with latest paper
Message-Id: <5img9e$hvj@Masala.CC.UH.EDU>
Tom Christiansen (tchrist@mox.perl.com) wrote:
: [courtesy cc of this posting sent to cited author via email]
: In comp.lang.perl.misc,
: rv@erix.ericsson.se (Robert Virding) writes:
: :A final question which has long interested me and which seems relevant
: :to this whole discussion: who would use Tcl if it DIDN'T have such a
: :integrated interface to Tk?
: The people using it for expect.
Ok, in all fairness I do have to note this as a contribution on the
side of Tcl. I was quite pleased that a language existed to allow
control of other programs, and did in fact think it was a nifty idea.
So regardless of my feelings towards Tcl, I do admire the idea of
Expect.
: --tom
: --
: Tom Christiansen tchrist@jhereg.perl.com
: With a PC, I always felt limited by the software available. On Unix, I am
: limited by my knowledge. --Peter J. Schoenster <pschon@baste.magibox.net>
--
Cya,
Ahmed
------------------------------
Date: Fri, 11 Apr 1997 22:07:40 GMT
From: tgy@chocobo.org (Tim Gim Yee)
Subject: Re: Parsing a file backwards
Message-Id: <334eb496.17152924@news.seanet.com>
On Fri, 11 Apr 1997 09:42:15 -0600, Heather <hls@hpfitst2.fc.hp.com>
wrote:
>How do I open a file from within a perl script and parse it from the
>bottom up, as opposed to top down, which seems to be the default.
foreach (reverse <FH>) {
# do stuff starting with last line...
}
Of course, perl still reads the file top down to begin with, but it's
simpler than seek/read.
-- Tim Gim Yee tgy@chocobo.org
http://www.dragonfire.net/~tgy/moogle.html
"Will hack perl for a moogle stuffy, kupo!"
------------------------------
Date: Fri, 11 Apr 1997 16:50:41 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Parsing a file backwards
Message-Id: <hnbmi5.arf.ln@localhost>
Heather (hls@hpfitst2.fc.hp.com) wrote:
: How do I open a file from within a perl script and parse it from the
: bottom up, as opposed to top down, which seems to be the default.
@lines = reverse <FILE>;
foreach (@lines) {
# last to first...
}
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Fri, 11 Apr 1997 16:44:44 -0500
From: Mark Folmsbee <folmsbee@cjnetworks.com>
Subject: PERL 5.003 Link?
Message-Id: <334EB0CC.5457@cjnetworks.com>
Hello,
We are running redhat Linux 3.0.3 (kernel 1.2.13). Trying to install
perl version 5.003. The link of miniperl fails with:
"ld: cannot open -ldl: No such file or directory"
I took the defaults during config.
Looked at the INSTALL documentation and the FAQ (whichs says to look
at the INSTALL). Looked at the hints/linux which says something
about dynamic loading and redhat 3.0.3 needing:
RPMS/ld.so-1.7.14-3.i386.rpm
So downloaded this and tried redhat's install (rpm) which promptly
told me that it could not handle this version of rpm.
Is there some way to just link perl staticly and do away with this
new rpm or is the better route to fight with the rpm.
I can download a newer version of rpm and try
that but thought there might be an easier way to all this.
TIA!
Gary
------------------------------
Date: 11 Apr 1997 15:41:28 -0700
From: Scott Henry <scotth@sgi.com>
Subject: Re: Perl regression test weirdness.
Message-Id: <yd8pvw1ji7b.fsf@hoshi.engr.sgi.com>
>>>>> "H" == H Todd Chapman <htchapma@vela.acs.oakland.edu> writes:
H> I am trying to compile Perl 5.003 on an SGI Indy running IRIX6.2.
H> When I run the regression tests anywhere between 1 and 3 tests
H> fail. I can't make sense of it. One time op/overload will fail
H> and the next time I run the test lib/bigintpm and lib/gdbm will
H> fail. Somtimes others. If I run the test individually they always
H> pass. These are the errors from make test that are seen every
H> time:
H> Extracting pod2text (with variable substitutions)
H> AutoSplitting perl library
H> Making DynaLoader (static)
H> cc -32 -L/usr/local/lib -o perl perlmain.o libperl.a lib/auto/DynaLoader/DynaLoader.a `cat ext.libs` -lsun -lm -lc -lcrypt -lbsd -lPW
Boy, is *that* an incredibly useless list of libraries... Note that
-llib are searched in that order, and some functions are defined in
more than one library. -lc should be the *last* one on the line,
which is your main problem. A reasonable set of libs is:
-lbsd -lm
See also the pre-built Perl inst packages on my Web page:
http://reality.sgi.com/scotth/info/perl5.html
--
Scott Henry <scotth@sgi.com> / Help! My disclaimer is missing!
IRIX MTS, / GIGO *really* means: Garbage in, Gospel Out
Silicon Graphics, Inc / http://reality.sgi.com/scotth/
------------------------------
Date: 11 Apr 1997 23:24:56 GMT
From: roberson@ibd.nrc.ca (Walter Roberson)
Subject: Re: Perl regression test weirdness.
Message-Id: <5imh88$1te$1@canopus.cc.umanitoba.ca>
In article <5ilh3l$93g@saturn.acs.oakland.edu>,
H. Todd Chapman <htchapma@vela.acs.oakland.edu> wrote:
:I am trying to compile Perl 5.003 on an SGI Indy running IRIX6.2.
:When I run the regression tests anywhere between 1 and 3 tests fail. I
+can't make sense of it. One time op/overload will fail and the next
+time I run the test lib/bigintpm and lib/gdbm will fail. Somtimes
+others. If I run the test individually they always pass. These are the
+errors from make test that are seen every time:
[Whoa! That text line was originally over 300 characters long, which violates
the NNTP RFCs!]
:Extracting pod2text (with variable substitutions)
: AutoSplitting perl library
: Making DynaLoader (static)
: cc -32 -L/usr/local/lib -o perl perlmain.o libperl.a lib/auto/DynaLoader/DynaLoader.a `cat ext.libs` -lsun -lm -lc -lcrypt -lbsd -lPW
:ld: WARNING 84: /usr/lib/libsun.a is not used for resolving any symbol.
:ld: WARNING 85: definition of _setkey in /usr/lib/libc.so preempts that definition in /usr/lib/libcrypt.so.
:ld: WARNING 85: definition of setkey in /usr/lib/libc.so preempts that definition in /usr/lib/libcrypt.so.
:ld: WARNING 85: definition of _encrypt in /usr/lib/libc.so preempts that definition in /usr/lib/libcrypt.so.
:ld: WARNING 85: definition of encrypt in /usr/lib/libc.so preempts that definition in /usr/lib/libcrypt.so.
:ld: WARNING 85: definition of crypt in /usr/lib/libc.so preempts that definition in /usr/lib/libcrypt.so.
:ld: WARNING 85: definition of _crypt in /usr/lib/libc.so preempts that definition in /usr/lib/libcrypt.so.
:ld: WARNING 84: /usr/lib/libcrypt.so is not used for resolving any symbol.
:ld: WARNING 84: /usr/lib/libbsd.a is not used for resolving any symbol.
:ld: WARNING 84: /usr/lib/libPW.so is not used for resolving any symbol.
:
:Can anyone make sense of this?
None of what you quote here is an error.
The first one is telling you that libsun.a is not needed for this program.
That's not surprising, as under IRIX 6.2 libsun.a is a dummy library
that resolves nothing, all of its functionality having long been subsumed
into other libraries.
The messages about symbols in libc preempting symbols in libcrypt are
warnings only. By specifying -lc first, you have indicated that you
*want* libc symbols to preempt libcrypt symbols; the warnings are just
there to point out the consequences. In this case, we can see from
what follows, that libcrypt.so is not used, that the consequences are
probably not what you intended. If you bothered to specify libcrypt
on the compile line at all, you probably intended the full US-only
libcrypt versions to override the fully-exportable equivilent routines
in libc... but you should specify -lcrypt *before* -lc if that's what
you actually want.
The last two lines are also just warnings about libraries not actually
being used. Again they may indicate that your link order may not be
in accordance with your intention. If you truely want to use the BSD versions
of various routines, you must specify -lbsd *before* -lc, and you should
be sure to define _BSD_COMPAT or _BSD_SIGNALS or _BSD_TIME
libPW.so is a link to libgen.so, which holds XPG4-UX functions.
None of the above would randomly affect regression tests (but could
systematically affect regression tests that depended upon BSD behaviour).
What *could* affect regression tests randomly is if the code reads
uninitialized memory.
Someone (Scott Henry? http://reality.sgi.com/scotth ) put up the
recipie for compiling Perl 5.003 on SGI.
------------------------------
Date: Fri, 11 Apr 1997 17:15:21 -0500
From: Eric Ladner <eladner@goldinc.com>
Subject: Reading another line in an input loop?
Message-Id: <334EB7F9.842E23A2@goldinc.com>
I've been over the docs and the FAQ and can't seem to find the answer
I'm looking for (if it exists at all).
What I want to do is something like this:
open (INFILE, "sometextfile") or die "can't open.\n";
while (<INFILE>) {
# do some stuff.
if (/something/) {
# process some more
# get the next line without looping again
# process some more.
}
}
I think what I'm looking for is the perl equivalent of the awk command
getline.
Any hints?
-------------------------------------------------------------
Eric Ladner Oracle 7.X DBA and SysAdmin on
ELadner@GoldInc.com DEC OSF/1, HP-UX, and of course my
#include <disclamer.h> favorite, Linux: It works for me.
-------------------------------------------------------------
------------------------------
Date: Fri, 11 Apr 1997 20:03:20 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Reading another line in an input loop?
Message-Id: <comdog-1104972003200001@nntp.netcruiser>
In article <334EB7F9.842E23A2@goldinc.com>, Eric Ladner
<eladner@goldinc.com> wrote:
> What I want to do is something like this:
>
> open (INFILE, "sometextfile") or die "can't open.\n";
> while (<INFILE>) {
> # do some stuff.
> if (/something/) {
> # process some more
> # get the next line without looping again
just get the next line:
$next_line = <INFILE>;
> # process some more.
> }
> }
--
brian d foy <URL:http://computerdog.com>
unsolicited commercial email is not appreciated
------------------------------
Date: Fri, 11 Apr 1997 16:49:00 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: repeat pattern in one line
Message-Id: <ckbmi5.arf.ln@localhost>
[ posted, emailed ]
Mr. Chow Wing Siu (wschow@Comp.HKBU.Edu.HK) wrote:
: For example, if I want to match the pattern ABCDEF in the following file,
: how to count the frequency? ANS:6 Please mail the source to me. Thanks.
: --file begin--
: ABCDEF ABCDEF ABCDEF
: ABCDEF ABCDEF ABCDEF
: --file end--
--------------------------------
#! /usr/bin/perl -w
$_=<<ENDVAR;
ABCDEF ABCDEF ABCDEF
ABCDEF ABCDEF ABCDEF
ENDVAR
while (/ABCDEF/g ) {$cnt++}
# ^
# ^
print "there are $cnt matches for 'ABCDEF'\n";
--------------------------------
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Fri, 11 Apr 1997 22:26:45 GMT
From: alaric@abwillms.demon.co.uk (Alaric B. Williams)
Subject: Re: Reply to Ousterhout's reply (was Re: Ousterhout and Tcl ...)
Message-Id: <334d3fa2.8156638@news.demon.co.uk>
On Thu, 10 Apr 1997 09:08:06 +1000, Graham Matthews
<graham.matthews@maths.anu.edu.au> wrote:
>What rubbish. You can train people to use a modern language just like
>you can and do train them to use an older language. The "oh these new
>languages are too hard to learn for Joe average programmer" just doesn't
>stand up. How can a language with no pointers, no explicit memory
>alloc/dealloc, etc be harder to learn than one where you have to do all
>that yourself ...
Remember LOGO; a LISP derivative used for teaching youngsters to
program...
ABW
--
"Plug and Play support: WfEWAD will autodetect any installed
Nuclear Arsenals, Laser Satellites, Battlefield Control Networks,
Radar Installations, Fighter Squadrons, and other WfEWAD compliant
devices, including the new Macrosoft Unnatural Keyboard, with
full support for the now-famous Big Red Buttom(tm)."
(Windows for Early Warning and Defence User's manual P26)
Alaric B. Williams Internet : alaric@abwillms.demon.co.uk
<A HREF="http://www.abwillms.demon.co.uk/">Hello :-)</A>
------------------------------
Date: 11 Apr 1997 23:27:52 GMT
From: cosc19z5@Bayou.UH.EDU (cosc19z5@bayou.uh.edu)
Subject: Re: Reply to Ousterhout's reply (was Re: Ousterhout and Tcl ...)
Message-Id: <5imhdo$hvj@Masala.CC.UH.EDU>
John Ousterhout (ouster@tcl.eng.sun.com) wrote:
: In article <5ihaol$n3g@Masala.CC.UH.EDU>, cosc19z5@Bayou.UH.EDU (cosc19z5@bayou.uh.edu) writes:
: |> ...
: |>
: |> As for Tcl, it's there for one reason and one reason only -- strong
: |> corporate backing. We've got a powerful company that wants to
: |> make a quick buck and therefore is using its clout to force
: |> Tcl down our throats. This is the same tactic used by charlatans
: |> like Micro$oft. Indeed that's the only possible explanation
: |> as to why a glorified text preprocessor would even get a second
: |> look -- that and the fact that it is riding on the coattails
: |> of Tk.
: Sorry for taking so long to respond to this comment, but I couldn't stop
: laughing long enough to compose a response.
Is that also the reason why you didn't bother answering any of the
numerous posts that raised very legitimate questions about your
motivations, and Tcl in general?
I find it very interesting that you ignored all these interesting
posts, and when you chose to followup, you chose a followup where
you cut everything except one passage that necessitated nothing
more than a smug response on your behalf.
You know, if I didn't know any better I'd say you were avoiding
the other posts. I wonder why?
: I wish your accusation were
: true, but I'm afraid you are a bit out of touch. Apparently you haven't
: heard of a language called Java, which is the main thing Sun is pushing
: these days?
Gee Java, what's that? Yes I know about Java, how on Earth could
anyone not know about Java? Java this, Java that. Yes, for the
love of Shub Niggurath -- the goat with a thousand young, I know
about Java!
Could you tell that the Java hype is getting to me just a wee
bit?
: We're a small player in comparison. Also, how do you explain
: the 100,000 or so people who learned Tcl while I was still a lowly
: professor at Berkeley? Was that just a powerful university trying to
: make a quick buck and using its clout to force Tcl down people's throats?
Ok, pay attention Mr. Ousterhout, I'm about to do something that you've
been avoiding all along. I'm about to directly address an issue
relating to something I said! Yes, pay close attention so that you'll
know what to do if you actually decide to do this yourself (as
unlikely as that may seem):
My statement was exxagerated. I still maintain that Tcl does have
corporate backing, but my comparison with M$ and statements about
having it rammed down our throats was an (unintentional) exxageration.
Indeed, comparing any organization with M$ is the sort of thing
that should be done with extreme care, and in doing this, I have
unjustly insulted Sun, which has not done anything (yet) to warrant
the kind of contempt bred by Bill & Co. I'm no fan of Sun, but
comparing them to M$ is very unfair.
There, I have admitted my mistake, are you man enough to admit yours?
[Snip]
: Yes, I mean "we". Many many people have participated
: in this sinister plot, including Larry Wall, Dennis Ritchie, Bill Gates,
: the Bureau of ATF, most of the LAPD, and Mark Fuhrman (sorry you guys, but
: the truth has overwhelmed me so I've been forced to expose you). I feel
: just terrible at how I have set the programming world back, and I promise
: to be a good boy from now on.
I'm very glad that you are enjoying this Mr. Ousterhout. You've
blundered, people are criticizing you, and you are in a position
where you can learn something, possibly even do something to further
computing, yet you just take this as a joke.
I'm very happy that you find this funny.
: Now that that's over with, you can all get back to work now.
Yes, I'm sure you have a few more "gems" to release to the reading
public.
--
Cya,
Ahmed
------------------------------
Date: 11 Apr 1997 11:52:25 -0700
From: John Shen <johns@cnet.com>
Subject: Re: Reply to Ousterhout's reply (was Re: Ousterhout and Tcl ...)
Message-Id: <yuhsp0xjst2.fsf@cnet.com>
-----BEGIN PGP SIGNED MESSAGE-----
ouster@tcl.eng.sun.com (John Ousterhout) writes:
> OK, enough is enough. I can see that I'm not going to be able to fool you
> guys. I confess everything. You're right. It all *was* an evil
> conspiracy. There really isn't a shred of merit in Tcl, or C++, or Perl,
> or C; there is not a single reason on earth why anyone should use any of
> these languages for any programming task. Scheme truly is the perfect
> language that solves every problem and combines the virtues of every
> other language. For years we've been plotting to trick programmers into
> using bad languages. Yes, I mean "we". Many many people have participated
> in this sinister plot, including Larry Wall, Dennis Ritchie, Bill Gates,
> the Bureau of ATF, most of the LAPD, and Mark Fuhrman (sorry you guys, but
> the truth has overwhelmed me so I've been forced to expose you). I feel
> just terrible at how I have set the programming world back, and I promise
> to be a good boy from now on.
>
> Now that that's over with, you can all get back to work now.
Dear Professor O,
I hope you are just trying to be hilariously humorous in an emotional
argument to lighten up everyone, not really overwhelmed by the
personal attacks which are quite normal around the net (unless you are
too busy and seldom have time to stay long enough to witness that,
which I suspect being the case). I tend to think they are a normal
part of the cyberlife, whether we like it or not. Please get back to
doing your good work and gently ignore them. Also, when you are now
working for a company with clout and commercial interests in seeing
certain tools/languages succeed, suspicions (minus the ad hominim
part) that you have a mercurial motives are actually healthy and do
help us avoid being "taken" by hypes and infomercials.
I must say that your paper (which undoubtedly can be improved in many
ways) truly has had an enormous impact on all the programmers/project
leaders as I have not seen that much discussions on any other topic
recently in so many programming groups. This alone should hopefully
motivate all us of to read and think carefully about what you have
written, and give you more reason to follow up the topic with more
rigorous and convincing results and demonstrations. Languages like
Perl and Tcl (well, I cannot help putting Perl ahead of Tcl :-) have
been looked down upon by some as tools to craft quick-and-dirty
solutions, yet their successes in mission-critical projects
contradicts such views (actually they can be used for the full
spectrum from q&d to enterprise-level applications, which is the
beauty of it all). Your research and explanation will help such
successes, so please do continue, for the good of the community,
please say yes.
john
-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
Comment: http://www.ifcss.org/~zshen/ faith,hope,love http://www.cnet.com/
iQB1AwUBM06IYTagfthcdazpAQE5sQL/TaHv5E+ZFa0ex1zoTfYAIdVNt+RFIGFe
wNhdsJmCoxn/kYQKmXwrmEicAo6O0nxTj5iWlpCPgPKEjaKcmLbzDmvaDtbxkJqk
lW3WPS/1LmCmQnt8oMcNVh87TYtXigBp
=m8xn
-----END PGP SIGNATURE-----
------------------------------
Date: 11 Apr 1997 20:47:36 GMT
From: roy@mchip00.med.nyu.edu (Roy Smith)
Subject: Re: Reply to Ousterhout's reply (was Re: Ousterhout and Tcl ...)
Message-Id: <5im818$v0n$1@news.nyu.edu>
prasadm@not4u.polaroid.com writes:
> C happened to provide a real alternative to assembly.
There are some who claim that C is just a nice high-level assembler. I used
to use it that way when I was writing 6800 (not 68000) code. I would write
my programs in simple-minded C, then hand-compile it into 6800 ASM.
--
Roy Smith <roy@popmail.med.nyu.edu>
New York University School of Medicine
Copyright 1997 Roy Smith
For-profit redistribution prohibited
------------------------------
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 283
*************************************