[26210] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8396 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 8 09:05:27 2005

Date: Thu, 8 Sep 2005 06:05:06 -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           Thu, 8 Sep 2005     Volume: 10 Number: 8396

Today's topics:
        <> and filehandles in hashes <BZ@caradhras.net>
    Re: <> and filehandles in hashes <zen13097@zen.co.uk>
    Re: application question <sisyphus1@nomail.afraid.org>
    Re: application question <"h.v.niekerk at hccnet.nl">
    Re: application question <john@castleamber.com>
        Crude Email Adddress CHecking <uctraing@ultranet.com>
    Re: Crude Email Adddress CHecking <steve@uptime.org.uk>
    Re: Launching And Detaching <someone@example.com>
    Re: Launching And Detaching axel@white-eagle.invalid.uk
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 8 Sep 2005 11:13:03 GMT
From: BZ <BZ@caradhras.net>
Subject: <> and filehandles in hashes
Message-Id: <slrndi075v.mfv.BZ@kalypso.caradhras.net>

Hi!

Can anyone please explain to me why this code doesn't work? (it gives
a syntax error on the "print while..." line):

---- snip ----

#!/usr/bin/perl
use strict;
use warnings;

my %rec;
$rec{filename} = '/etc/fstab';
open($rec{fh},$rec{filename}) or die("$! while opening");

my @arr;
push @arr, { %rec };
# next line results in a syntax error:
print while (<$arr[0]->{fh}>);

close($rec{fh}) or die("$! while closing");

---- snip ----

If I change the <$arr[0]->{fh}> to readline($arr[0]->{fh}), it works
fine, and it also works fine if I put the filehandle in a scalar
variable first:

## this works fine again
my @arr;
push @arr, { %rec };
my $fh = $arr[0]->{fh};
print while (<$fh>);


Does anyone have a clue what's going on here?

-- 
BZ


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

Date: 08 Sep 2005 11:31:13 GMT
From: Dave Weaver <zen13097@zen.co.uk>
Subject: Re: <> and filehandles in hashes
Message-Id: <43202101$0$306$da0feed9@news.zen.co.uk>

On 8 Sep 2005 11:13:03 GMT, BZ <BZ@caradhras.net> wrote:
 ...
>  If I change the <$arr[0]->{fh}> to readline($arr[0]->{fh}), it works
>  fine, and it also works fine if I put the filehandle in a scalar
>  variable first:
> 
>  ## this works fine again
>  my @arr;
>  push @arr, { %rec };
>  my $fh = $arr[0]->{fh};
>  print while (<$fh>);
> 
>  Does anyone have a clue what's going on here?

Taken from `perldoc perlop`:

   If what the angle brackets contain is a simple scalar variable
   (e.g., <$foo>), then that variable contains the name of the
   filehandle to input from, or its typeglob, or a reference to the
   same.  For example:

           $fh = \*STDIN;
           $line = <$fh>;

   If what's within the angle brackets is neither a filehandle nor a
   simple scalar variable containing a filehandle name, typeglob,
   or typeglob reference, it is interpreted as a filename pattern to
   be globbed, and either a list of filenames or the next filename
   in the list is returned, depending on context.




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

Date: Thu, 8 Sep 2005 14:25:11 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: application question
Message-Id: <431fbd61$0$8993$afc38c87@news.optusnet.com.au>


"Huub" <"h.v.niekerk at hccnet.nl"> wrote in message
news:431fb6a5$0$769$3a628fcd@reader10.nntp.hccnet.nl...
> Hi,
>
> I have to do a project that will combine computergraphics, AI and
> scripting. I know perl can be used for AI and scripting, but how about
> graphics (e.g. OpenGL)? I read the faq, but couldn't find an answer on
that.
>

As regards OpenGL see:
http://search.cpan.org/search?query=OpenGL&mode=module

Note also that PDL (Perl Data Language) can be built with OpenGL and PGPLOT
support.

For perl graphics in general see:
http://search.cpan.org/modlist/Graphics

Cheers,
Rob




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

Date: Thu, 08 Sep 2005 06:59:06 +0200
From: Huub <"h.v.niekerk at hccnet.nl">
Subject: Re: application question
Message-Id: <431fc471$0$777$3a628fcd@reader20.nntp.hccnet.nl>

Sisyphus wrote:
> "Huub" <"h.v.niekerk at hccnet.nl"> wrote in message
> news:431fb6a5$0$769$3a628fcd@reader10.nntp.hccnet.nl...
> 
>>Hi,
>>
>>I have to do a project that will combine computergraphics, AI and
>>scripting. I know perl can be used for AI and scripting, but how about
>>graphics (e.g. OpenGL)? I read the faq, but couldn't find an answer on
> 
> that.
> 
> 
> As regards OpenGL see:
> http://search.cpan.org/search?query=OpenGL&mode=module
> 
> Note also that PDL (Perl Data Language) can be built with OpenGL and PGPLOT
> support.
> 
> For perl graphics in general see:
> http://search.cpan.org/modlist/Graphics
> 
> Cheers,
> Rob
> 
> 

Thank you.


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

Date: 8 Sep 2005 05:01:21 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: application question
Message-Id: <Xns96CBCBDA4Bcastleamber@130.133.1.4>

Huub <"h.v.niekerk at hccnet.nl"> wrote:

> Hi,
> 
> I have to do a project that will combine computergraphics, AI and 
> scripting. I know perl can be used for AI and scripting, but how about
> graphics (e.g. OpenGL)? I read the faq, but couldn't find an answer on
> that. 

http://search.cpan.org/search?query=opengl&mode=all

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: Thu, 08 Sep 2005 12:08:41 GMT
From: Bob <uctraing@ultranet.com>
Subject: Crude Email Adddress CHecking
Message-Id: <20a0i1ti70jr65hg767f49tfaid762m2kf@4ax.com>

OK, admitting up front that I know it's impossible to actually check
email addresses for validity due to the possible valid address
formats...

I'm looking for a routine/chunk of code that will check email
addresses for compliance with fairly standard formats i.e. it 
needs to be user@somedomain.com format, contain no spaces, etc. 

Anyone have a chunk or a pointer?

Thanks, 

Bob (barely a perl programmer :-) 


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

Date: Thu, 08 Sep 2005 13:15:57 +0100
From: Stephen Hildrey <steve@uptime.org.uk>
Subject: Re: Crude Email Adddress CHecking
Message-Id: <1126181757.32143.0@eunomia.uk.clara.net>

Bob wrote:
> OK, admitting up front that I know it's impossible to actually check
> email addresses for validity due to the possible valid address
> formats...
> 
> I'm looking for a routine/chunk of code that will check email
> addresses for compliance with fairly standard formats i.e. it 
> needs to be user@somedomain.com format, contain no spaces, etc. 

perldoc -q "valid mail"

Steve
-- 
Stephen Hildrey
E-mail: steve@uptime.org.uk   / Tel: +442071931337
Jabber: steve@jabber.earth.li / MSN: foo@hotmail.co.uk


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

Date: Thu, 08 Sep 2005 05:02:22 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Launching And Detaching
Message-Id: <yBPTe.166396$wr.106988@clgrps12>

Hal Vaughan wrote:
> I'm using one simple program to launch some daemons.  When I launch a
> program, I use backticks.  (This is all on Linux, in bash, btw.)  I've
> added "2>&1 >/dev/null &" to the command line, so it's like this:
> 
>         `/path/to/program 2>&1 >/dev/null &`;
> 
> I've noticed that if I include the '&' so the program detaches from the
> shell, if I kill the launching program, the child process survives.  I've
> also tried this by forking first:
> 
>         if (!fork()) {
>                 `/path/to/program 2>&1 >/dev/null &`;
>                 exit;
>         }
> 
> I had the hope that if I forked and launched like this, once all the
> programs were launched, the launching program would exit.  It doesn't.  Is
> there a way I can launch a program, then have the first program exit, so
> it's no longer using that bash instance (without killing it)?

Just putting '&' at the end does not detach a process from the shell.

man nohup
perldoc perlipc


John
-- 
use Perl;
program
fulfillment


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

Date: Thu, 08 Sep 2005 11:27:34 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: Launching And Detaching
Message-Id: <GeVTe.6644$k22.3228@fe2.news.blueyonder.co.uk>

Hal Vaughan <hal@thresholddigital.com> wrote:
> I'm using one simple program to launch some daemons.  When I launch a
> program, I use backticks.  (This is all on Linux, in bash, btw.)  I've
> added "2>&1 >/dev/null &" to the command line, so it's like this:
> 
>        `/path/to/program 2>&1 >/dev/null &`;
> 
> I've noticed that if I include the '&' so the program detaches from the
> shell, if I kill the launching program, the child process survives.  I've
> also tried this by forking first:
> 
>        if (!fork()) {
>                `/path/to/program 2>&1 >/dev/null &`;
>                exit;
>        }
> 
> I had the hope that if I forked and launched like this, once all the
> programs were launched, the launching program would exit.  It doesn't.  Is
> there a way I can launch a program, then have the first program exit, so
> it's no longer using that bash instance (without killing it)?
 
You should not been using backticks for this purpose - they
are designed to collect data from the external program
and will wait for that program.

Have a look at: perldoc -f exec

Axel


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

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


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