[25429] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7674 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 19 18:10:24 2005

Date: Wed, 19 Jan 2005 15:10:15 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 19 Jan 2005     Volume: 10 Number: 7674

Today's topics:
    Re: Perl and waiting for execution of external program <noreply@gunnar.cc>
    Re: Perl and waiting for execution of external program xhoster@gmail.com
        perl rfc-3676 <terrylr@blauedonau.com>
    Re: Perl6 book ioneabu@yahoo.com
        switching to extended character set using curses & perl someone92@hotmail.com
    Re: system command on Win98 <mikeflan@earthlink.net>
        The array ARGV <carlton_gregory@yahoo.com>
    Re: The array ARGV <1usa@llenroc.ude.invalid>
    Re: The array ARGV <jl_post@hotmail.com>
    Re: The array ARGV <carlton_gregory@yahoo.com>
    Re: The world's shortest 'Hello World!' program: a prop <responder_solo_en_el_grupo@yahoo.es>
    Re: The world's shortest 'Hello World!' program: a prop <bik.mido@tiscalinet.it>
    Re: The world's shortest 'Hello World!' program: a prop <bik.mido@tiscalinet.it>
    Re: Usage of File::Find <bik.mido@tiscalinet.it>
    Re: Why doesn't this work? <bik.mido@tiscalinet.it>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 19 Jan 2005 18:58:12 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Perl and waiting for execution of external program
Message-Id: <357lajF4jdgsjU1@individual.net>

jonas.andersson@rocketmail.com wrote:
>>How is the program invoked? Is it possibly run as a CGI script?
> 
> You are correct: it is run as a CGI script. Sorry for not mentioning
> that.

Well, then it's the browser or the CGI process that times out, not Perl, 
so that piece of info is essential.

There are various ways to deal with this problem. A simple method, that 
works in some cases, is to flush STDOUT:

     $| = 1;

and keep the process alive by having the program print something to 
STDOUT once in a while during the calculation.

If you are looking for a more comprehensive answer, you'd better try a 
newsgroup that deals with CGI, for instance 
comp.infosystems.www.authoring.cgi

HTH

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 19 Jan 2005 19:22:43 GMT
From: xhoster@gmail.com
Subject: Re: Perl and waiting for execution of external program
Message-Id: <20050119142243.193$rb@newsreader.com>

jonas.andersson@rocketmail.com wrote:
> Hi,
>
> Sometimes, when running an external program through Perl, I run into
> problems:
>
> ...
> open (PROG, "|$MyProgram &> /dev/null") or die "cannot open
> program"
>
> print PROG "Load file $FileName\n";
> print PROG "Calculate all\n";
>
> close (PROG) or die "cannot close program";
> ...
>
> It sometimes happens that Perl does not wait for the (lengthy)
> calculations to finish, but tries to close the program prematurely. (At
> least, that is what the symptoms look like).
>
> Is there a way to force Perl to wait for the program to finish before
> it tries to close it, however long it takes?

Most likely your http server is getting impatient and clobbering your
Perl script.  One possible non-Perl solution is to make your http server
more patient.  Another possible solutions is to have your Perl program
fork, have the parent finish pronto, while the child (after closing STDOUT)
keeps going, safe from the wrath of impatient http server.  The problem
then is that the web browser sees the results of the parent's output, and
not the child's.  If the child's results need to get to the web browser,
you will have to arrange for that rendovous yourself.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Wed, 19 Jan 2005 14:11:00 -0600
From: "terry l. ridder" <terrylr@blauedonau.com>
Subject: perl rfc-3676
Message-Id: <Pine.LNX.4.61.0501191407040.23192@johann.blauedonau.com>

hello;

i have all ready search cpan.org and did not find anything that
referenced rfc-3676. would anyone know if there is any perl modules
and/or scripts which would rewrite the messages, header and body, to be
rfc-3676 compliant?


-- 
terry l. ridder ><>


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

Date: 19 Jan 2005 08:08:29 -0800
From: ioneabu@yahoo.com
Subject: Re: Perl6 book
Message-Id: <1106150909.180891.68380@c13g2000cwb.googlegroups.com>


> I did not buy the first edition of the book; I waited for the second.
> I do not regret buying it.  Are you going to use it to implement
> production code in Perl 6?  No.  But if you haven't had the time to
> keep up with the development of Perl 6 as reported in the weekly
> summaries, the second edition gives you a good starting point.  I,
for
> one, found it a considerably more challenging read than I would have
> expected.
>
> Jim Keenan

I just want to get a feel for what Perl 6 is all about.  I came into
Perl so late as it is, maybe getting in on the ground floor of 6 will
make me feel more at home.

Can anyone recommend links to some good starter information?  I went to
the Perl 6 site and ended up reading a bunch of speeches by Larry Wall
and some really vague stuff about Perl 6.

Thanks!

wana



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

Date: 19 Jan 2005 14:45:13 -0800
From: someone92@hotmail.com
Subject: switching to extended character set using curses & perl
Message-Id: <1106174713.225835.186350@c13g2000cwb.googlegroups.com>

Hi,
I'm writing a perl program that needs to draw lines and other special
characters on the screen. I'm using curses to design my user interface.
I'm been trying for a while to figure out how to change to the extended
character set using curses without any success. I'm using FreeBSD 4.10
(VT320 terminal)

I'm able to switch to ecs without curses this way
print ("\e(0");
print ("qqqqq"); #works really draw a line

but if I try to print an escape sequence using curses's addstr it will
be printed on screen, so it doesn't work. And it seems that perl's
curses module doesn't support addrawch (which could have been useful)

I also tried what I thought was the solution to my problem but I was
really suprised that it doesn't work :

Curses::initscr;
Curses::attrset(A_ALTCHARSET);
$c="qqqqqqqqqqq";
Curses::addstr ($c);
Curses::refresh;
Curses::endwin;

Curses doesn't seems to switch to ecs

I found this quotes on the newsgroups:
"The attrset(A_ALTCHARSET) will use terminfo capabilties to switch to
the alternate character set.  To use this successfully, the terminfo
entry for your terminal must define 'smacs' (start alternate character
set), 'rmacs' (end alternate character set) capabilities.  In addition,
the 'sgr' capability definition should implement the '%9' flag for
alternate character set."

is it true? I only found /etc/termcap on my FreeBSD system and nothing
about smacs and rmacs in it. 

Anyone can help me ? thanks in advance



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

Date: Wed, 19 Jan 2005 16:51:36 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: system command on Win98
Message-Id: <41EE90AC.2AF65675@earthlink.net>


Michele Dondi wrote:

snip

> Did you create a scripting language? Not to underestimate you, but
> language design in general is not a trivial task, you know...

No, it is a commercial package.  It mostly just sends
various keystrokes to programs (windows).  Alt s -
Ctrl n - etc.  It has some other functions too, but I
mostly use it to send keystrokes.  I can generally
do it's other functions with Perl.

I suspect there is a Perl way to send the keystrokes too.
In fact I suspect Win32::CtrlGUI::Window would do
everything I need.  I need to learn that module and
throw away that commercial scripting language package.


Mike




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

Date: 19 Jan 2005 13:34:18 -0800
From: "g3000" <carlton_gregory@yahoo.com>
Subject: The array ARGV
Message-Id: <1106170458.765259.129850@z14g2000cwz.googlegroups.com>

I have read that the array ARGV holds the command line arguments.

is there a way to pass a hash ( list ) as an argument on the command
line?

I know in a sub routine @_ can be a hash.

But I want to do something like

myprogram.pl (key1=>'value1',key2=>'value2')

and inside the sub in my program be able to
sub1
{
my %options = @_;
 ....
}
when I have a call at the end being
sub1(@ARGV);

dont think it can be done but I just want to be positive.



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

Date: 19 Jan 2005 21:42:39 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: The array ARGV
Message-Id: <Xns95E3AA041650Aasu1cornelledu@132.236.56.8>

"g3000" <carlton_gregory@yahoo.com> wrote in 
news:1106170458.765259.129850@z14g2000cwz.googlegroups.com:

> I have read that the array ARGV holds the command line arguments.

It is @ARGV. ARGV is a bareword.

> is there a way to pass a hash ( list ) as an argument on the command
> line?

Huh?

What makes you think the shell knows about hashes etc?

Is this what you are asking?

#! /usr/bin/perl

use strict;
use warnings;

use Data::Dumper;

mydumper(@ARGV);

sub mydumper {  print Dumper { @_ }; }

__END__

C:\Home> c.pl key1 value1 key2 value2 sdlkfj ewruh
$VAR1 = {
          'key2' => 'value2',
          'key1' => 'value1',
          'sdlkfj' => 'ewruh'
        };

> I know in a sub routine @_ can be a hash.

That is a non-sensical statement. Please read

perldoc perlsub

> when I have a call at the end being
> sub1(@ARGV);
> 
> dont think it can be done but I just want to be positive.

If I understood you right, of course 'it' can be done. @ARGV is an array 
just like any other array. You can initialize the keys and values of a 
hash from it the same way you would with any other array.

Sinan.


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

Date: 19 Jan 2005 13:46:43 -0800
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: The array ARGV
Message-Id: <1106171203.116253.57450@f14g2000cwb.googlegroups.com>

g3000 wrote:
>
> I have read that the array ARGV holds the
> command line arguments.
>
> is there a way to pass a hash ( list ) as
> an argument on the command line?


Sure.  Use this program:


| #!/usr/bin/perl
| use strict;
| use warnings;
|
| sub sub1
| {
|    my %options = @_;
|
|    use Data::Dumper;
|    print Dumper \%options;
| }
|
| sub1(@ARGV);
|
| __END__


and call it like this:

myprogram.pl key1 value1 key2 value2

This will set the %options hash to (key1 => 'value1', key2 =>
'value2').

(Just make sure that you pass in an even number of arguments, or else
you'll get a complaint like:

Odd number of elements in hash assignment...
)

   I hope this helps.

   -- Jean-Luc



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

Date: 19 Jan 2005 13:57:39 -0800
From: "g3000" <carlton_gregory@yahoo.com>
Subject: Re: The array ARGV
Message-Id: <1106171859.202190.233940@z14g2000cwz.googlegroups.com>

Jean - Luc 

u answered my question thanks. Thread closed



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

Date: Wed, 19 Jan 2005 21:31:09 +0000 (UTC)
From: Hue-Bond <responder_solo_en_el_grupo@yahoo.es>
Subject: Re: The world's shortest 'Hello World!' program: a proposal
Message-Id: <slrncutkct.2bv.responder_solo_en_el_grupo@genus.hue-bond.com>

Michele Dondi, mié20050119@15:03:27(CET):
>
>>is 0 bytes in length with the action of printing to STDOUT:
>
> _What_ is "0 bytes in length"? I can't see anything in your example!!

Of course, it's 0 bytes ;^).


> Note that the empty program _is_ a valid program, and it's also the
> simples trie, in that it _does_ print itself, i.e. nothing.

Hmm? How could an empty program *print* something? Even if that something is
the empty string.


-- 
 David Serrano


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

Date: Wed, 19 Jan 2005 23:44:37 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: The world's shortest 'Hello World!' program: a proposal
Message-Id: <34itu0pap5es8c8mkkrcuomflsqc9870no@4ax.com>

On Tue, 18 Jan 2005 16:10:35 -0500, Ken <x3v0-usenet@yahoo.com> wrote:

>Larry wrote:
[snip 45 more lines]

>lol (this IS a joke, right?)

I don't think so, but I'm not really sure the OP is a troll either.
But then why quoting his whole message (which is alread a waste of
electrons in the first place)? Well, I see, your cmt applies to all of
it, so in some sense it does make sense, but... oh, well: you have
trimmed it down. All in all you're right: if it were a joke, then it
would have been funny after all!


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Wed, 19 Jan 2005 23:44:50 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: The world's shortest 'Hello World!' program: a proposal
Message-Id: <paitu0hctqi9q5rrgroe9tipg13bl6aun2@4ax.com>

On Tue, 18 Jan 2005 22:28:23 -0000, "Leonard Challis"
<perl@lennychallis.co.uk> wrote:

>"Ken" <x3v0-usenet@yahoo.com> wrote in message 
[snip 47 more lines]

>> lol (this IS a joke, right?)

>Lol, I can't tell if it is or not, but it would be quit funny :D

And did you really need to include a full quote of a message already
including a quote of the whole OP's immortal prose, just to add this
pearl of wisdom?!?


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Wed, 19 Jan 2005 23:44:48 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Usage of File::Find
Message-Id: <4jitu0hgnle8qa8q8cpikkm8i36i3uj66a@4ax.com>

On Tue, 18 Jan 2005 19:55:37 -0500, Bob Walton <see_sig@invalid>
wrote:

>Well, you could set $File::Find::prune when your "wanted" 
>function detects it has entered a directory at more than the 
>specified depth.  Determining the depth should be a matter of 
>counting the path delimiters in $File::Find::dir , which is 
>probably best done with the tr/// operator.

Some additional fiddling could be required if top-level dirs contain
path delimiters as well. All in all I wouldn't regard this as the best
strategy to accomplisht the task. I suspect something along the lines
of

  #!/usr/bin/perl -l
  
  use strict;
  use warnings;
  use File::Find;
  
  my $l;
  find { no_chdir => 1,
         preprocess => sub { $l++; @_},
         postprocess => sub { $l-- },
         wanted => sub { $_ = "$l\t$_"; print } }, @ARGV;
  
  __END__

should do the job. (Untested!)


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Wed, 19 Jan 2005 23:44:42 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Why doesn't this work?
Message-Id: <aiitu0tn9d0t5129dgvd0rceatbf0okk6o@4ax.com>

On 18 Jan 2005 14:33:24 -0800, "David Filmer"
<IneverReadAnythingSentToMe@hotmail.com> wrote:

>Subject: Why doesn't this work?

Hint: choose better subject lines.

>print (gmtime(time))[2];

 print +(gmtime(time))[2];
 # print +(gmtime time)[2];


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 7674
***************************************


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