[6762] in Perl-Users-Digest
Perl-Users Digest, Issue: 387 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 28 22:27:16 1997
Date: Mon, 28 Apr 97 19:00:25 -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 Mon, 28 Apr 1997 Volume: 8 Number: 387
Today's topics:
Deleting Files <cristo@consotech.se>
Dups in a array.. how to clear? <tony@vegas.es.hac.com>
file copy <rebecc60@pobox.upenn.edu>
Re: File Copy (Tad McClellan)
Re: file copy (Jeff Stampes)
Re: File Copy (Tim Gim Yee)
File::Find error (Otis Gospodnetic)
HTML parser in Perl (Aviel Rubin)
Re: I/O on serial device? (Stephen P Lee)
Re: Ldsa rader och jdmfvra dem med $FORM{'username'} fu (Chipmunk)
Re: Multiple classes, one object? <tchrist@mox.perl.com>
Re: Network Programming and Sockets <lpa@sysdeco.no>
Re: Network Programming and Sockets (Nathan V. Patwardhan)
Re: Notice to antispammers (John Stanley)
Re: Object IDs are good ( was: Object IDs are bad ) <wg@cs.tu-berlin.de>
Re: Ousterhout and Tcl lost the plot with latest paper <celtschk@physik.tu-muenchen.de>
PAGER (thanks) (Chipmunk)
Perl script crashes when filehandle is closed jase@cadence.com
port from solaris to WinNT 4.0 <boris@virtualf.com>
Re: pre-RFD: comp.lang.perl.{data-structure,inter-proce <usenet-tag@qz.little-neck.ny.us>
Re: problem: array assignment to hashref slice <fawcett.i-dont-like-spam@nynexst.com>
push or unshift simple question (Geoffrey Hebert)
Re: raw input (Tad McClellan)
redirection of STDERR <laguerre@cri.ensmp.fr>
Re: Substitute File Path For URL (Gerben Vos)
Re: using modems from perl <rootbeer@teleport.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 28 Apr 1997 19:22:04 -0700
From: Cristo <cristo@consotech.se>
Subject: Deleting Files
Message-Id: <33655B4C.23D8@consotech.se>
Hi!
A quick question. How do I delete a file in Perl?
Second question. How do I make a back button with HTML?
Third question. How do I create a Directory?
Thanx!
Please e-mail me the answer to cristo@consotech.se
/Best Regards Cristo
------------------------------
Date: 28 Apr 1997 21:19:02 GMT
From: "Tony Reeves" <tony@vegas.es.hac.com>
Subject: Dups in a array.. how to clear?
Message-Id: <01bc5419$dac9b8e0$45931193@treeves.es.hac.com>
I have a large arrray..
@ALLUSERS - about 9,000 records.
I'd like to know a simple way to remove any duplicates that might be in the
file. that is if the file has:
0098456,Jones,Smith
0098657,Patton,George
0097693,Bradley,Jim
.
.
.
0098456,Jones,Smith
what routine can I use to look at this HUGE file and remove the dups, like
Jones,Smith.
I looked at grep, but not sure it will work, or will it?
------------------------------
Date: Mon, 28 Apr 1997 11:49:07 -0400
From: Becky Schonfeld <rebecc60@pobox.upenn.edu>
Subject: file copy
Message-Id: <3364C6F3.7A58@pobox.upenn.edu>
I have used the following bit of perl to attempt to get file $A to be
copied to $B except for one line ($break of file $A). However it seems
to not skip line $break. Can anyone help?
$records=0;
open(IN, "$A") || die "cannot open $A for reading";
open(OUT, ">$B") || die "cannot create $B";
while (<IN>){
if ($records != $break){
print OUT $_;}
$records++;
}
------------------------------
Date: Mon, 28 Apr 1997 17:02:44 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: File Copy
Message-Id: <4q63k5.p11.ln@localhost>
Becky Schonfeld (rebecc60@pobox.upenn.edu) wrote:
: Can anyone send me or recommend a very simple script to copy file1 to
: file2 except for one line from file1? Any help is much appreciated.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Which line to you want to leave out?
The first one?
The last one?
One from the middle?
One that contains a certain string?
The shortest one?
The longest one?
Sorry, but you get the idea. We cannot write it with the specification
that you have provided. We don't know what criteria to use to
determine which line to skip...
Using the File::Copy module would be a Good Idea.
But here is how to copy a (complete) file the hard way:
open(IN, "infile") || die "could not open 'infile' $!";
open(OUT, ">outfile") || die "could not open 'outfile' $!";
while (<IN>) {
print OUT;
}
close(IN);
close(OUT);
Tell us how to identify the line to be omitted...
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 28 Apr 1997 23:54:58 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: file copy
Message-Id: <5k3dci$94d$1@neocad.com>
Becky Schonfeld (rebecc60@pobox.upenn.edu) wrote:
: I have used the following bit of perl to attempt to get file $A to be
: copied to $B except for one line ($break of file $A). However it seems
: to not skip line $break. Can anyone help?
: $records=0;
: open(IN, "$A") || die "cannot open $A for reading";
: open(OUT, ">$B") || die "cannot create $B";
These should read:
open IN, $A or die "cannot open $A for reading";
|| has a higher precedence than a list operator like open, so you
should always use 'or' instead of '||'
: while (<IN>){
: if ($records != $break){
: print OUT $_;}
: $records++;
: }
what's $break? It ha sno meaning in this context, so the
comparison is always true.
--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com
------------------------------
Date: Tue, 29 Apr 1997 01:48:11 GMT
From: tgy@chocobo.org (Tim Gim Yee)
Subject: Re: File Copy
Message-Id: <33655134.146024061@news.seanet.com>
On Mon, 28 Apr 1997 09:15:23 -0400, Becky Schonfeld
<rebecc60@pobox.upenn.edu> wrote:
>Can anyone send me or recommend a very simple script to copy file1 to
>file2 except for one line from file1? Any help is much appreciated.
perl -pe "$_='' if $.==1" file1 >file2
That should copy everything from file1 to file2 minus the first line.
Not sure if this is what you wanted though.
-- Tim Gim Yee tgy@chocobo.org
http://www.dragonfire.net/~tgy/moogle.html
"Will hack perl for a moogle stuffy, kupo!"
------------------------------
Date: 28 Apr 1997 16:48:28 GMT
From: otisg@tiger.middlebury.edu (Otis Gospodnetic)
Subject: File::Find error
Message-Id: <5k2kcs$mc2@tiger.middlebury.edu>
Hi,
I was running a script that uses File::Find.pm when it suddenly died due to
the following error:
Modification of a read-only value attempted at
/home/its/otisg/lib/perl5/File/Find.pm line 130.
I looked at the relevant line in the module, and it says:
$name = "$dir/$_";
I know I use variables $name and $_ in some places in this script. Could it
be that they are non-local and are colliding? (but then why didn't the script
die the first time it encountered $name variable in my script?)
Thanks,
Otis
------------------------------
Date: 28 Apr 1997 17:31:45 GMT
From: rubin@quip.eecs.umich.edu (Aviel Rubin)
Subject: HTML parser in Perl
Message-Id: <5k2mu1$mup$1@news.eecs.umich.edu>
Is there a public domain HTML parser in perl available
anywhere?
Please reply by e-mail to rubin@research.att.com since I
have trouble keeping up with the newsgroup.
Thanks,
Avi
*********************************************************************
Aviel D. Rubin rubin@research.att.com
Secure Systems Research Dept.
AT&T Research Labs
600 Mountain Ave. http://www.research.att.com/~rubin/
Murray Hill, NJ 07974-0636 Voice: +1 908 582-7468
USA FAX: +1 908 582-5192
------------------------------
Date: 29 Apr 1997 00:25:38 GMT
From: splee@sfu.ca (Stephen P Lee)
Subject: Re: I/O on serial device?
Message-Id: <5k3f62$30n$1@morgoth.sfu.ca>
In article <gerlachE93KIr.FJ8@netcom.com>,
Matthew H. Gerlach <gerlach@netcom.com> wrote:
>In article <335D6B60.3976B227@netscape.com> Jamie Zawinski <jwz@netscape.com>
writes:
>>I want to have a Perl script that talks to my modem. This doesn't
>>work:
>
>I have found serial i/o to be more tricky that it seems on the surface. It
>usually involves working with termio's and being sure to set every field
>exactly right.
>
>I have had great luck having my perl scripts talk to a serial program
>rather than talking to the device directly. Specifically, I use Comm.pl
>to talk to ckermit from columbia.edu. You could use cu, or tip, but
>I don't suggest it.
>
>Matthew H. Gerlach
>
Would you mind sending me or posting a sample of how to implement ckermit
or some other comm program within a perl scrip? I would like to control
a device connected to the comm port of a Linux box. The device accepts
hayes-style commands.
I'm new to Perl programming so any help would be appreciated.
Thanks,
Stephen
--
Stephen P. Lee Office: (604) 291-4291
Department of Biological Sciences Fax: (604) 291-3496
Simon Fraser University E-mail: Stephen_p_lee@sfu.ca
Burnaby, BC, Canada. V5A 1S6
------------------------------
Date: 28 Apr 1997 23:05:53 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: Ldsa rader och jdmfvra dem med $FORM{'username'} funkar ej
Message-Id: <5k3agh$14t$1@dartvax.dartmouth.edu>
In article <33642F81.7B4@algonet.se>
Jonas Thvrnvall <labah@algonet.se> writes:
> Varfvr blir fvljande kod alltid 'true'?
> Jag fvrsvker ldsa rader och jdmfvra dem med $FORM{'username'},
> jag ser att samma namn upprepas trots detta blir satsen aldrig falsk
> kan negon hjdlpa mig?
>
> # Rdkna rader
> open (FILE,"$users") || die "Can't Open $users: $!\n";
> @LINES=<FILE>;
> close(FILE);
> $SIZE=@LINES;
>
> # Vppna och skriv
> open (GUEST,">$users") || die "Can't Open $users: $!\n";
> $new='true';
> for ($i=0;$i<=$SIZE;$i++) {
> $_=$LINES[$i];
> if ($FORM{'username'} eq $_) {
> $new='false';
>
> }
> print GUEST $_;
> }
> if ($new eq 'true'){print GUEST "$FORM{'username'}\n";}
> close (GUEST);
Afraid I don't speak the language, so I'm not sure what the question
is. I notice that you seem to be iterating past the end of the array.
@array = (0,1,2);
scalar(@array) == 3;
$#array == 2;
Try this instead:
# Rdkna rader
open (FILE,"$users") || die "Can't Open $users: $!\n";
@LINES=<FILE>;
close(FILE);
# Vppna och skriv
open (GUEST,">$users") || die "Can't Open $users: $!\n";
$new='true';
# replace 'for' with 'foreach'
foreach (@LINES) {
if ($FORM{'username'} eq $_) {
$new='false';
}
print GUEST $_;
}
if ($new eq 'true'){print GUEST "$FORM{'username'}\n";}
close (GUEST);
---
Do the values in %FORM have newlines (\n) at the end?
Does $FORM{'username'} eq "name" or does $FORM{'username'} eq "name\n"?
You might need to add 'chomp($_);'
Hope that helps.
Chipmunk
------------------------------
Date: 28 Apr 1997 22:02:07 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Multiple classes, one object?
Message-Id: <5k36ov$g6u$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
colink@latticesemi.com (Colin Kuskie) writes:
:I would like to build a module that supplies two classes, A and B, where
:B inherits and builds on the functions in A. Can I place both classes
:in the same module:
:
:ie use Foo::Bar; ##Access the A and B methods
Yes, you may, if you're careful about it.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
"The usability of a computer language is inversely proportional to the
number of theoretical axes the language designer tries to grind."
--Larry Wall
------------------------------
Date: Mon, 28 Apr 1997 19:42:10 +0200
From: Luca Passani <lpa@sysdeco.no>
Subject: Re: Network Programming and Sockets
Message-Id: <3364E172.2CA9@sysdeco.no>
Actually, I think I understand the spirit of the first poster.
I have the Camel5 and Unix Network Programmin by R. Stevens.
The latter is full of C code and it really takes hard studying to get
into it (which I still haven't).
I wanted to see how things worked in Perl and (even though I managed to
make a nice server which helps me debug a parser) I think that
Perl only adds a very thin layer on the original C-TCP/IP interface.
I wonder if:
1) wouldn't it be possible for Perl to offer some higher-level interface
to TCP/IP (even Socket.pm requires a rather deep understanding of
C/TCP/IP stuff)
2) The Camel shouldn't explain more about how the server and the client
really work in the examples. This could turn out to be an introduction
to Network programming for many.
luca
Neil Briscoe wrote:
>
> In article <Pine.GSO.3.96.970424113146.24140A-100000@pickett>,
> plussier@synnet.com (Paul Lussier) wrote:
> > This is my first venture into network programming, and dealing with
> > writing client/server type scripts. I took the 2 examples Tom C. wrote
> > on
> > 194-5 of the perlref .pdf file and began playing with them. What I
> > couldn't figure out, was how I would pass parameters from the client to
> > the server. All the examples seem to have the server configured to only
> > one thing (which is great for examples). But, for instance, how could I
> > change Tom's example to accept different parameters?
> >
> > Currently, the client connects to the server, and the server outputs to
> > the client:
> >
> > Hello there, <client name>, it's now <date>
> >
> > I'd like to be able to pass command line args from the client to the
> > server. For example, something like:
> >
> > client "ls -l /usr/local"
> >
> > would pass the string "ls -l /usr/local" to the server, and the server
> > would return the "ls -l" output of /usr/local on that machine.
> > Obviously
> > my goal is to accomplis more than just a remote "ls" server :)
> >
> > Any help would be greatly appreciated, or, any pointers to good docs on
> > into to client/server programming would be great as well (any one write
> > one in perl yet? :)
> >
> > Thanks a lot
> >
>
> Clients and servers talk to each other via the socket connection. To do
> what you want, you need to develop a protocol that they both expect to be
> adhered to. It can be as simple as :-
>
> Client: Hello
> Server: Greetings
> Client: Incoming Data
> Server: Give it to me, finish with 'End of Data'
> Client: 13
> Client: 10
> Client: +
> Client: End of Data
> Server: Thanks - the answer is 23
>
> Or just as complicated as you like. Most protocols are actually far more
> pithy than this, computers aren't great conversationalists.
>
> You need to read a good book on Unix Network programming, which,
> doubtless, will be full of C code, but which you should be able to
> transfer to your Perl writings. I have a copy of Unix Network Programming
> by R. Stevens here, its a little old now, but may well have been updated.
======================================================================
Luca Passani. | Sysdeco Innovation AS, http://www.sysdeco.no
Email: lpa@sysdeco.no | Trondheimsveien 184, 0570 Oslo, Norway
Tel: (+47) 22 09 66 06 | Fax: (+47) 22 09 65 03
======================================================================
------------------------------
Date: 28 Apr 1997 21:54:17 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Network Programming and Sockets
Message-Id: <5k36a9$8g0@fridge-nf0.shore.net>
Luca Passani (passani@eunet.no) wrote:
: > Many people should try to understand things before attempting to bang
: > something out. There are a number of resources around and about to
: > learn about network programming. I prefer the TV Guide. :-)
: If this logic was the one with which Perl was originally created, it
: wouldn't be as widespread as it is today.
What logic? Perl is for sharing, so what? It doesn't mean that people
shouldn't learn things properly, just because the code has already
been written. It also doesn't mean that people should seek simpler
functions/functionality when the existing functions don't suit them.
In fact, I can't find anything wrong with the sockets functions as
they are now, but I might be smoking crack. Sheeeeesh.
: Perl is useful because it's simple when you have to do simple things,
: yet it allows you to make more and more complex things as your
: knowledge improves.
uh-huh.
: On the other hand, I don't think this is the case with network
: programming, which really requires a lot of understanding before you can
: do simple things.
You're right. Well, I take that back. Once you've understood the
philosophy behind network programming / client-server models (with
even the simplest of cases), you'll be off and running. In other
words, a .sig server/client isn't difficult to write if you understand
the concepts behind it.
: Maybe I'm wrong, but I think that the difference is that defaults are
: not used as they are elsewhere in Perl.
What defaults are you talking about? Where else are they used in Perl?
: BTW if you have a resource which explains TCP/IP programming without
: giving me tons of C code, I would be glad to access it.
The only resource/knowledge-base I have uses tons of C code.
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: 29 Apr 1997 00:55:49 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Notice to antispammers
Message-Id: <5k3gul$4n4@news.orst.edu>
In article <336a033f.13117519@news.aimnet.com>,
Terry Carroll <carroll@tjc.com> wrote:
>People who use invalid email addresses to thwart spammers have made a
>decision to shift their problem of wanting to avoid spam from themselves
>to the persons who want to legitimately correspond with them. They have
>decided that the inconvenience to spammers outweighs the inconvenience to
>legitimate users, and they have decided on this without regard to the
>legitimate users.
Nonsense.
It's my mailbox, not yours. I have to deal with the things that show up
there, not you. When the bell rings to announce new mail, I am the one
who has to stop what I am doing to see if it is a priority message or
not, not you.
It's my decision who has a legitimate reason to put things in my
mailbox, not yours. I express that decision by filtering heavily.
That's why I don't have to waste time dealing with unbidden copies of
USENET articles or other junk mail coming through one of my addresses.
Any "legitimate user" knows an email address that will get through my
filters. I either tell them before they need it, or configure my filter
to let their mail pass at the address they do know. No legitimate user
is inconvenienced. I know this. I look at the logs.
>By removing the
>inconvenience to spammers, it removes the motivation for these rude people
>to shift their problem to the shoulders of legitimate correspondents.
The "rude people" are those who sit behind their own mail filters
threatening to provide other people's "unlisted" addresses to the
spammers so they will be spammed. Tom is helping spammers defeat the
mail filters that he thinks he has a right to run on his own mail.
If you don't like spam, fight the spammers, not the people who are
filtering their mail. The excuse that nothing will be done unless
everyone who is filtering has that filtering defeated is ridiculous.
The belief that legislative action will stop email spammers is just
too silly for any net-cognizant person to hold. As soon as spam is
illegal to send in the US, it will come from .at or .lv or .uk or any
of several dozen other non-US domains.
For many years, it has been accepted that people have the right to tell
others not to send them email. Now that people also have the technology
to enforce that, some people are upset that their mail isn't accepted
by everyone. They need to get over it, not seek revenge.
------------------------------
Date: 29 Apr 1997 00:42:04 +0200
From: Wolfgang Grieskamp <wg@cs.tu-berlin.de>
Subject: Re: Object IDs are good ( was: Object IDs are bad )
Message-Id: <1oohaybwhv.fsf@cs.tu-berlin.de>
schaffer@wat.hookup.net writes:
> In <pog1wbcuqw.fsf@dogbert.cs.chalmers.se>, Lennart Augustsson <augustss@cs.chalmers.se> writes:
> > ...
> >If objects can be distinguished when
> >you learn more about them then they were not equal in each and every
> >respect.
>
> Depends. Often computer programs are set up to model an approximation of
> the real world, with some selected attributes of the real world objects
> used in the description.
Actually, this kind of ``fuzzy'' modeling isn't supported explicitly
in pure functional languages, though it is surely relevant in praxis.
Pure FP's are useful if you have a formal model at hand (as in
compiler construction), or if you need one (as in safety-critical
systems).
Anything else can be done in pure FP's by using monads. But thats not
``referential transparency'' in the pragmatic sense discussed in this
thread.
Wolfgang
--
wg@cs.tu-berlin.de http://uebb.cs.tu-berlin.de/~wg/
------------------------------
Date: Mon, 28 Apr 1997 19:23:42 +0200
From: Christopher Eltschka <celtschk@physik.tu-muenchen.de>
Subject: Re: Ousterhout and Tcl lost the plot with latest paper
Message-Id: <3364DD2D.86195F2@physik.tu-muenchen.de>
John Ousterhout wrote:
[...]
> >The button example requires about 25 lines of code in three procedures
> >when implemented in C++ with Microsoft Foundation Classes. Just
> >setting the font requires 7 lines of code:
> >
> >LOGFONT lf;
> >
> >memset(&lf, 0, sizeof(lf));
> >
> >lf.lfHeight = -16;
> >
> >strcpy(lf.lfFaceName, "Times New Roman");
> >
> >CFont *fontPtr = new CFont();
> >
> >fontPtr->CreateFontIndirect(&lf);
> >
> >buttonPtr->SetFont(fontPtr);
>
> Come on! All this shows is the inconveniece of using the MFC
> classes. An interface exactly the same as the Tcl one could easily be
> written in C++.
>
> I invite anyone who believes this to try to do it, and post the results.
> I've had this argument before, and when people do this, one of two things
> happens: either they eventually concede that this is hard to do in C++, or
> they define new C++ APIs that are essentially untyped (e.g. they use
> strings for everything). This just supports my arguments that types get
> in the way of gluing. You can build untyped APIs in strongly typed
> languages, but they tend to be clumsy because the languages are designed
> to encourage strong typing. If you need an untyped approach, you might
> as well use a language designed for that.
Well, I found this discussion just now, but this is IMHO easy to answer:
void action() { cout << "Hello" << endl; }
button b=buttonstyle().text("Hello").font("Times",16).execute(action);
Where the library would have the following definitions (only public
parts
shown):
typedef void (*actionproc)();
class buttonstyle
{
public:
friend button;
buttonstyle& text(string txt);
buttonstyle& font(string name, int size);
buttonstyle& execute(actionproc);
// other attributes
};
class button
{
public:
button(const buttonstyle& style);
void changestyle(const buttonstyle&);
buttonstyle style();
// button actions
};
As you see, it *is* possible to do it in C++. So if the C++ interface of
real
GUI libraries isn't as simple, you should complain to the library
writer,
not the language.
And it is neither untyped (you can't initialize a button with anything
but
a buttonstyle), nor hard to do (all methods are just straightforward).
BTW, what would the following possible C++ interface for menus look like
in
tcl/tk?
MenuBar MainMenu
(
Menu("Main")
.Item
(
Menu("~File")
.Item(Command("~Open", cmOpenFile), helpOpen)
.Item(Command("~Save", cmSaveFile), helpSave)
.Item(Command("~Save ~As", cmSaveFileAs), helpSaveAs)
.Separator()
.Item(Switch("Make ~Backup", BackupFlag), helpBackup)
)
.Item
(
Menu("~Search")
.Item(Command("~Find"), cmFind), helpFind)
.Item(Command("~Replace"), cmReplace), helpReplace)
.Separator()
.Item(Command("Find ~Again"), cmFindAgain), helpFindAgain)
)
)
Here cmXXX specifies the Action (or Message, as usual in GUIs), while
helpXXX specifies an optional help context for online help.
[...]
------------------------------
Date: 28 Apr 1997 19:12:51 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: PAGER (thanks)
Message-Id: <5k2srj$vok$1@dartvax.dartmouth.edu>
A 'thank you' to Tom Phoenix for pointing out a problem with the
following code:
$pager = $ENV{PAGER} || 'more'; # get preferred pager
open (PAGER, "| $pager") or *PAGER = *STDOUT;
He indicated that the code might not do what I expected if it couldn't
access the user's prefered pager. Looking at the perlfunc and perlipc
man pages, I discovered that open can't verify that the command for a
pipe actually exists. So, in the above code, if $pager refers to a
non-existent command, open will return success and the program will
receive a SIGPIPE when the pipe is used.
Now I need a way to distinguish between a SIGPIPE received because the
pager doesn't exist, and a SIGPIPE received because the user quit the
pager before viewing all the output.
Whee!
Chipmunk
------------------------------
Date: Mon, 28 Apr 1997 17:21:40 -0600
From: jase@cadence.com
Subject: Perl script crashes when filehandle is closed
Message-Id: <862265801.22305@dejanews.com>
I have a Perl script that needs to gather the stdout and stderr from an
external program, so I followed the example from the (old) version of the
Perl FAQ and created this subroutine for my script:
sub system_command {
local($cmd) = @_;
local($out) = "";
open (CMD, "($cmd | sed 's/^/STDOUT:/') 2>&1 |");
while (<CMD>) {
if (/^STDOUT:/) {
;
} else {
$out .= $_;
}
}
close(CMD);
return $out;
}
Every once in a while, the script will crash with the error "Attempt to
free unreferenced scalar ..." at the line where CMD is closed. Am I doing
something wrong? Is there a better way to do this?
Thanks for your input,
jase
--
/\ Jase P Wells, Scopus Administrator Email: jase@altagroup.com
/- \ Alta Business Unit of Cadence Direct: 408.523.8706 ____
/-- \ 555 North Mathilda Avenue Main: 408.733.1595 \ /
/______\ Sunnyvale, California 94086 Fax: 408.523.4601 \/
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Mon, 28 Apr 1997 18:38:04 -0400
From: Boris Kizelshteyn <boris@virtualf.com>
Subject: port from solaris to WinNT 4.0
Message-Id: <336526CC.2B71@virtualf.com>
Hi!
I'm porting a large perl system from PERL 4.0 on Solaris to PERL 5 on
WinNT 4.0. Can anyone provide me with useful sources of information (or
the information itself). Will my code be mostly compatible, any specific
things I should watch out for. Any information would be useful.
Thanks,
Boris Kizelshteyn
email: boris@virtualf.com
------------------------------
Date: Mon, 28 Apr 1997 18:12:26 -0500 (EST)
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: pre-RFD: comp.lang.perl.{data-structure,inter-process,porters,regex}
Message-Id: <eli$9704281812@qz.little-neck.ny.us>
Posted and mailed.
A. Deckers <I-hate-cyber-promo@man.ac.uk> wrote:
>Pre-RFD for additional clp.* groups.
>====================================
...
>The clp.* hierarchy that I envisage would look something as follows:
...
>+ m comp.lang.perl.regex Perl's regular expressions.
Given that there is not any other group for regexps I think this
would attract people with other regexp problems. For those reasons
I think just a general comp.lang.regex (or other suitable group)
would be better. Just MHO.
>For the clp.{data-structure,inter-process,regex} groups I envisage an
>automatic moderation system. The only restriction that will be applied is
As proposed it is interesting, but slightly flawed.
>In addition, the moderation software could reject any article that
>doesn't match /\bperl\b/i in either in the Subject header or in the
I see a lot of topical posts in clp.misc which fail that test. I
mean, "perl" is in the frigging group name, I see no reason to add
it when I ask <<Why doesn't
"s!(I([^i:.,]+(:[^:.,]*:)?)+(:[^:.,]*)?)[.,]([^i]*i)!$1 $5!;" ever
finish?>>
>In order to reduce propagation delays, I propose that the submission
>address should be a mailing list and that the moderation script should
>be made publically available. Thus, anyone can install the moderation
>script, create a mail alias, subscribe it to the mailing list, and
>start injecting articles into his or her local server.
Good, with one caveat, *you will want a way to prod people to update
the bot when bugs are fixed*. You should also plan now how the bot
should deal with cancels.
>This should actually *improve* propagation over the current situation. An
Yup.
>While this might create a single point of failure for the moderated
>groups, any delays introduced by server/network outages should be
I don't see any reason why the moderators file cannot specify a
comma seperated list of moderators, each of which is running a
mirror of the mailing list. Something similiar was recently proposed
by Seth Breidbart for the moderation of alt.spam.agis :^)
>It would probably be
>best if clp.misc remained unmoderated whatever happened.
I concur.
> ii- foisting spammers harvesting email addresses.
I'm on the "munging headers is of questionable value" side of this
issue. I only encourage it for cases with valid replyable addresses.
See my nearly-ready-to-be-a-true-FAQ Pre-FAQ (still collecting
answers) on email addressing:
<URL:http://www.netusa.net/~eli/faqs/addressing.html>
>Until a global solution to this problem becomes available, it will
Eg, convincing Phil Lawlor to stop spamming through AGIS. Ask your
newsadmin to carry alt.flame.phil-lawlor, moderated by Phil, per
the newgroup: <5jvnfd$6fd$1@nadine.teleport.com>
>0- whether this pre-RFD contains usefull ideas and whether they should be
>pursued further;
Yes.
>1- whether the proposed additional groups are well chosen, and if not,
>what the alternatives should be;
Mostly.
>2 - whether the names of the new groups are adequate, and if not, what the
>alternatives should be;
See previous.
>3- whether the proposed auto-moderation scheme seems adequate in
>principle, and if not, how it should be modified;
Somewhat so.
>4- whether the auto-moderation scheme should be extended to the existing
>clp.{modules,tk} groups.
Not yet.
>5- whether it is worth going to the trouble of setting up clp.porters, or
>if this will generate more costs than benefits. Since I don't participate
>on the porters mailing list (though I occasionally read the gated
>newsgroup), I will bow to whatever prevailing opinion emerges among
>those who do.
No comment.
>6- anything else that you want to say about this pre-RFD. :-)
See <eli$9704281812@qz.little-neck.ny.us>.
Elijah
------
[0] There is no zeroth footnote.[0]
------------------------------
Date: 28 Apr 1997 12:19:49 -0400
From: Tom Fawcett <fawcett.i-dont-like-spam@nynexst.com>
Subject: Re: problem: array assignment to hashref slice
Message-Id: <8jiv172k7u.fsf@nynexst.com>
Joe Marzot <gmarzot@baynetworks.com> writes:
> don't know if I'm missing something here
>
> I know I can say
> @hash{a,b,c,d} = (1,2,3,4);
>
> but how do I do this with a hashref?
$hashref={};
@{$hashref}{a,b,c,d} = (1,2,3,4);
for $key (keys %$hashref) {
print $key, ":", $hashref->{$key}, "\n";
}
------------------------------
Date: Tue, 29 Apr 1997 01:11:36 GMT
From: soccer@microserve.net (Geoffrey Hebert)
Subject: push or unshift simple question
Message-Id: <5k3gq7$pqk$1@news3.microserve.net>
I have one element I want to add to an array. I can do it several
others ways, But I can not seem to use push or unshift.
unshift @myarray $one_element;
I have two books that both use multiple eliment lists examples.
When I do what they say it works. But dumb me, I seem to be stuck in
the above format for a single addition.
------- signature ----------
Check out the Perl site!
http://www.microserve.net/~soccer/
use password perlmisc
Geat tool for Developers>
------------------------------
Date: Mon, 28 Apr 1997 16:38:18 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: raw input
Message-Id: <ac53k5.9t.ln@localhost>
Sascha Teske (slash@deil.de) wrote:
: Tad McClellan wrote:
: >
: > Chipmunk (Ronald.J.Kimball@dartmouth.edu) wrote:
: > : In article <5jpui7$q3b@info.abdn.ac.uk>
: > : junkmail@sysa.abdn.ac.uk (Kyzer) writes:
: >
: > : > Sascha Teske, while smelling of fish, wrote:
: > : > : I have a Problem i want to write an more intelligent chat and want to
: > : > : use perl is there a way to get data before or without a newline "amen" ?
: > : > : don't say RTFM to me, I DID !!!
: > : >
: > : but that's not what Sascha asked about. The problem is how to get data
: > : without having to wait for a newline.
: >
: > : I'd offer a suggestion here, but I haven't a clue how to do it. ;-)
: > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: >
: > read() or sysread() ?
: Can you give me an example so that i can see how to use
: read()||sysread()
: it could help me
there are several examples (of how to read without waiting for a newline)
in the Perl FAQ, part 5, under the question:
=head2 How can I read a single character from a file? from the keyboard?
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Mon, 28 Apr 1997 18:12:39 +0200
From: Cyril LAGUERRE <laguerre@cri.ensmp.fr>
Subject: redirection of STDERR
Message-Id: <3364CC77.41C67EA6@cri.ensmp.fr>
this is my cgi:
#! /usr/local/bin/perl
print "content-type:text/html\n\n";
open(FILE," sortie.txt");
$nomfichier='testregle7.pl';
open(SAVEOUT,">&STDOUT");
open(SAVEERR,">&STDERR");
open(STDOUT,"> sortie.txt");
open(STDERR,">&STDOUT");
`perl -cd $nomfichier`;
close(STDOUT);
close(STDERR);
open(STDOUT,">&SAVEOUT");
open(STDERR,">&SAVEERR");
if I use "perl cgi_name" ok, in sortie.txt I find the STDERR of my
command `perl...$nomfichier`
but if a html document runs my cgi with the form access, sortie.txt is
empty
My goal is to catch the error message of the command `perl..` with this
system.
------------------------------
Date: 28 Apr 1997 17:33:18 GMT
From: gerben@localhost.cs.vu.nl (Gerben Vos)
Subject: Re: Substitute File Path For URL
Message-Id: <5k2n0u$nh@star.cs.vu.nl>
stvsloan@longbow.com wrote:
>: $urlPath = "http://www.longbow.com/";
>: $filePath = "../html/";
>: $fn = $ENV{'HTTP_REFERER'}; #returns "http://www.longbow.com/filename.html"
>: ($fn = $fn) =~ tr/$urlPath/$filePath/; #want to return
>: "../html/filename.html"
Tad McClellan writes:
>Because you are using tr/// when you meant to use s/// ...
You may also want to quote the metacharacters in $urlPath:
$fn =~ s/\Q$urlPath/$filePath/;
^^ note the \Q
. . . . . . . . . . . . . . . . . . . . . . . . . . . G e r b e n V o s <><
mailto:gerben@cs.vu.nl http://www.cs.vu.nl/%7Egerben/
Never attribute to malloc that which can be adequately explained by stupidity.
------------------------------
Date: Mon, 28 Apr 1997 18:54:10 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ross Williamson <enzrowi@nzsf00.epa.ericsson.se>
Subject: Re: using modems from perl
Message-Id: <Pine.GSO.3.96.970428185026.12951A-100000@kelly.teleport.com>
On Mon, 28 Apr 1997, Ross Williamson wrote:
> I need some assistance. I am trying to write a perl script to
> do a simple set of commands to a modem.
You probably should start with section 8 of the new FAQ, which has the
answer to the question, "How do I read and write the serial port?" Hope
this helps!
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/perlfaq8.html
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/perlfaq8/How_do_I_re
ad_and_write_the_seri.html
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
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 387
*************************************