[21792] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3996 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 19 00:05:37 2002

Date: Fri, 18 Oct 2002 21:05:07 -0700 (PDT)
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, 18 Oct 2002     Volume: 10 Number: 3996

Today's topics:
    Re: About to tear my hair out here ... (Newbie Question <wsegrave@mindspring.com>
    Re: About to tear my hair out here ... (Newbie Question <REMOVEsdnCAPS@comcast.net>
    Re: About to tear my hair out here ... (Newbie Question <wsegrave@mindspring.com>
        Avoid errors when PMs can't be found (XML::Parser) ? <gerry1@dircon.co.uk>
    Re: can't terminate the script? ctcgag@hotmail.com
        Email w/ Attachment from form, via Sendmail (Mike)
        help - strange behaviour - 'use lib' + template toolkit <nuba@truta.dcc.ufmg.br>
    Re: icmp/udp question <troc@netrus.net>
    Re: Need advice on a project (wrt to tie'ing to a file  <bwalton@rochester.rr.com>
    Re: RFC: TraceScalar.pm <bobesch@letras.net>
    Re: RFC: TraceScalar.pm <bobesch@letras.net>
    Re: RFC: TraceScalar.pm <Tassilo.Parseval@post.rwth-aachen.de>
    Re: RFC: TraceScalar.pm <bobesch@letras.net>
    Re: Separating stdout and stderr <mike_constant@yahoo.com>
    Re: Separating stdout and stderr <garry@ifr.zvolve.net>
        Sleep(1) is not returning ? <storys@NOSPAM.charter.net>
    Re: Sleep(1) is not returning ? <bobesch@letras.net>
    Re: Sleep(1) is not returning ? <storys@NOSPAM.charter.net>
        using Perl & TXT as database <jwboer@netscape.net>
    Re: using Perl & TXT as database <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 18 Oct 2002 19:34:57 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: About to tear my hair out here ... (Newbie Question)
Message-Id: <aoq9n7$1nl$1@slb5.atl.mindspring.net>

"Michael Budash" <mbudash@sonic.net> wrote in message
news:mbudash-2DB1A7.12394918102002@typhoon.sonic.net...
> In article <495e297c.0210180814.441844@posting.google.com>,
>  simontheak@hotmail.com (Simon) wrote:
<snip>
> do yourself a favor and learn how to use the CGI perl module (among
> other techniques):
>

Mr. Budash shows you the way to use CGI.pm, object-oriented style, to
continue to write ugly HTML. IMO, part of the elegance and power of Dr.
Stein's CGI.pm module is that you can choose object-oriented or functional
style.


Mr. Budash wrote the following, which should do exactly whjat you've
requested, at least for single-valued parameters.
> #-----------------------------------------
> #!/usr/bin/perl -wT
>
> use strict;
> use CGI;
>
> my $cgi = CGI->new();
>
> print $cgi->header();
>
> print q|<html>
> <head><title>Test Page</title></head>
> <body>
> <h2>Hello, world!</h2>
> |;
>
> foreach ($cgi->param()) {
>   print "$_ : ", $cgi->param($_), "<br>\n";
> }
>
> print q|</body>
> </html>
> |;
>
> exit;
> #-----------------------------------------
>

Personally, I'd prefer something like the following for single valued
parameters (change the shebang line to suit your OS):

#!perl -w
# test_hello_params.pl - Test Page, Hello, World!, and Name=Value pairs
use strict;
use CGI qw(-no_xhtml :standard *pre);
print header, start_html('Test Page'), h2('Hello, world!'), hr, start_pre,
"\n",
"The Name = Value pairs you sent me are:\n\n";
foreach (param()) {print $_, ' = ', param($_), "\n"}
print end_pre, end_html;

Do you see how nice that looks compared to raw HTML?

> see: http://stein.cshl.org/WWW/software/CGI/
>
> the CGI module is included with the perl distribution, so you don't even
> have to install it...
>
> good luck!

Do spend at lot of time at Dr. Stein's site learing about CGI.pm. One of the
things you'll find there is that CGI.pm nicely handles multiple values for
the same name (See Dr. Stein's examples). A simple modification to the above
script makes it so it will display multiple values.

For multiple values, change the 'foreach' line above to:

foreach (param()) {print $_, ' = ', join(', ', param($_)), "\n"}

Good luck in your adventures with Perl and CGI.pm.

Bill Segraves







------------------------------

Date: Fri, 18 Oct 2002 20:08:35 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: About to tear my hair out here ... (Newbie Question)
Message-Id: <Xns92ABD71D15C67sdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"William Alexander Segraves" <wsegrave@mindspring.com> wrote in
news:aoq9n7$1nl$1@slb5.atl.mindspring.net: 

> "Michael Budash" <mbudash@sonic.net> wrote in message
> news:mbudash-2DB1A7.12394918102002@typhoon.sonic.net...
>> In article <495e297c.0210180814.441844@posting.google.com>,
>>  simontheak@hotmail.com (Simon) wrote:
> <snip>
>> do yourself a favor and learn how to use the CGI perl module (among
>> other techniques):
>>
> 
> Mr. Budash shows you the way to use CGI.pm, object-oriented style, to
> continue to write ugly HTML.

That's a matter of opinion.
 ...

> #!perl -w
> # test_hello_params.pl - Test Page, Hello, World!, and Name=Value
> pairs use strict;
> use CGI qw(-no_xhtml :standard *pre);
> print header, start_html('Test Page'), h2('Hello, world!'), hr,
> start_pre, "\n",
> "The Name = Value pairs you sent me are:\n\n";
> foreach (param()) {print $_, ' = ', param($_), "\n"}
> print end_pre, end_html;
> 
> Do you see how nice that looks compared to raw HTML?

Personally, I prefer my HTML to look like HTML.  When I'm using perl to 
generate code in other languages (eg: HTML, Javascript, PostScript, etc),
I like to see the output language for what it is. I think that constructs 
like:

    print table({-border=>1, -class=>'foo'}, TR([td('bar'), td('baz')]));

are much uglier and ultimately harder to read than

    print <<TAB;
<table border="1" class="foo"><tr><td>bar</td><td>baz</td></tr></table>
TAB
 
But hey, it's a matter of one's personal style and taste.

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPbCwnWPeouIeTNHoEQImpgCgse4i2wMDvRfA5pslXKY+zhqubywAnA87
VWaS7sNPq11pOp6XolVcM07O
=DA9i
-----END PGP SIGNATURE-----


------------------------------

Date: Fri, 18 Oct 2002 22:26:34 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: About to tear my hair out here ... (Newbie Question)
Message-Id: <aoqji7$v3o$1@slb6.atl.mindspring.net>

"Eric J. Roode" <REMOVEsdnCAPS@comcast.net> wrote in message
news:Xns92ABD71D15C67sdn.comcast@216.166.71.239...
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> "William Alexander Segraves" <wsegrave@mindspring.com> wrote in
> news:aoq9n7$1nl$1@slb5.atl.mindspring.net:
>
<snip>
> > Mr. Budash shows you the way to use CGI.pm, object-oriented style, to
> > continue to write ugly HTML.
>
> That's a matter of opinion.

Indeed it is. I should have stated it was my opinion.


I meant no disrespect, of course. It just seems a bit silly, IMO, to use
CGI.pm, but not use the shortcuts it provides.

<snip>

Gee, I hated snipping my own code. ;-)

> > Do you see how nice that looks compared to raw HTML?
>
> Personally, I prefer my HTML to look like HTML.  When I'm using perl to
> generate code in other languages (eg: HTML, Javascript, PostScript, etc),
> I like to see the output language for what it is. I think that constructs
> like:
>
>     print table({-border=>1, -class=>'foo'}, TR([td('bar'), td('baz')]));
>
> are much uglier and ultimately harder to read than
>
>     print <<TAB;
> <table border="1" class="foo"><tr><td>bar</td><td>baz</td></tr></table>
> TAB
>
> But hey, it's a matter of one's personal style and taste.

Yes. Indeed it is. OTOH, if I really wanted to know in detail the appearance
of the HTML, I could look at the HTML that CGI.pm generates.

Let us hope the OP will learn to use that which is most comfortable for him.

Thanks for your comments, Eric.

Bill Segraves




------------------------------

Date: Fri, 18 Oct 2002 23:58:03 +0100
From: Gerry Hickman <gerry1@dircon.co.uk>
Subject: Avoid errors when PMs can't be found (XML::Parser) ?
Message-Id: <3DB091FB.48284750@dircon.co.uk>

Hi,

I'm using AnyData.pm which calls XML::Parser and Parser tries to find
WeakRef and URI/URL, but unfortunately it's an ancient Cobalt box with a
buggy v2.26 Parser and no WeakRef. I can't update the Cobalt box, I
don't have TELNET and the admin won't do it.

I have erros routed to the browser at present from CGI::Carp but see
below:

Thing is the database works perfectly, but every rendered web page shows
three "fatal" errors related to the fact that XML::Parser can't find
it's PMs.

I can turn off "Carp qw(fatalsToBrowser)", but I'm worried these errors
will cause everything to run slower?

Is there any "clean" way I can stop XML::Parser from trying to load
these non-existant modules, or would it be possible to install new
versions of URI/URL and WeakRef in my custom lib path? The problem is
that Parser tries to load URI::URL instead of URI/URL.

-- 
Gerry Hickman (London UK)


------------------------------

Date: 18 Oct 2002 22:36:20 GMT
From: ctcgag@hotmail.com
Subject: Re: can't terminate the script?
Message-Id: <20021018183620.576$TG@newsreader.com>

"jackkon" <jackkon@ms29.url.com.tw> wrote:
> "Brian McCauley" <nobull@mail.com> ¼¶¼g©ó¶l¥ó
> news:u9y98xmd4e.fsf@wcl-l.bham.ac.uk...
> > "jackkon" <jackkon@ms29.url.com.tw> writes:
> >
> > What is probably wrong is your interpretation of what you are
> > observing. It has nothing whatever to do with Perl.
> >
> > You've not told us what you are observing only how you interpreted it.
> >
> > If your OS is Linux then see the Linux FAQ: "Why Is Free Memory as
> > Reported by free Shrinking?".
> >
> > If your OS is not Linux then see the Linux FAQ anyhow as the concept
> > is much the same for most Unix-like OSs.
>
> My OS is linux Mandrake 8.2
> but I use the ActivePerl, not the native perl while install
>
> When the script named rpm-qlp.pl  prints "Execute Over",
> I use the "top" command to watch the process,
> and I find the data below.
>
>   PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME COMMAND
>  1867 root      15   0  6220 1108   368 R     3.9  1.7  24:04 X
>  2379 jck1      12   0  2200  732   568 S     1.9  1.1  13:15 kdeinit
>  7136 jck1      19  19  2724 1416  1008 S N   1.9  2.2  17:33 krozat.kss
>  7425 jck1      17   0   668  512   340 R     1.7  0.8   0:01 top
>     5 root      10   0     0    0     0 SW    1.5  0.0   0:11 kswapd
>  7397 root      10   0 63508  46M 42768 R     0.5 77.2   0:31 rpm-qlp.pl
>
> It seems a little strange.
> But I don't know why.

Run the script from the command line without putting it in the background.
Is there a long gap between printing 'Execute Over' and when the shell
prompt returns?  Does the process disappear from top once the shell
returns on it's own?

I've noticed that when building large data structures, perl and/or the OS
spends an inordinate amount of time dicking around upon exit.  Often
it will take several times longer to exit than it took to build the data
structure and do all the processing.  Perhaps perl is trying to give memory
back to linux one bit at a time or something.  I get around it by
unbuffering STDOUT, printing 'Done' as the last act, then hitting ^C when I
see the 'Done'.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
                    Usenet Newsgroup Service


------------------------------

Date: 18 Oct 2002 19:30:07 -0700
From: csdude@hotmail.com (Mike)
Subject: Email w/ Attachment from form, via Sendmail
Message-Id: <46cdc619.0210181830.4ec73d6a@posting.google.com>

Hey, guys,

I'm almost brain-fried here, I've been beating my head against a wall
for two days on this one!

I have a form in which the visitor is allowed to include an image.
This image would be emailed to me, along with all of the other text
info. Simple enough, right?

Now, my website is being hosted remotely (Perl 5.6.0, on Unix), and
although they're considering it, at this time I do not have MIME::Lite
available (nor do I have MAIL::Sender). I do have CGI.pm (I think; the
list they gave me just says "CGI") and MIME::Entity, though, so that's
what I've been trying to work with to get this to work.

Here's the relevant code:

use CGI;
use MIME::Entity;

$image = param('image');
$upload = tmpFileName($image);
#I used to have tmpFileName(param('image')), but changed it to match
perldoc

$top = MIME::Entity->build(
	Type		=> "multipart/mixed",
	From		=> "$them",
	To		=> "$me",
	Subject		=> "Test"
);

$top->attach(
	Path		=> "$upload",
	Type		=> "image/gif",
	Encoding	=> "base64"
);

$top->attach( Data => $msg );

open (MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n";
	$top -> print(\*MAIL);
close MAIL;


If I change $upload to a file on the server (ie,
"/home/mydomain/www/file.gif") then there's no problem, but when I use
the above $upload, I get Internal Server Errors (oh, I forgot to
mention that the error log on my server isn't working; I just found
that out yesterday, and my host is working on it today). Am I using
tmpFileName correctly?

TIA,

Mike

PS, if all else fails, then with MIME::Lite not available, are there
any modules that come standard with Perl that can help me out of this
one? There are 369 modules installed, but I think they're all, or
mostly all, standard with Perl.


------------------------------

Date: Fri, 18 Oct 2002 23:41:01 +0000 (UTC)
From: Nuba <nuba@truta.dcc.ufmg.br>
Subject: help - strange behaviour - 'use lib' + template toolkit
Message-Id: <aoq66d$fm$1@dcc.ufmg.br>


Hi there

I am stuck and have no idea of where to look for:
Don't know if this is a 'Template Toolkit' or a 'use lib' issue.

I've developed a website using the 'template toolkit' module,
but my ISP's administrators refuse to add it to their perl
installation. I have no home or shell there, only FTP access to a 
virtualhost dir.

So I've uploaded the 'Template.pm' and the subdir 'Template' from
my local installation, and added the following line to the head of
my perl scripts: 

  use lib '/long/path/to/my/uploaded/lib/dir/and/subdirs';


And although now it doen't crashes when I have

  use Template;


inside of a script, later on, when I call

  my $template = Template->new($config);

the $template var remains undefinded, and produces
the following error to STDERR: 

  Can't call method "process" on an undefined value at script.pl line 142


Any hint on this will be greatly appreciated. 

Thanks in advance,

Nuba

-- 
         ,::::,                                                   
        ::    :    Nuba Rodrigues Princigalli    _____________    
        :. O-O:                                 |        '\\\\\\  
         :   >     Web Design and Development   |        ' ____|_ 
     ____\  - ._.   Computational Mathematics   |   +    '||::::::
   /'    \ -::' .'                              |        '||_____|
  /. ,-    O    < \               www.nuba.tk   '________|_____|  
 (\ <'     '  |\ / '-.___    nuba@dcc.ufmg.br   ___/____|___\___  
_.\__\________\_\___/), |\\____________________|    _    '  <<<:| 
                                               |_________'___o_o| 


------------------------------

Date: Sat, 19 Oct 2002 01:17:18 -0000
From: Rocco Caputo <troc@netrus.net>
Subject: Re: icmp/udp question
Message-Id: <slrnar1cks.8ma.troc@eyrie.homenet>

On Fri, 18 Oct 2002 21:04:24 GMT, smackdab wrote:
> For ICMP, I know I can use select() to see if there is any pending
> data on my socket.  Since I can use IO::Socket I am assuming that I
> can also use IO::Select instead of the select() call, right ?

IO::Select is just an object-oriented version of select().  It hides
the nitty-gritty vec() work necessary for working with select().  So
yes, you can use IO::Select wherever select() is appropriate.

> For UDP, I can't tell from my book if I can use select() or
> IO::Select...  It just mentiones that you can set an alarm in an
> eval {} block to timeout a recv().  Since I am on windows, I don't
> use alarm..

You can use select() (and by extension, IO::Select) with UDP.  No
alarm() is necessary.

> Assuming that select will work for UDP, can I set the sequence
> number with IO::Socket or do I need to manually create the packet ?

UDP packets have no sequence number of their own, so any sequence
number that your UDP packets have is supplied by you.

Yes, you can include the sequence number in whatever you're send()'ing
via UDP.  No, you won't need to build raw packets.

-- Rocco Caputo / troc@pobox.com / poe.perl.org / poe.sf.net


------------------------------

Date: Sat, 19 Oct 2002 00:03:51 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Need advice on a project (wrt to tie'ing to a file and general strategy)
Message-Id: <3DB0A145.2060401@rochester.rr.com>

Michele Dondi wrote:

 ...
> So, the first question regards how to calculate checksums with perl:
> do I have to resort to external programs (thus, possibly, having to
> use a Windows port of a *nix one for compatibility) or is there a
> (recommended) module suitable for this task?


Check out Digest::MD5.


> 
> Also, I know (more than) one way to make such a program, but an
> important consideration to take into account is that now I should run
> it on huge (for me) "data sets" (that is of the size of 10^5 files).


Check out the addfile method to Digest::MD5.  It is probably about as 
good a you will do for efficiency.


 ...


> Michele
> 

-- 
Bob Walton



------------------------------

Date: 19 Oct 2002 00:43:48 +0200
From: Bodo Schulze <bobesch@letras.net>
Subject: Re: RFC: TraceScalar.pm
Message-Id: <874rbjs6zf.fsf@letras.net>

"Stephen O. Lidie" <lusol@Pandora.cc.lehigh.edu> writes:

> Bodo Schulze <bobesch@letras.net> wrote:
> > Hi All,
> 
> > after lurking around here for a while, I would like to ask you for
> > some comment on a tiny module I wrote. It uses tie() to trace regex
> > substitutions operated on a scalar bound to TraceScalar. I found this
> 
> You might consider just using the CPAN module Tie::Watch and supply your
> custom callbacks.

That's true, but defining the callbacks involves pratically the same
work as writing the modules from scratch and it pulls in a lot of
code. Anyway, thank you for your comment.

Best regards, Bodo


------------------------------

Date: 19 Oct 2002 01:16:01 +0200
From: Bodo Schulze <bobesch@letras.net>
Subject: Re: RFC: TraceScalar.pm
Message-Id: <87zntbqqxa.fsf@letras.net>

"Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de> writes:


[snip]

> Looks nice. It seems to have a lite flavour of "use re 'debug'". 

I didn't know this. It really produces a lot of information.

> I also see enough room for additions later on. For instance it'd be
> nice if you could also track down substitutions that don't actually
> change anything (as the fourth of yours). This may be beyond the
> scope of tying though.  But perhaps with the help of a little XS it
> might be possible. Enough for your exploration. ;-)

Well, Perl is all I know a bit in programming, no C. Perhaps later.

> You require at least 5.6.0. Is there anything particular that wont run
> under older perls (except for use warnings of course)? 

I put this in, in case it doesn't work with older versions. I don't
know Perl prior to version 5.6.0.

Best regards, Bodo


------------------------------

Date: 19 Oct 2002 00:46:00 GMT
From: "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: RFC: TraceScalar.pm
Message-Id: <aoqa08$g7r$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Bodo Schulze:

> "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de> writes:
> 
> [snip]
> 
>> Looks nice. It seems to have a lite flavour of "use re 'debug'". 
> 
> I didn't know this. It really produces a lot of information.

Even too many, for my taste. I always need the explanations in the camel
to decipher its output.

>> I also see enough room for additions later on. For instance it'd be
>> nice if you could also track down substitutions that don't actually
>> change anything (as the fourth of yours). This may be beyond the
>> scope of tying though.  But perhaps with the help of a little XS it
>> might be possible. Enough for your exploration. ;-)
> 
> Well, Perl is all I know a bit in programming, no C. Perhaps later.

Get the Kernigham/Ritchie book, flick a little through it and after a
while tackle perlxstut, perlguts, perlapi and perlxs. It's like
re-learning Perl from a very different view. And one picks up C en
passant. Good thing about the Perl API is that it is usable without
being a C expert. Useful things can be done with surprising ease (though
some might argue about that).

>> You require at least 5.6.0. Is there anything particular that wont run
>> under older perls (except for use warnings of course)? 
> 
> I put this in, in case it doesn't work with older versions. I don't
> know Perl prior to version 5.6.0.

Thus you are on the safe side. But perhaps you also install an older
Perl (5.004 or 5.005) for testing. 5.8.0 is also obligatory. The
differences are subtle for most things, but often unexpected.

Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


------------------------------

Date: 19 Oct 2002 03:00:04 +0200
From: Bodo Schulze <bobesch@letras.net>
Subject: Re: RFC: TraceScalar.pm
Message-Id: <8765vz450r.fsf@letras.net>

"Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de> writes:

> Also sprach Bodo Schulze:

> > Well, Perl is all I know a bit in programming, no C. Perhaps later.
> 
> Get the Kernigham/Ritchie book, flick a little through it and after a
> while tackle perlxstut, perlguts, perlapi and perlxs. It's like
> re-learning Perl from a very different view. And one picks up C en
> passant. Good thing about the Perl API is that it is usable without
> being a C expert. Useful things can be done with surprising ease (though
> some might argue about that).

Re-learning Perl from a different view sounds interesting. I got this
on my TOLEARN list.

> >> You require at least 5.6.0. Is there anything particular that wont run
> >> under older perls (except for use warnings of course)? 
> > 
> > I put this in, in case it doesn't work with older versions. I don't
> > know Perl prior to version 5.6.0.
> 
> Thus you are on the safe side. But perhaps you also install an older
> Perl (5.004 or 5.005) for testing. 5.8.0 is also obligatory. The
> differences are subtle for most things, but often unexpected.

Looks like things are getting serious :)

Your comments are very much appreciated. Thanks a lot.

Best regards, Bodo


------------------------------

Date: Fri, 18 Oct 2002 15:21:17 -0700
From: "Newbie" <mike_constant@yahoo.com>
Subject: Re: Separating stdout and stderr
Message-Id: <aoq1go$p033h$1@ID-161864.news.dfncis.de>


"Vilmos Soti" <vilmos@vilmos.org> wrote in message
news:87adlbqug3.fsf@my.vilmos.lan...
> Hello,
>
> If I open a process with open, then is it possible somehow to access
> the process' stdout and stderr separately?
>
> open (X, "tar cvf /dev/nst0 /mydir");
> while (<X>) {
> whatever;
> }
> close (X);
>
> The problem here is that I get only stdout. If I put the "2>&1" to the
> appropriate place, then I get both, but I cannot distinguish between
> them.
>
> I tried to crate a fifo and send stderr to that fifo and read it
> later, but the whole program hanged.
>
> All I can do now is to redirect stderr to a physical file and read
> that file later. Is there a nicer solution?

Definitely. Check out IPC::Open3


>
> If both go to the same filehandle but they are prepended with
> sg like "stdout" or "stderr" then that would be perfect.
>
> Thanks, Vilmos




------------------------------

Date: Sat, 19 Oct 2002 01:09:36 GMT
From: Garry Williams <garry@ifr.zvolve.net>
Subject: Re: Separating stdout and stderr
Message-Id: <slrnar1bv8.dlt.garry@zfw.zvolve.net>

On 18 Oct 2002 14:59:56 -0700, Vilmos Soti <vilmos@vilmos.org> wrote:

> If I open a process with open, then is it possible somehow to access
> the process' stdout and stderr separately?


This a FAQ.  

  perldoc -q stderr
    "How can I capture STDERR from an external command?"

Also see IPC::Open3, but pay special attention to the "This is very
dangerous..." paragraph in that manual page.  Probably the FAQ answer
is best.  The FAQ claims it's answer is the "easiest and safest".  


> open (X, "tar cvf /dev/nst0 /mydir");


This doesn't look like copied code...

-- 
Garry Williams


------------------------------

Date: Fri, 18 Oct 2002 20:57:53 -0400
From: "Lenny Story" <storys@NOSPAM.charter.net>
Subject: Sleep(1) is not returning ?
Message-Id: <ur1bgk9o1na43c@corp.supernews.com>

Greetings,

For some strange reason the sleep calls in my perl code are not
returning.... for example...

printf("Starting..\n");

while(1)
{
    printf("+");
    sleep(1);
}

This code prints out the starting message but no others. Select seems to do
the
same thing....

I'm using perl 5.6.0  on SuSE linux 2.4.4 kernel...

anyone have any ideas ?

-Lenny




------------------------------

Date: 19 Oct 2002 03:31:54 +0200
From: Bodo Schulze <bobesch@letras.net>
Subject: Re: Sleep(1) is not returning ?
Message-Id: <871y6n43jp.fsf@letras.net>

"Lenny Story" <storys@NOSPAM.charter.net> writes:

> Greetings,
> 
> For some strange reason the sleep calls in my perl code are not
> returning.... for example...

It's not sleep that doesn't return, since in this case '+' should be
printed once.

> printf("Starting..\n");
> 
> while(1)
> {
>     printf("+");
>     sleep(1);
> }
> This code prints out the starting message but no others. Select seems to do
> the
> same thing....

printf, print and write are linebuffered when outputting to the
terminal. Since there is no newline within the loop, the output
doesn't get flushed. You may turn on 'command buffering' by setting 

        $| = 1

Then the buffered data gets flushed on every call to 'print' etc.

Best regards, Bodo


------------------------------

Date: Fri, 18 Oct 2002 22:11:18 -0400
From: "Lenny Story" <storys@NOSPAM.charter.net>
Subject: Re: Sleep(1) is not returning ?
Message-Id: <ur1fq8ngodv455@corp.supernews.com>

Greetings,

Hmm...well, your right...It works now..Surprising....that wasn't the
answer i expected.

Bodo, thank you for the response.
-Lenny

"Bodo Schulze" <bobesch@letras.net> wrote in message
news:871y6n43jp.fsf@letras.net...
> "Lenny Story" <storys@NOSPAM.charter.net> writes:
>
> > Greetings,
> >
> > For some strange reason the sleep calls in my perl code are not
> > returning.... for example...
>
> It's not sleep that doesn't return, since in this case '+' should be
> printed once.
>
> > printf("Starting..\n");
> >
> > while(1)
> > {
> >     printf("+");
> >     sleep(1);
> > }
> > This code prints out the starting message but no others. Select seems to
do
> > the
> > same thing....
>
> printf, print and write are linebuffered when outputting to the
> terminal. Since there is no newline within the loop, the output
> doesn't get flushed. You may turn on 'command buffering' by setting
>
>         $| = 1
>
> Then the buffered data gets flushed on every call to 'print' etc.
>
> Best regards, Bodo




------------------------------

Date: Sat, 19 Oct 2002 02:40:31 +0200
From: Boer <jwboer@netscape.net>
Subject: using Perl & TXT as database
Message-Id: <3DB0A9FF.4010709@netscape.net>

Hi
i recently built a Perl-driven relational database (just for the fun of 
programming), which uses text files to store records in. I actually have 
been using it now in a 'real life' situation, for a website with an 
average of 400 hits per day. It is very fast and doesn't seem to have 
problems.

My question: is it better to use a database like mySQL? I read somewhere 
that high traffic websites might cause problems when generating lots of 
disk access.
The advantage of using Perl-n-TXT is its speed.

Any thoughts about this?

JWB



------------------------------

Date: Sat, 19 Oct 2002 02:07:27 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: using Perl & TXT as database
Message-Id: <3DB0BE3D.2080300@rochester.rr.com>

Boer wrote:

 ...
> i recently built a Perl-driven relational database (just for the fun of 
> programming), which uses text files to store records in. I actually have 
> been using it now in a 'real life' situation, for a website with an 
> average of 400 hits per day. It is very fast and doesn't seem to have 
> problems.
> 
> My question: is it better to use a database like mySQL? I read somewhere 
> that high traffic websites might cause problems when generating lots of 
> disk access.
> The advantage of using Perl-n-TXT is its speed.
> 
> Any thoughts about this?
> 
> JWB
> 

The text-file version will be fine until you get a fair-sized chunk of 
data built up.  Then it will be way slow, and the SQL database will 
shine in comparison (if you use mod_perl or something so you don't have 
the connection overhead for every access).

BTW, you might try the DBI module with DBD-CSV.  That will let you use 
exactly the same program with CSV text files as with a full-blown SQL 
database (except for the connection bit).

-- 
Bob Walton



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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.

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 V10 Issue 3996
***************************************


home help back first fref pref prev next nref lref last post