[31296] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2541 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 7 14:09:48 2009

Date: Fri, 7 Aug 2009 11:09:16 -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, 7 Aug 2009     Volume: 11 Number: 2541

Today's topics:
    Re: constant variable in perl <tadmc@seesig.invalid>
    Re: constant variable in perl <tadmc@seesig.invalid>
    Re: issue with multiprocess - fork <tadmc@seesig.invalid>
        Perl process as a unix background process gbostock@excite.com
    Re: Perl process as a unix background process <smallpond@juno.com>
    Re: Perl process as a unix background process <jak@isp2dial.com>
    Re: Perl process as a unix background process <glex_no-spam@qwest-spam-no.invalid>
    Re: Perl process as a unix background process gbostock@excite.com
    Re: Perl process as a unix background process gbostock@excite.com
    Re: Perl process as a unix background process gbostock@excite.com
    Re: Perl process as a unix background process <jak@isp2dial.com>
    Re: Perl process as a unix background process gbostock@excite.com
    Re: Process to upload multiple files from a single <inp <thepoet_nospam@arcor.de>
    Re: Usage of sub-routine prototype <tadmc@seesig.invalid>
        using file globs and regex <pgodfrin@gmail.com>
    Re: using file globs and regex <tadmc@seesig.invalid>
    Re: using file globs and regex <pgodfrin@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 07 Aug 2009 07:15:01 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: constant variable in perl
Message-Id: <slrnh7o67s.qq1.tadmc@tadmc30.sbcglobal.net>

Alexander Jack <abu.4000@gmail.com> wrote:
> On Aug 7, 11:39 am, Ben Morrow <b...@morrow.me.uk> wrote:
>> Quoth Alexander Jack <abu.4...@gmail.com>:
>>
>> > How to declare and use a constant variable in Perl ,
>> > please help me out ,
>>
>>     use constant NAME => "value";
>>
>> or
>>
>>     use Readonly;
>>     Readonly my $var = "value";
>>
>> depending on which you prefer.
>>
>> Ben
>
> Don't think that I am too greedy , but I want to know what is the
> difference between constant and Readonly  in perl  .


Start with

    perldoc constant

and

    perldoc Readonly


The later has a section named

    COMPARISON WITH "use constant"

which would seem interesting in this context.  :-)


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Fri, 07 Aug 2009 07:18:42 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: constant variable in perl
Message-Id: <slrnh7o6eo.qq1.tadmc@tadmc30.sbcglobal.net>

Alexander Jack <abu.4000@gmail.com> wrote:
> On Aug 7, 11:39 am, Ben Morrow <b...@morrow.me.uk> wrote:

>>     use Readonly;

> I didn't find any pragma like Readonly in my system , 


It is not a pragma.

By convention, pragma are in all lower-case.

Readonly is a module.


> Can you tell me
> how to get this...


The same way you would get any module:

    perldoc -q module

        What modules and extensions are available for Perl?  
             What is CPAN?  What does CPAN/src/... mean?
        How do I install a module from CPAN?
        How do I keep my own module/library directory?


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Fri, 07 Aug 2009 07:29:06 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: issue with multiprocess - fork
Message-Id: <slrnh7o728.qq1.tadmc@tadmc30.sbcglobal.net>

Xho Jingleheimerschmidt <xhoster@gmail.com> wrote:
> friend.05@gmail.com wrote:
>> My script is using fork so there are child processes. Sometimes my
>> script runs properly and output is correct. But sometime my script
>> gets stuck just after exiting child process.
>
> Asking the same question under a different subject line is more likely 
> to annoy the people you want to help you, than it is to get you more help.


Indeed, as I had killfiled this OP in April when he crossposted 
the first time.

    http://groups.google.com/groups/search?as_umsgid=74405uF119t50U2%40mid.individual.net

I thought at the time that it was perhaps a bit harsh to banish
him to perpetual invisibility, but I did it anyway.

Seeing that he still does it after being warned about it makes
me feel better about my original decision.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Fri, 7 Aug 2009 08:33:50 -0700 (PDT)
From: gbostock@excite.com
Subject: Perl process as a unix background process
Message-Id: <9adb0787-061b-4ecd-bc57-070f3ceb65dd@f10g2000vbf.googlegroups.com>

I'm experiencing some strange behavior with a certain perl program
when trying to run it as a unix background process. This process runs
with no problems at the terminal.
When I do:
(prompt)$myperl.pl &

The process starts running, output comes to the terminal but the
prompt doesn't come back. If there is any input at the terminal a
message appears saying that the process has stopped.

If I do:
(prompt)$ nohup myperl.pl &

the same thing happens

If I do:
(prompt)$myother.pl &

then I get the prompt back and the process runs in the background just
fine and continues when I use the terminal as usual.

So the question is: Does anybody have any idea what could be in the
myperl.pl that could prevent it from running in the background?

Please don't ask me to post the code as it is proprietary. If you need
to see the code you're probably just guessing at what could be the
problem anyway. There is a huge difference between myperl.pl and
myother.pl so it's not just a matter of spotting the diference. I'm
just hoping that some one has seen this sort of thing before and knows
what causes it.I'm not new to perl or unix and I've never seen
anything like this. What could be in the perl code to prevent it from
running in the background?



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

Date: Fri, 7 Aug 2009 08:55:52 -0700 (PDT)
From: smallpond <smallpond@juno.com>
Subject: Re: Perl process as a unix background process
Message-Id: <2ac5c313-8e9b-4a1e-ab61-ef3beb138771@p9g2000vbl.googlegroups.com>

On Aug 7, 11:33=A0am, gbost...@excite.com wrote:
> I'm experiencing some strange behavior with a certain perl program
> when trying to run it as a unix background process. This process runs
> with no problems at the terminal.
> When I do:
> (prompt)$myperl.pl &
>
> The process starts running, output comes to the terminal but the
> prompt doesn't come back. If there is any input at the terminal a
> message appears saying that the process has stopped.
>
> If I do:
> (prompt)$ nohup myperl.pl &
>
> the same thing happens
>
> If I do:
> (prompt)$myother.pl &
>
> then I get the prompt back and the process runs in the background just
> fine and continues when I use the terminal as usual.
>
> So the question is: Does anybody have any idea what could be in the
> myperl.pl that could prevent it from running in the background?
>
> Please don't ask me to post the code as it is proprietary. If you need
> to see the code you're probably just guessing at what could be the
> problem anyway. There is a huge difference between myperl.pl and
> myother.pl so it's not just a matter of spotting the diference. I'm
> just hoping that some one has seen this sort of thing before and knows
> what causes it.I'm not new to perl or unix and I've never seen
> anything like this. What could be in the perl code to prevent it from
> running in the background?

Important information that you left out:
  - what shell are you running?
  - did you write this code or someone else?
  - what flavor of unix?

This sounds similar to delayed suspend mode in bash.


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

Date: Fri, 07 Aug 2009 16:11:06 +0000
From: John Kelly <jak@isp2dial.com>
Subject: Re: Perl process as a unix background process
Message-Id: <74ko75t5qc1u6mld6jnec4e2pmkv28ihmr@4ax.com>

On Fri, 7 Aug 2009 08:33:50 -0700 (PDT), gbostock@excite.com wrote:

>I'm experiencing some strange behavior with a certain perl program
>when trying to run it as a unix background process.

>Does anybody have any idea what could be in the myperl.pl that could
>prevent it from running in the background?

>Please don't ask me to post the code as it is proprietary.

No idea.  But for fun, you could try:

The daemon helper, a small C program with a simple interface and a
liberal license.  I use daemon helper for starting perl and bash
scripts, to read fifos fed by syslog.  They block on read until syslog
provides data to work on.  They never end, and need help to start as
"daemons."

But that's just one example.  There are many other potential uses for
the daemon helper.

dh is its name; a natural companion to sh.

Hope you find it useful.

ftp://ftp.isp2dial.com/users/jak/src/dh/


-- 
Webmail for Dialup Users
http://www.isp2dial.com/freeaccounts.html
 


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

Date: Fri, 07 Aug 2009 11:16:14 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Perl process as a unix background process
Message-Id: <4a7c534e$0$87070$815e3792@news.qwest.net>

gbostock@excite.com wrote:
> I'm experiencing some strange behavior with a certain perl program
> when trying to run it as a unix background process. This process runs
> with no problems at the terminal.
> When I do:
> (prompt)$myperl.pl &
> 
> The process starts running, output comes to the terminal but the
> prompt doesn't come back. If there is any input at the terminal a
> message appears saying that the process has stopped.
> 
> If I do:
> (prompt)$ nohup myperl.pl &
> 
> the same thing happens
> 
> If I do:
> (prompt)$myother.pl &
> 
> then I get the prompt back and the process runs in the background just
> fine and continues when I use the terminal as usual.
> 
> So the question is: Does anybody have any idea what could be in the
> myperl.pl that could prevent it from running in the background?

Possibly it's reading from STDIN.

> 
> Please don't ask me to post the code as it is proprietary. 

Instead, you could comment out large chunks of your code to
narrow down where it might occur.  Once you narrow it down
to the particular line(s), then you can post your short example.

> If you need
> to see the code you're probably just guessing at what could be the
> problem anyway. [...]

Amazing..

I'll let you guess as to how to provide the data to your process,
since you don't need to see the code.


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

Date: Fri, 7 Aug 2009 09:18:42 -0700 (PDT)
From: gbostock@excite.com
Subject: Re: Perl process as a unix background process
Message-Id: <6dba9472-210e-4718-91b8-df898a5016e7@d21g2000vbm.googlegroups.com>

On Aug 7, 9:55=A0am, smallpond <smallp...@juno.com> wrote:
> On Aug 7, 11:33=A0am, gbost...@excite.com wrote:
>
>
>
>
>
> > I'm experiencing some strange behavior with a certain perl program
> > when trying to run it as a unix background process. This process runs
> > with no problems at the terminal.
> > When I do:
> > (prompt)$myperl.pl &
>
> > The process starts running, output comes to the terminal but the
> > prompt doesn't come back. If there is any input at the terminal a
> > message appears saying that the process has stopped.
>
> > If I do:
> > (prompt)$ nohup myperl.pl &
>
> > the same thing happens
>
> > If I do:
> > (prompt)$myother.pl &
>
> > then I get the prompt back and the process runs in the background just
> > fine and continues when I use the terminal as usual.
>
> > So the question is: Does anybody have any idea what could be in the
> > myperl.pl that could prevent it from running in the background?
>
> > Please don't ask me to post the code as it is proprietary. If you need
> > to see the code you're probably just guessing at what could be the
> > problem anyway. There is a huge difference between myperl.pl and
> > myother.pl so it's not just a matter of spotting the diference. I'm
> > just hoping that some one has seen this sort of thing before and knows
> > what causes it.I'm not new to perl or unix and I've never seen
> > anything like this. What could be in the perl code to prevent it from
> > running in the background?
>
> Important information that you left out:
> =A0 - what shell are you running?

bash. I've always been a ksh guy and I'm just getting going on bash
because I figured it was about time. How much different can bash be?

> =A0 - did you write this code or someone else?
Someone else did about a third of it, but that was the original third.
I checked with him and he can't explain what I'm seeing.

> =A0 - what flavor of unix?
linux

>
> This sounds similar to delayed suspend mode in bash.

Maybe you could elaborate on how that could be affected by the perl
process? I did a brief search on that and while it sounds related, I
don't know how the perl process could be sending ctl-z or ctl-y to the
shell.

Thanks.

- Hide quoted text -
>
> - Show quoted text -



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

Date: Fri, 7 Aug 2009 09:32:46 -0700 (PDT)
From: gbostock@excite.com
Subject: Re: Perl process as a unix background process
Message-Id: <f6531869-7ac3-462c-9e8c-dafa0b78bf58@l35g2000vba.googlegroups.com>

On Aug 7, 10:16=A0am, "J. Gleixner" <glex_no-s...@qwest-spam-no.invalid>
wrote:
> gbost...@excite.com wrote:
> > I'm experiencing some strange behavior with a certain perl program
> > when trying to run it as a unix background process. This process runs
> > with no problems at the terminal.
> > When I do:
> > (prompt)$myperl.pl &
>
> > The process starts running, output comes to the terminal but the
> > prompt doesn't come back. If there is any input at the terminal a
> > message appears saying that the process has stopped.
>
> > If I do:
> > (prompt)$ nohup myperl.pl &
>
> > the same thing happens
>
> > If I do:
> > (prompt)$myother.pl &
>
> > then I get the prompt back and the process runs in the background just
> > fine and continues when I use the terminal as usual.
>
> > So the question is: Does anybody have any idea what could be in the
> > myperl.pl that could prevent it from running in the background?
>
> Possibly it's reading from STDIN.

Nope, it reads from files, but the problem manifests before it gets to
the file read.

>
>
>
> > Please don't ask me to post the code as it is proprietary.
>
> Instead, you could comment out large chunks of your code to
> narrow down where it might occur. =A0Once you narrow it down
> to the particular line(s), then you can post your short example.

Narrow it down on what basis? Guessing?

>
> > If you need
> > to see the code you're probably just guessing at what could be the
> > problem anyway. [...]
>
> Amazing..
>
> I'll let you guess as to how to provide the data to your process,
> since you don't need to see the code.

Object Oriented!?!?!? ;-)

- Hide quoted text -
>
> - Show quoted text -



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

Date: Fri, 7 Aug 2009 09:34:34 -0700 (PDT)
From: gbostock@excite.com
Subject: Re: Perl process as a unix background process
Message-Id: <4e90db83-040d-43a3-9564-85ebf78c8a5a@q35g2000vbi.googlegroups.com>

On Aug 7, 10:11=A0am, John Kelly <j...@isp2dial.com> wrote:
> On Fri, 7 Aug 2009 08:33:50 -0700 (PDT), gbost...@excite.com wrote:
> >I'm experiencing some strange behavior with a certain perl program
> >when trying to run it as a unix background process.
> >Does anybody have any idea what could be in the myperl.pl that could
> >prevent it from running in the background?
> >Please don't ask me to post the code as it is proprietary.
>
> No idea. =A0But for fun, you could try:
>
> The daemon helper, a small C program with a simple interface and a
> liberal license. =A0I use daemon helper for starting perl and bash
> scripts, to read fifos fed by syslog. =A0They block on read until syslog
> provides data to work on. =A0They never end, and need help to start as
> "daemons."
>
> But that's just one example. =A0There are many other potential uses for
> the daemon helper.
>
> dh is its name; a natural companion to sh.
>
> Hope you find it useful.
>
> ftp://ftp.isp2dial.com/users/jak/src/dh/

It probably would be useful, but anal retentive corporations take a
dim view of downloading software.

>
> --
> Webmail for Dialup Usershttp://www.isp2dial.com/freeaccounts.html



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

Date: Fri, 07 Aug 2009 17:38:21 +0000
From: John Kelly <jak@isp2dial.com>
Subject: Re: Perl process as a unix background process
Message-Id: <tdpo75ph3i02ov8l5i67sjsoa2ktikibqm@4ax.com>

On Fri, 7 Aug 2009 09:34:34 -0700 (PDT), gbostock@excite.com wrote:

>> The daemon helper, a small C program with a simple interface
>> dh is its name; a natural companion to sh.
>> ftp://ftp.isp2dial.com/users/jak/src/dh/

>It probably would be useful, but anal retentive corporations take a
>dim view of downloading software.

You can't post the code and you can't download free software.  What a
pity.


-- 
Webmail for Dialup Users
http://www.isp2dial.com/freeaccounts.html
 


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

Date: Fri, 7 Aug 2009 10:46:23 -0700 (PDT)
From: gbostock@excite.com
Subject: Re: Perl process as a unix background process
Message-Id: <793c8911-1244-4582-9e02-cced63673538@r24g2000vbn.googlegroups.com>

On Aug 7, 11:38=A0am, John Kelly <j...@isp2dial.com> wrote:
> On Fri, 7 Aug 2009 09:34:34 -0700 (PDT), gbost...@excite.com wrote:
> >> The daemon helper, a small C program with a simple interface
> >> dh is its name; a natural companion to sh.
> >>ftp://ftp.isp2dial.com/users/jak/src/dh/
> >It probably would be useful, but anal retentive corporations take a
> >dim view of downloading software.
>
> You can't post the code and you can't download free software. =A0What a
> pity.

You said it!

>
> --
> Webmail for Dialup Usershttp://www.isp2dial.com/freeaccounts.html



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

Date: Fri, 07 Aug 2009 15:40:49 +0200
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: Process to upload multiple files from a single <input type=file>
Message-Id: <4a7c2ed4$0$31866$9b4e6d93@newsspool3.arcor-online.net>

Peter J. Holzer schrieb:
> On 2009-08-05 19:23, Ed Jay <edMbj@aes-intl.com> wrote:
>> I have a form that allows multiple files to be selected using a single
>> input element, e.g., <input type='file' min='1' max='999'>,
> 
> http://www.w3.org/TR/html401/ doesn't mention any "min" and "max"
> attributes for the input element, and this doesn't seem to let you
> select multiple files in IE7 or FF3.5. In which browser does this work?

It seems that Opera has been an early bird implementing the
then-proposed min/max behaviour for file inputs as in was
mentioned in the webforms 2.0 draft
(http://www.w3.org/TR/web-forms-2/).

Yet this has never made it into an official recommendation, and while
the current HTML5 draft does mention a "multiple" attribute for file
inputs, it specifically disallows "min" and "max"
(http://preview.tinyurl.com/mgpm7h).

-Chris


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

Date: Fri, 07 Aug 2009 07:44:33 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Usage of sub-routine prototype
Message-Id: <slrnh7o7v7.qq1.tadmc@tadmc30.sbcglobal.net>

Alexander Jack <abu.4000@gmail.com> wrote:


> Can any one tell me what is the usage of sub-routine prototype , 


Errr, there is a section named "Prototypes" in

    perldoc perlsub

Did that leave you with more questions?

If so, then ask _those_ questions.

When you have a question about subroutines, you should try reading
the docs for subroutines. Did you do that already?


> I
> know that was optional one but I wanted to know that whether it has
> any usages.


It "supports a very limited kind of compile-time argument checking".

So limited that you almost surely should not use prototypes in Perl.

And a beginner should certainly not be using them.

See also:

    http://www.perl.com/language/misc/fmproto.html


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Fri, 7 Aug 2009 09:33:52 -0700 (PDT)
From: pgodfrin <pgodfrin@gmail.com>
Subject: using file globs and regex
Message-Id: <81835bcc-69ea-4a86-997d-33d25624dd13@z34g2000vbl.googlegroups.com>

Greetings,
This program works fine (with file names f1..f8 in the directory):

#!/usr/bin/perl
use warnings;
use strict;
$\="\n";
while(<f*>)
{
    print "$_";
    if(/f5/)
    {
        my $fn=$_;
        print "File name $fn found..." and exit;
    }
}
exit;

But I was hoping to be able to do something like:
my $fn=grep (/f5/,<f*>);

Basically just trying to have less lines of code...any suggestions?
phil g


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

Date: Fri, 07 Aug 2009 12:06:08 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: using file globs and regex
Message-Id: <slrnh7on9k.u8t.tadmc@tadmc30.sbcglobal.net>

pgodfrin <pgodfrin@gmail.com> wrote:
> Greetings,
> This program works fine (with file names f1..f8 in the directory):
>
> #!/usr/bin/perl
> use warnings;
> use strict;
> $\="\n";
> while(<f*>)
> {
>     print "$_";
>     if(/f5/)
>     {
>         my $fn=$_;
>         print "File name $fn found..." and exit;
>     }
> }
> exit;
>
> But I was hoping to be able to do something like:
> my $fn=grep (/f5/,<f*>);
>
> Basically just trying to have less lines of code...any suggestions?


use grep() in a list context instead of in a scalar context.

I don't like using overloaded angle brackets in my code.

If I want equality, I use an operator that tests for equality.
    
    my($fn) = grep ( $_ eq 'f5' , glob 'f*');


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Fri, 7 Aug 2009 10:23:39 -0700 (PDT)
From: pgodfrin <pgodfrin@gmail.com>
Subject: Re: using file globs and regex
Message-Id: <57d16ad3-a938-432d-825c-318e37c85bf7@n2g2000vba.googlegroups.com>

Thanks Tad - works like a charm...
pg

On Aug 7, 12:06=A0pm, Tad J McClellan <ta...@seesig.invalid> wrote:
> pgodfrin <pgodf...@gmail.com> wrote:
> > Greetings,
> > This program works fine (with file names f1..f8 in the directory):
>
> > #!/usr/bin/perl
> > use warnings;
> > use strict;
> > $\=3D"\n";
> > while(<f*>)
> > {
> > =A0 =A0 print "$_";
> > =A0 =A0 if(/f5/)
> > =A0 =A0 {
> > =A0 =A0 =A0 =A0 my $fn=3D$_;
> > =A0 =A0 =A0 =A0 print "File name $fn found..." and exit;
> > =A0 =A0 }
> > }
> > exit;
>
> > But I was hoping to be able to do something like:
> > my $fn=3Dgrep (/f5/,<f*>);
>
> > Basically just trying to have less lines of code...any suggestions?
>
> use grep() in a list context instead of in a scalar context.
>
> I don't like using overloaded angle brackets in my code.
>
> If I want equality, I use an operator that tests for equality.
>
> =A0 =A0 my($fn) =3D grep ( $_ eq 'f5' , glob 'f*');
>
> --
> Tad McClellan
> email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"



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

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 V11 Issue 2541
***************************************


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