[8020] in Perl-Users-Digest
Perl-Users Digest, Issue: 1645 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 15 10:07:55 1998
Date: Thu, 15 Jan 98 07:00:34 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 15 Jan 1998 Volume: 8 Number: 1645
Today's topics:
Re: basename with NT (Periat Henri)
Re: Can I create a Linked List in Perl draggs@hawkeye.idx.com
Re: Can Perl talk smtp protocol under NT4? (Jeffrey R. Drumm)
Chat script <msmit@aberdare.co.za>
Could use some perl help! (Marty Lebowitz)
Re: Creating a FoxPro database using Perl Scripts (Clay Irving)
Re: Displaying GIFs <jdporter@min.net>
Duplicating standard output/error (Samuel Ockman)
EMTY FILE? <jahnel@xarch.tu-graz.ac.at>
Re: Encrypting files with Perl. (Clay Irving)
Re: Ever modified Win NT registry with Perl? (Clay Irving)
Example of handling 2 STDIN 's? (Paul Ryder)
Find::file running slow <andrew.spiers@virgin.net>
Re: getting charecters from a variable <mat.r@ukonline.co.uk>
Re: Limiting simultaneous users (David Efflandt)
Re: Looking for online auction script <darny@it-tradesources.com>
Net::FTP <boschini@cilea.it>
Re: Net::FTP <gbarr@ti.com>
Re: Objects as keys for a hash table (Tye McQueen)
Re: Objects as keys for a hash table <jdporter@min.net>
Re: perl -- a language for LEARNING programming? notsew@wwa.com
Re: Perl running under Linus - #!/bin/usr (David Efflandt)
Re: perl under windows95 <peter@humansearch.com>
Re: Read STDERR from child? (Justin Vallon)
Re: Read STDERR from child? (David Efflandt)
Reading email via Perl <heikki.elenius@programmera.se>
Recursive mkdir() (Ed Avis)
Re: reg exp question (M.J.T. Guy)
Searching for bitypes.h <bidouye@club-internet.fr>
Re: Searching for bitypes.h (Vic Abell)
Re: sending emails with perl ? <buzz@bear.com>
Re: the -> operator <joseph@5sigma.com>
Training Slides dominic@shafika.vetri.com
Re: Using internal hooks to warn and die in Win32 Perl <nobody@nospam.nowhere.nospam.nowhere>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 Jan 1998 08:13:51 GMT
From: periat@ens.ascom.ch (Periat Henri)
Subject: Re: basename with NT
Message-Id: <69kgfv$l65@ascomax.hasler.ascom.ch>
In article <01bd20d9$d3243740$0c07000a@dns1.filnet.fr>, "Olivier" <PAYS@FILNET.fr> writes:
>I would like to use the same command as basename (UNIX)
>
>to obtain with a path like
>c:\folderA\folderB\file.txt -->file.txt
>
>This expression is not good why ???
>
>$base=($File=~m|.*/([^/]+)$|)
>
>P.S:I dont want to use cgi.pm
>
>Thanks
>
>Olivier ROBERT
>soil@filnet.fr
>
Salue Olivier
How about:
use File::Basename;
$base = &basename($File);
And you don't have to worry if your program runs on a UNIX or a M$ box.
Henri
-----------------------------------------------------------------------
Henri Periat Phone: 0041 32 624 35 78
Ascom Business Systems AG E-Mail: periat@ens.ascom.ch
Dep. 3578 Fax: 0041 32 624 31 56
Ziegelmattstr. 1
CH-4503 Solothurn
Switzerland
-----------------------------------------------------------------------
------------------------------
Date: Thu, 15 Jan 1998 14:12:43 GMT
From: draggs@hawkeye.idx.com
Subject: Re: Can I create a Linked List in Perl
Message-Id: <34be1839.3240236@news.idx.com>
On Wed, 14 Jan 1998 20:02:53 +0000, Ruben <ruben@wynn.com> wrote:
>You can create a linked list, but WHY would you want to if you have
>associative arrays which dynamically contain data.
>
>Ruben
First I'd like to thank eveyone who has responded so far to my
question. I greatly appreciate it.
In answer to the question of 'why?', the answer is that I have a
flat-file database to write. In C, its a matter of storing each
record into a linked list of structures.
I'm still working on figuring out the detail of the PERL version of
this. And additional suggestions or comments will be appreciated.
Thanks!
------------------------------
Date: Thu, 15 Jan 1998 13:33:27 GMT
From: drummj@mail.mmc.org (Jeffrey R. Drumm)
Subject: Re: Can Perl talk smtp protocol under NT4?
Message-Id: <34be0773.2914021090@news.mmc.org>
On Thu, 15 Jan 1998 07:22:49 +0100, martin@RADIOGAGA.HARZ.DE (Martin
Vorlaender) wrote:
(stuff deleted)
>These messages (or some other about being unable to find syscall.ph on my
>system) occur only if you don't specify the 'host' parameter with the
>Net::SMTP->new() method.
>
>In the CGI script of mine where I stumbled over this I just provided
>$ENV{SERVER_NAME}; since then, no more messages are bothering me.
>
>cu,
> Martin
I am specifying a target host in the new() method, but after re-reading the
Net::SMTP documentation I realized that you may have been thinking of the
"Hello" parameter for new(). I added that, and the error messages stopped. I
suspect that Graham would rather have this work "out-of-the-box", though.
Perhaps a note in the POD about adding a "Hello" parameter on NT is all that's
really required . . .
FWIW, Here's the code that works, with no errors to boot:
#!d:/perl5.04/bin/perl.exe -w
use strict;
use Net::SMTP;
my $mail_host = 'target.mmc.org';
my $hello = 'source.mmc.org';
my $from_addr = 'drummj@mail.mmc.org';
my $mail = Net::SMTP->new ($mail_host,
Hello => $hello,
Timeout => 30) or
die "Couldn\'t Connect to $mail_host\n";
$mail->mail ($from_addr);
$mail->recipient ("drummj\@$mail_host");
$mail->data ();
$mail->datasend ("To: drummj\@$mail_host\n");
$mail->datasend ("From: $from_addr\n");
$mail->datasend ("Subject: Hey, There!\n\n");
$mail->datasend ("I just love what you\'ve done with your hair.\n\n");
$mail->dataend ();
$mail->quit ()
__END__
--
Jeffrey R. Drumm, Systems Integration Specialist
Maine Medical Center - Medical Information Systems Group
420 Cumberland Ave, Portland, Maine 04101
Voice: 207-871-2150 Fax: 207-871-6501 Email: drummj@mail.mmc.org
------------------------------
Date: Thu, 15 Jan 1998 13:37:27 +0200
From: "Mike Smit" <msmit@aberdare.co.za>
Subject: Chat script
Message-Id: <69lalt$3oh$1@news.ibi.co.za>
I am writing a frames based chat system for our companys intranet. The
bottom frame is the form where the new message is input, and the top frame
is where all messages are displayed. The top frame calls a file called
readchat.PL every 5 secs automatically which reads a text file called
chatter.txt. This is where all messages are written to.
When submitting a message from the form, the form call writchat.PL which
appends the new text to chatter.txt, which it does correctly. the problem I
am having is that writchat.PL is sending a page back giving me a 500 error.
I don't need writchat.PL to send a page back, readchat.PL is doing the
necessary reading for me.
HOW DO I STOP WRITCHAT.PL FROM SENDING BACK!!!!!
All he needs to do is store the new info. THATS IT.
Any help would be appreciated.
Thanx - Mike
msmit@aberdare.co.za
------------------------------
Date: Thu, 15 Jan 1998 11:51:02 GMT
From: yi@world.std.com (Marty Lebowitz)
Subject: Could use some perl help!
Message-Id: <EMtq93.6vJ@world.std.com>
Anyone out there with perl knowledge able to help out by making a minor
mod (if its more, we can talk about it!), to an existing routine?
/ml
------------------------------
Date: 15 Jan 1998 09:48:06 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Creating a FoxPro database using Perl Scripts
Message-Id: <69l7j6$8t5@panix.com>
In <69jj59$ng9$1@garnet.nbnet.nb.ca> massong@nbnet.nb.ca (Gary Masson) writes:
>I haven't programmed to much with Perl, but I have a requirement to
>take a flat file and create a FoxPro database (for x86 based
>machines). Is there a module to add onto perl5 which will make this
>relatively possible, if not easy ?
You might want to take a look at Jan Pazdziora's DBD::XBase
http://www.perl.com/CPAN/authors/Jan_Pazdziora/
--
Clay Irving <clay@panix.com> I think, therefore I am. I think?
http://www.panix.com/~clay/
------------------------------
Date: Thu, 15 Jan 1998 08:19:00 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Displaying GIFs
Message-Id: <34BE0CC4.765E@min.net>
? the platypus {aka David Formosa} wrote:
>
> In <69h81o$1cb$1@comdyn.comdyn.com.au> mgjv@comdyn.com.au (Martien Verbruggen) writes:
>
> >In article <884737521.464702@cabal>,
> > ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au> writes:
>
> >> I think its more that he hasn't opened the file for output '<' nor has he
>
> >'<' is for input, and that is default if no specifier is given. He
> >doesn't need to open any output, because he's printing to STDOUT.
>
> Sorry braino, I meant "I think he hasn't open the file for input". The
> confistion arrised because the file is outputting into the perl program
> that is inputting the file into itself.
I'm not sure that this is the source of the confusion, but there is no
doubt that you are more than a little confused.
"outputting into the perl program"?
Your whole thing about "print <FILE>" makes me think you are using
Bizarro Perl.
Go read Learning Perl again.
John Porter
------------------------------
Date: 12 Jan 1998 00:25:44 GMT
From: ockman@var1.varesearch.com (Samuel Ockman)
Subject: Duplicating standard output/error
Message-Id: <slrn6bioof.gi1.ockman@var1.varesearch.com>
I'm working on a program where I ask a lot of questions, and then run a
lot of commands using system. After finishing asking the questions, I'd
like to get an exact copy of what is displayed on the screen (on both
stdout and stderr). It seems like the best way to do this would be to
alias stdout (and stderr) so they point to both themselves, and a file
open for writing. But I don't know how to do this. Anyone have any
ideas?
Thanks
Sam
--
New Linux Workstations available | Work Linux? | VA Research -
Dual Pentium II motherboard | Work with us. | Proud Corporate
Complete system starts < $2000 | e-mail jobs@ | Sponsor of Guerilla
http://www.varesearch.com | varesearch.com | Linux Development
------------------------------
Date: Thu, 15 Jan 1998 14:50:44 +0100
From: Jahnel Klaus <jahnel@xarch.tu-graz.ac.at>
Subject: EMTY FILE?
Message-Id: <34BE1434.F478E6F0@xarch.tu-graz.ac.at>
How can i test a file weather its empty or not (but not with the testing
of the file size)
TIA KLAUS
------------------------------
Date: 15 Jan 1998 09:50:56 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Encrypting files with Perl.
Message-Id: <69l7og$9cu@panix.com>
In <69jjc3$ng9$2@garnet.nbnet.nb.ca> massong@nbnet.nb.ca (Gary Masson) writes:
>On the same project I mentioned in my previous post (w/Foxpro
>databases) I would like to be able to encrypt (and decrypt) large
>binary files (they are self-extracting zips actually). Is their an
>encryption module available for perl?
Lots of 'em.
Check:
Perl Reference: security
http://reference.perl.com/query.cgi?security
--
Clay Irving <clay@panix.com> I think, therefore I am. I think?
http://www.panix.com/~clay/
------------------------------
Date: 15 Jan 1998 09:45:03 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Ever modified Win NT registry with Perl?
Message-Id: <69l7df$8lb@panix.com>
In <34BD2607.4C2E1060@email.sps.mot.com> Andrew Cowan <rxst50@email.sps.mot.com> writes:
>This is a multi-part message in MIME format.
>--------------C148D4E448BFD99AE23F697F
>Content-Type: text/plain; charset=us-ascii
>Content-Transfer-Encoding: 7bit
Eewww! MIME! You should turn this off or be prepared to suffer the scorn of
USENET readers.
>Anyone ever modified the Windows registry on NT 4.x using
>a perl script?
How about:
RegApp.pl
http://www.chipnet.cz/depot/perl.htm
A Perl script to add, change and delete registry entries without the
need to use RegEdit.
ObPlug: Found in Perl Reference <http://reference.perl.com>
--
Clay Irving <clay@panix.com> I think, therefore I am. I think?
http://www.panix.com/~clay/
------------------------------
Date: Thu, 15 Jan 1998 10:21:21 GMT
From: paul@f1world.com (Paul Ryder)
Subject: Example of handling 2 STDIN 's?
Message-Id: <34bee242.176758705@news.u-net.com>
Hi,
Can someone post an example of how I can listen for STDIN from a
socket connection and STDIN from the keyboard at the same time using
select?
Thanks in advance.
Plz email reply to paul@pry.u-net.com
_________________________________________________
Paul Ryder http://www.f1world.com
paul@pry.u-net.com ICQ : 262573
paul@f1world.com
paul@quake2.com
------------------------------
Date: Thu, 15 Jan 1998 07:56:27 +0000
From: Andrew Spiers <andrew.spiers@virgin.net>
Subject: Find::file running slow
Message-Id: <34BDC12B.5B58F00E@virgin.net>
Why when I run this script does it run ok :-
#!/usr/bin/perl
use File::Find;
use CGI qw(:standard);
print header(),
start_html("Directory Tree"),
h1("Directory Tree");
find (\&wanted, '/web');
sub wanted { return unless /htm/; push @ARGV, $File::Find::name; };
foreach $file (@ARGV) {
print pre("$file\n");
}
print end_html;
Yet when I add another print line after print pre("$file\n"); does the
sript take ages to run ?
Many Thanks
------------------------------
Date: 15 Jan 1998 09:04:28 GMT
From: "Matthew Robertson" <mat.r@ukonline.co.uk>
Subject: Re: getting charecters from a variable
Message-Id: <01bd2194$45795d60$1201010a@tipsytoad.ukonline.co.uk>
Problem solved.
Thanks for the help All
Mat
------------------------------
Date: Thu, 15 Jan 1998 10:57:13 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Limiting simultaneous users
Message-Id: <34bfe5c1.4524730@flood.xnet.com>
Rick Johnson <webmaster@worldgraphix.com> wrote:
>I am looking for a starting point to help me add a feature which will
>limit the number of users who can access a script at one time.
>
>I have a script which is basically a "classified ads script" but the
>number of users who are trying to access the script at the same time is
>so substantail that it seems to crash the script. Is there anyway to
>limit how many people can be in an area at the same time and return a
>message indicating the ads are unavailable at this moment, please try
>again later.
>
>Thanks!
>
>Rick
>webmaster@worldgraphix.com
Look up file locking (flock). I had a CGI script that would leave
zombies in an endless loop if more than one script tried to read the
same file at the same time. I used an alarm to cancel the script in
30 seconds, which worked until I figured out how to lock the file.
The problem with unlocked files may surface more with files accessed
one line at a time than if you read in the whole thing at once.
Otherwise 'seek' can help you keep track of where you are in a file if
different scripts access different parts of the same file at the same
time and move the file pointer (however, it specifies byte position
and not line number so you need to figure out from the line length
including any \r or \n where to seek next).
David Efflandt/Elgin, IL USA
efflandt@xnet.com http://www.xnet.com/~efflandt/
------------------------------
Date: Thu, 15 Jan 1998 16:00:03 +0800
From: Dar Ny <darny@it-tradesources.com>
Subject: Re: Looking for online auction script
Message-Id: <34BDC201.6F24282C@it-tradesources.com>
Martien Verbruggen wrote:
> In article <34BC8B21.E3809EC0@it-tradesources.com>,
> Dar Ny <darny@it-tradesources.com> writes:
> > Hi
> >
> > I'm looking over the internet for good auction script. but no luck.
> > anyone has the script??
>
> I suppose you mean a CGI script or application? Check out
> www.cgi-resources.com for that sort of stuff.
>
> CGI != perl, perl != CGI.
>
> Martien
> --
> Martien Verbruggen |
> Webmaster www.tradingpost.com.au | Inside every anarchy lurks an old boy
> Commercial Dynamics Pty. Ltd. | network - Mitchell Kapor
> NSW, Australia |
excuse me!
correct me if i'm wrong but cant cgi written in P E R L ? ? ?
darny
------------------------------
Date: Thu, 15 Jan 1998 09:51:37 +0100
From: Matteo Boschini <boschini@cilea.it>
Subject: Net::FTP
Message-Id: <34BDCE19.180E@cilea.it>
Hi everybody, I'm newbie to Net::FTP. Think it's great and I'm planning
to use for some applications. Anyway, I have a question.
the ftp->login('user','passwd') wants the user and password. Is there
an already exploited way of passing it an already en-cryp(3)ted passwd ?
I don't like the idea of having the scripts sitting around with
usid/passwd....
Already thanking for the help,
Matteo Boschini
------------------------------
Date: Thu, 15 Jan 1998 08:07:47 -0600
From: Graham Barr <gbarr@ti.com>
To: boschini@cilea.it
Subject: Re: Net::FTP
Message-Id: <34BE1833.A725B38C@ti.com>
Matteo Boschini wrote:
>
> Hi everybody, I'm newbie to Net::FTP. Think it's great and I'm planning
> to use for some applications. Anyway, I have a question.
> the ftp->login('user','passwd') wants the user and password. Is there
> an already exploited way of passing it an already en-cryp(3)ted passwd ?
> I don't like the idea of having the scripts sitting around with
> usid/passwd....
Well the FTP protocol uses clear-text passwords, so encrypting it
will not help as your script will have to decrypt it before sending it
to the server.
You could use a .netrc file to store the information and call
$ftp->login() without any arguments. Normally (well on unix)
a .netrc can only be read by the owner so it has some basic
security, but do not be fooled into thinking that is totally
secure.
Graham.
--
Originality is the ability to conceal your source.
------------------------------
Date: 14 Jan 1998 19:25:05 -0600
From: tyde@medtrodnet.cdom (Tye McQueen)
Subject: Re: Objects as keys for a hash table
Message-Id: <69johh$9nc@fiinix.metronet.com>
Keywords: from just another new york perl hacker
) Allen Choy <achoy@us.oracle.com> posted:
) >I cached a list of objects using a hash table, with the objects as
) >keys. When
) >I try to retrieve the objects via key %hash, I get the objects, but
) >they're no
) >longer objects. Is this the intended behavior? And how does anyone
) >have
) >a decent workaround for this?
foreach $thing ( @things ) {
$obj= new MyClass $thing;
$cache{$obj}= $obj;
}
...
foreach $key ( keys(%cache) ) {
$obj= $cache{$key};
...
}
If you really needed the %cache hash to contain something
else for values, then use the "standard" synchronized array
and hash method:
foreach $thing ( @things ) {
$obj= new MyClass $thing;
push( @cache, $obj );
$cache{$obj}= $thing;
}
...
foreach $obj ( @cache ) {
$thing= $cache{$obj};
...
}
which has the advantage of keeping your objects in their
original order.
--
Tye McQueen Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
Remove d's from address to reply (sorry for the inconvenience).
------------------------------
Date: Thu, 15 Jan 1998 08:53:26 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Objects as keys for a hash table
Message-Id: <34BE14D6.6587@min.net>
Allen Choy wrote:
>
> I cached a list of objects using a hash table, with the objects as
> keys. When
> I try to retrieve the objects via key %hash, I get the objects, but
> they're no
> longer objects. Is this the intended behavior? And how does anyone
> have
> a decent workaround for this?
See page 256 in the Camel,
"Hard References Don't Work as Hash Keys",
for an intro to this topic.
Also, the FAQ, section 4, "Data: Hashes" addresses this by
pointing you to the Tie::Hash module.
hth,
John Porter
------------------------------
Date: Thu, 15 Jan 1998 14:28:11 GMT
From: notsew@wwa.com
Subject: Re: perl -- a language for LEARNING programming?
Message-Id: <34be1b56.342812@news.wwa.com>
what i'm wondering, i guess, is whether my knowledge of perl (and
other languages, many of whose basic constructs derive from c/c++)
would be enough to get me through some of the "theory" i'm interested
in learning. should i pick up a book in data structures, for example,
where examples are given entirely in c, would i be lost, or would
things in essence look pretty familiar? i mean, a for loop is a for
loop. similarly, would i be able to convince a professor (whose
consent i'd need to take his class without the requisite c/c++
knowledge) of as much?
------------------------------
Date: Thu, 15 Jan 1998 10:29:06 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Perl running under Linus - #!/bin/usr
Message-Id: <34bedffb.3046833@flood.xnet.com>
grsshpper@feedME wrote:
>I have a question that relates to Perl running under Linux.
>
>As I understand things, the first line in a perl program
>in Linux should be #!/bin/usr/perl so that when the perl
>script is called, Linux knows it has to direct the lines
>following to the perl program at /bin/usr
You are just a bit turned around. If you type 'which perl' or 'type
perl' in the shell, you will like find that the correct first line in
Linux it is (whitespace optional between '#!' and path):
#!/usr/bin/perl
>If this setup is functioning correctly, then if I have a
>perl script called say "testpl.pl" for example, then all
>I have to do is type in testpl.pl at the prompt, and the
>perl program at /bin/usr will execute it.
You also need to 'chmod 755 testpl.pl' (type 'man chmod' for more
info). Also the current directory is NOT automatically in your path
like DOS so if there is no dot (.) in your path, you need to run the
script as './testpl.pl'.
>The only problem is... it's not working, at least not on
>my Linux system. Please note that I CAN execute perl
>programs by typing perl testpl.pl
>However shouldn't I be able to execute scripts without
>specifically invoking perl ?
>Note that I do have the location /usr/bin on my $PATH
>variable, so the system should be able to find perl.
>In fact it DOES find it because perl testpl.pl works ...
>
>Am I wrong about the effect of the #!/bin/usr/perl
>statement ?
Yes, since you just said perl is in /usr/bin (not /bin/usr).
>Is there a setting in my profile or somewhere else I
>should add or change ? or is there something else I am
>doing wrong ?
You can add the dot to your path in profile. But if you use an editor
that wordwraps like 'pico' either use the -w switch to turn off
wordwrap or suck the path all back into one line.
Some people do not recommend having dot in your path because you may
end up running a different program or script than you intended if
there is one of the same name higher up in your path (like 'test').
David Efflandt/Elgin, IL USA
efflandt@xnet.com http://www.xnet.com/~efflandt/
------------------------------
Date: Thu, 15 Jan 1998 09:19:47 -0500
From: "Peter D. Kovacs" <peter@humansearch.com>
Subject: Re: perl under windows95
Message-Id: <34BE1B02.5FFEB6D9@humansearch.com>
> The other way is to search the net for PFE - The Programmer's File Editor.
> Then, you - ie it - can run perl <scriptName> in 1 DOS box and capture the output in another.
> Or try the author at: http://www.lancs.ac.uk/people/cpaap/pfe.
Yeah, PFE is definitely a good choice. If you have a few bucks UltraEdit is better:
http://www.ultraedit.com
It also supports capturing the output of a perl session.
Peter Kovacs
------------------------------
Date: Thu, 15 Jan 1998 05:01:57 -0500
From: vallon@mindspring.com (Justin Vallon)
Subject: Re: Read STDERR from child?
Message-Id: <19980115050157595412@user-37kb61r.dialup.mindspring.com>
Robb Kambic <rkambic@unidata.ucar.edu> wrote:
> Here's a simple way of catching STDERR from a subprocess, redirect it
> to STDOUT.
> Because perl uses borne shell like syntax 2>&1 in system calls.
>
> ( @output ) = `pqact -vl - -q /dev/null $pqact_conf 2>&1` ;
Since STDERR (apparently) is not redirected by ``, try sending STDOUT to
STDERR and STDERR to STDOUT (check the man pages on sh/ksh which I do
not have access to at the moment):
local $stderr = `xyz >3 2>&1 3>&2 3>-`;
# Run xyz with the following redirections (order matters):
# 1) Make fd3 output to the same as stdout.
# 2) Send fd2 (stderr) output to fd1 (stdout).
# 3) Send fd3 (same as orig stdout) to fd2 (old stderr)
# 4) Close fd3
stdout should go to perl's stdout, and $stderr should capture the stderr
of xyz.
Option 2: Use IPC::Pipe3. It gives you STDIN, STDOUT, STDERR, and you
can do the nitty-gritty of select(), then print things from STDOUT, and
capture things from STDERR.
--
-Justin
vallon@mindspring.com
------------------------------
Date: Thu, 15 Jan 1998 10:03:34 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Read STDERR from child?
Message-Id: <34bdd730.795262@flood.xnet.com>
rkambic@unidata.ucar.edu (Robb Kambic) wrote:
>In article <34bcce76.642189@flood.xnet.com>,
> efflandt@xnet.com (David Efflandt) writes:
>> I cannot seem to find in man pages or Programming Perl how to read
>> STDERR from a child process (in Linux). I am attempting to use a
>> 'dialog' menu. STDIN and STDOUT should remain normal.
>>
>> I can get the results of a yesno dialog because it simply uses the
>> exit code. But a dialog --menu puts the menu selection in STDERR and
>> it now just displays on the screen at the last cursor position. How
>> do I read this into my script instead?
>
>David,
>
>Here's a simple way of catching STDERR from a subprocess, redirect it to STDOUT.
>Because perl uses borne shell like syntax 2>&1 in system calls.
>
>( @output ) = `pqact -vl - -q /dev/null $pqact_conf 2>&1` ;
>
>The only problem you might have is determining what output is from STDOUT
>verses STDERR.
>
>Robb...
Doesn't work because you would get no interactive menu display to
select from. STDOUT has to go to the screen to display the menu,
STDIN needs keyboard to highlight a menu selection with cursor keys
and the only thing I am trying to trap is STDERR which does not come
until all of the above.
It does work running it through an external script which redirects its
STDERR to a file. Just wondering if there is a way to do it more
directly instead of running it though a couple of external files.
Maybe open3 would work, but I do not know much about pipes and it
might be less portable. This is what I came up with so far:
#!/usr/bin/perl
$menufile = "/tmp/dmenu.$$";
$optfile = "/tmp/dopt.$$";
$menu = 'dialog --title "Menu Test" --menu "Select One" 10 26 3'
. ' "Red" "Blood" "Green" "Tree" "Blue" "Sky" ' . "2\>$optfile";
open(OUT, ">$menufile") or die "Can't open $menufile: $!\n";
print OUT "$menu\n";
close OUT;
chmod 0755, $menufile;
system ($menufile);
print "\nDialog return code: $?\n";
open (IN, "<$optfile") or die "Can't open $optfile: $!\n";
$option = <IN>;
close IN;
print "Menu option: $option\n";
unlink $menufile, $optfile;
David Efflandt/Elgin, IL USA
efflandt@xnet.com http://www.xnet.com/~efflandt/
------------------------------
Date: Thu, 15 Jan 1998 13:43:51 +0100
From: Heikki Elenius <heikki.elenius@programmera.se>
Subject: Reading email via Perl
Message-Id: <34BE0487.485B@programmera.se>
Hi,
is there anyway to read email on a pop3 server using Perl?
I'm looking for a script similar to the one used by Hotmail.
If you have any ideas about this, please reply both to the
group and by email.
Thanks in advance,
Heikki
------------------------------
Date: Thu, 15 Jan 1998 14:36:28 GMT
From: epa@datcon.co.uk (Ed Avis)
Subject: Recursive mkdir()
Message-Id: <34be1e8b.11342109@news-direct>
Many versions of mkdir(1) have a -p flag to create all directories in
a specified path. For example
mkdir -p foo/bar/baz
works, creating directories foo and bar if they do not already exist.
Is there a feature like this in Perl?
TIA,
--
Ed Avis
------------------------------
Date: 15 Jan 1998 12:31:07 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: reg exp question
Message-Id: <69kvib$4i2$1@lyra.csx.cam.ac.uk>
Ian Goldstein <nygsi@ny.ubs.com> wrote:
>I want to extract all instances of duplicate consecutive
>characters from a string. I came up with a simple algorithm,
>but was wondering if there was a "shorter" method.
You don't need a loop, or a regular expression.
To remove consecutive identical characters,
tr/\000-\377//s
If you only want to compress lower case letters,
tr/a-z//s;
does the same as your code.
Mike Guy
------------------------------
Date: Thu, 15 Jan 1998 11:44:56 +0000
From: STOCK Fridiric <bidouye@club-internet.fr>
Subject: Searching for bitypes.h
Message-Id: <34BDF6B8.B49@club-internet.fr>
Hello,
I'm trying to compile Perl5.003 under Sco Unix R3.2V4.2 with Gcc
2.7.2.2, and I don't have sys/bitypes.h, which is required at make
command for Socket.c, in include file arpa/inet.h
Where could I get it ?
Thanks
--
00 00
Fridiric STOCK
00 00
------------------------------
Date: 15 Jan 1998 12:53:01 GMT
From: abe@cc.purdue.edu (Vic Abell)
Subject: Re: Searching for bitypes.h
Message-Id: <69l0rd$pc@mozo.cc.purdue.edu>
STOCK Fridiric <bidouye@club-internet.fr> writes:
>I'm trying to compile Perl5.003 under Sco Unix R3.2V4.2 with Gcc
>2.7.2.2, and I don't have sys/bitypes.h, which is required at make
>command for Socket.c, in include file arpa/inet.h
>Where could I get it ?
It sounds like you may have the BIND version of <arpa/inet.h>, not
the one distributed by SCO. The standard <arpa/inet.h> from SCO
for 3.2v4.2 doesn't #include <sys/bittypes.h> (It doesn't #include
anything.), while the one that BIND can install, unless instructed
otherwise, has this pre-processor sequence:
#if (!defined(BSD)) || (BSD < 199306)
# include <sys/bitypes.h>
#else
# include <sys/types.h>
#endif
Usually BIND also installs a <sys/bitypes.h> so that this sequence
works.
Vic Abell <abe@purdue.edu>
------------------------------
Date: Thu, 15 Jan 1998 09:34:02 -0500
From: Buzz Moschetti <buzz@bear.com>
Subject: Re: sending emails with perl ?
Message-Id: <34BE1E5A.11C7@bear.com>
Pascal PERRY wrote:
>
> memeier@bene.baynet.de wrote:
> >
> > Hi !
> > Can anybody tell me how send emails with perl-scripts ?
> >
> > Mike
>
> 1) Create a socket localy with socket()
> 2) Connect to a remote SMTP server with connect()
> [...]
Personally, I prefer the Mail::Mailer module:
use Mail::Mailer;
$msg = new Mail::Mailer;
$headers = {
'To' =>[ qw(buzz) ],
'From' =>[ (buzz) ],
'Subject' =>[ ("This is the subject") ]
};
$msg->open($headers);
print $msg "your message\n"; # Note the CR
print $msg <<EOS;
A nice way to do a block of
boilerplate text.
EOS
$msg->close; # close will send it
------------------------------
Date: Thu, 15 Jan 1998 02:42:28 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: the -> operator
Message-Id: <34BDD9DD.6830365D@5sigma.com>
One might think so.
@a->[0] = 42;
print "@a\n";
%a->{'test'} = 42;
print keys(%a), "\n";
-joseph
http://www.effectiveperl.com
Brian Wheeler wrote:
> yes. the -> will pass whatever's on the left of the ->. It has to
> be either a class name or a blessed reference.
------------------------------
Date: Thu, 15 Jan 1998 05:12:01 -0600
From: dominic@shafika.vetri.com
Subject: Training Slides
Message-Id: <884862282.1162739713@dejanews.com>
Hello Perlians,
Is anyone in the list willing to share his Perl training Sildes with me?
Or kindly point me to a place where I can find the Slides with lot of
Perl examples.
Thanks and Regards
Dominic
________________________________________________________
For Win32Perl Mail Archive-Visit (6000 mails)
http://www.geocities.com/SiliconValley/Heights/9736
________________________________________________________
A. Dominic, Project Leader, Work: +91 44 8256755
Vetri Software (India) Ltd. Home: +91 44 4925590
#7 Kodambakum High Road,
Madras, India 600 034
Email: dominic@shafika.vetri.com
http://www.geocities.com/SiliconValley/Heights/9736
________________________________________________________
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 13 Jan 1998 17:27:19 GMT
From: POJ <nobody@nospam.nowhere.nospam.nowhere>
Subject: Re: Using internal hooks to warn and die in Win32 Perl
Message-Id: <69g85n$s74$1@vega.lejonet.se>
Hi,
I consider the event logging in Windows NT to be somewhat
restricted. An ordinary application may choose one of three
event types for each logged event. The types are 'Information',
'Warning' and 'Error'.
Event types on a trace or debug level are missing. It might be
helpful to turn on tracing in an application, and use it for
error searching. Similarly, a debug level could be useful.
Best regards,
Per-Ove Jakobsson
Please don't mail answers; post a follow up instead.
------------------------------
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 1645
**************************************