[28840] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 84 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 28 14:06:18 2007

Date: Sun, 28 Jan 2007 11:05:07 -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           Sun, 28 Jan 2007     Volume: 11 Number: 84

Today's topics:
    Re: custom regexp modifiers <paul@probulletin.com>
    Re: custom regexp modifiers <uri@stemsystems.com>
    Re: help with mime head jcharth@hotmail.com
    Re: help with mime head <bik.mido@tiscalinet.it>
        how to flush a  file <dcruncher4@aim.com>
    Re: how to flush a  file <rvtol+news@isolution.nl>
    Re: how to flush a  file <abigail@abigail.be>
    Re: how to flush a  file <tadmc@augustmail.com>
    Re: how to flush a  file <abigail@abigail.be>
    Re: how to flush a  file <uri@stemsystems.com>
    Re: how to flush a  file <abigail@abigail.be>
    Re: Seperating Perl code and HTML using Here Documents. <Peter@PSDT.com>
    Re: Seperating Perl code and HTML using Here Documents. barrybevel@ananzi.co.za
    Re: Seperating Perl code and HTML using Here Documents. <uri@stemsystems.com>
    Re: Seperating Perl code and HTML using Here Documents. <DJStunks@gmail.com>
    Re: Seperating Perl code and HTML using Here Documents. <uri@stemsystems.com>
        socket and fork <dontmewithme@got.it>
    Re: Undefined subroutine even though it appears in symb (NOSPAM)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 28 Jan 2007 10:36:38 -0800
From: "Paul" <paul@probulletin.com>
Subject: Re: custom regexp modifiers
Message-Id: <1170009398.293882.36880@a75g2000cwd.googlegroups.com>

I'll certainly do that in future, but I find it hard to believe that 
you can't figure out the context of my post when the previous post 
asks "why is it there?" and my reply begins "it shouldn't be there".



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

Date: Sun, 28 Jan 2007 13:57:18 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: custom regexp modifiers
Message-Id: <x7d54zughd.fsf@mail.sysarch.com>


what context? not everyone see all posts on usenet and not always in the
same order. read the guidelines posted here regularly for more on how to
work with this group. context is all.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 28 Jan 2007 09:12:58 -0800
From: jcharth@hotmail.com
Subject: Re: help with mime head
Message-Id: <1170004378.120279.253280@l53g2000cwa.googlegroups.com>

I tried using open my $fh but $head->get  returns an empty string 
everysingle time, if i print $message I see the full message.

open my $fh, '<', \$message or die "D'Oh! $!\n";
  my $head = MIME::Head->read($fh);

$myTo = lc($head->get('To',0));



On Jan 27, 10:31 am, Michele Dondi <bik.m...@tiscalinet.it> wrote:
> On 27 Jan 2007 06:48:27 -0800, jcha...@hotmail.com wrote:
>
> >Hello I am trygint to get the header of a string. I dont thnk this can
> >be done with the mime head module but may bet there is a work around.
> >I am fetching a message to a variable called
> >$message using LWP, i tried MIME::HEAD->read"$message"  and -The module is MIME::Head, and the above is not syntactically valid
> Perl: parens around method calls are mandatory except when the
> argument list is empty. Also, not strictly an error, but you don't
> need to quote $message. See
>
>   perldoc -q quoting
>
> Also, reading M::H's docs I see
>
> : Before reading further, you should see MIME::Tools to make sure that
> : you understand where this module fits into the grand scheme of things.
> : Go on, do it now. I'll wait.
>
> However, it also says
>
> :     ### Parse a new header from a filehandle:
> :     $head = MIME::Head->read(\*STDIN);
> :    
> :     ### Parse a new header from a file, or a readable pipe:
> :     $testhead = MIME::Head->from_file("/tmp/test.hdr");
> :     $a_b_head = MIME::Head->from_file("cat a.hdr b.hdr |");
>
> Thus you can open() $message in memory:
>
>   open my $fh, '<', \$message or die "D'Oh! $!\n";
>   my $head = MIME::Head->read($fh);
>
> 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: Sun, 28 Jan 2007 19:04:52 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: help with mime head
Message-Id: <ovopr2t1idokgq84or18618fi5g743shp6@4ax.com>

On 28 Jan 2007 09:12:58 -0800, jcharth@hotmail.com wrote:

>I tried using open my $fh but $head->get  returns an empty string 
>everysingle time, if i print $message I see the full message.
>
>open my $fh, '<', \$message or die "D'Oh! $!\n";
>  my $head = MIME::Head->read($fh);
>
>$myTo = lc($head->get('To',0));

Are things different if you save $message to a temporary file and
parse that? I see no reason why they should, but just to be sure...
oh, and I hope your perl is recent enough, but if it is not, I mean if
it doesn't support open()ing scalars in memory, then I suppose it
would just give you an error - either that or try to open a file with
the name of the stringified reference for reading, which is unlikely
to exist and would cause the program to die() anyway. I don't know for
sure because I only have access to fairly recent perls. Other than
this I can only quote myself:

: Also, reading M::H's docs I see
: 
: : Before reading further, you should see MIME::Tools to make sure that
: : you understand where this module fits into the grand scheme of things.
: : Go on, do it now. I'll wait.

Did you do so?

>On Jan 27, 10:31 am, Michele Dondi <bik.m...@tiscalinet.it> wrote:
[snip full quoted content]

*Please* do not top-post. If you don't know what top-posting is, then
google for it. It makes very hard for us to follow the discussion
properly.


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: Sun, 28 Jan 2007 11:07:53 -0500
From: "Data Cruncher" <dcruncher4@aim.com>
Subject: how to flush a  file
Message-Id: <c8SdneJRA4vKVyHYnZ2dnUVZ_o-knZ2d@comcast.com>

My process writes to the log file. I want to periodically flush it so
that tail -f on the the log file shows the progress on a regular
basis.

This is what I do to write in the log file:-

open(LOGFILE,"> file name") or die ...
print LOGFILE "aaaaa\n" ;
this print is done during the life of the process.
What is happening is that until the process terminates
the log file can not be viewed by tail -f because perl is
still buffering the output to the log file.
and then finally
close(LOGFILE);

How do I flush it. There is no command like flush(LOGFILE).

What I have done is a crude approach of closing the log file
and then reopening it with '>>filename'. As it happens only
once a minute, it is not that expensive. But I am not happy
with this approach. It is not an elegant approach.

TIA.




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

Date: Sun, 28 Jan 2007 17:46:54 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: how to flush a  file
Message-Id: <epinj6.1hs.1@news.isolution.nl>

Data Cruncher schreef:

> My process writes to the log file. I want to periodically flush it so
> that tail -f on the the log file shows the progress on a regular
> basis.

This is from `perldoc -f select`:

    $oldfh = select(STDERR); $| = 1; select($oldfh);

Some programmers may prefer to think of filehandles as objects
with methods, preferring to write the last example as:

    use IO::Handle;
    STDERR->autoflush(1);

-- 
Affijn, Ruud

"Gewoon is een tijger."


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

Date: 28 Jan 2007 17:10:39 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: how to flush a  file
Message-Id: <slrnerpm88.tcf.abigail@alexandra.abigail.be>

Dr.Ruud (rvtol+news@isolution.nl) wrote on MMMMDCCCXCVIII September
MCMXCIII in <URL:news:epinj6.1hs.1@news.isolution.nl>:
^^  Data Cruncher schreef:
^^  
^^ > My process writes to the log file. I want to periodically flush it so
^^ > that tail -f on the the log file shows the progress on a regular
^^ > basis.
^^  
^^  This is from `perldoc -f select`:
^^  
^^      $oldfh = select(STDERR); $| = 1; select($oldfh);

Well, that will flush STDERR but it has the effect of leaving it unbuffered.
Which may not be what the OP wants. I'd write it as:

    my $old_fh = select STDERR; {local $| = 1;} select $old_fh;


^^  Some programmers may prefer to think of filehandles as objects
^^  with methods, preferring to write the last example as:
^^  
^^      use IO::Handle;
^^      STDERR->autoflush(1);

Or:

    use IO::Handle;
    STDERR -> flush or die "Flush failed: $!";


Too bad 'flush' was never added to Perl as a primitive.



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
 .qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
 .qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'


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

Date: Sun, 28 Jan 2007 11:16:08 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: how to flush a  file
Message-Id: <slrnerpmio.8io.tadmc@tadmc30.august.net>

Data Cruncher <dcruncher4@aim.com> wrote:

> How do I flush it.


   perldoc -q flush

       How do I flush/unbuffer an output filehandle?  Why must I do this?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 28 Jan 2007 18:09:14 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: how to flush a  file
Message-Id: <slrnerppm2.tcf.abigail@alexandra.abigail.be>

Tad McClellan (tadmc@augustmail.com) wrote on MMMMDCCCXCVIII September
MCMXCIII in <URL:news:slrnerpmio.8io.tadmc@tadmc30.august.net>:
&&  Data Cruncher <dcruncher4@aim.com> wrote:
&&  
&& > How do I flush it.
&&  
&&  
&&     perldoc -q flush
&&  
&&         How do I flush/unbuffer an output filehandle?  Why must I do this?


To be fair to the OP, this FAQ only explains how to unbuffer the handle.
It doesn't explain how to flush a filehandle.

I have to say, flushing a filehandle in Perl is unintuitive, awkward
and phrone to do it while doing unintended side-effects. And, amazingly,
it only takes one line in C.



Abigail
-- 
perl -le 's[$,][join$,,(split$,,($!=85))[(q[0006143730380126152532042307].
          q[41342211132019313505])=~m[..]g]]e and y[yIbp][HJkP] and print'


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

Date: Sun, 28 Jan 2007 13:29:17 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: how to flush a  file
Message-Id: <x7odojuhs2.fsf@mail.sysarch.com>

>>>>> "A" == Abigail  <abigail@abigail.be> writes:

  A> Tad McClellan (tadmc@augustmail.com) wrote on MMMMDCCCXCVIII September
  A> MCMXCIII in <URL:news:slrnerpmio.8io.tadmc@tadmc30.august.net>:
  A> &&  Data Cruncher <dcruncher4@aim.com> wrote:
  A> &&  
  A> && > How do I flush it.
  A> &&  
  A> &&  
  A> &&     perldoc -q flush
  A> &&  
  A> &&         How do I flush/unbuffer an output filehandle?  Why must I do this?

  A> To be fair to the OP, this FAQ only explains how to unbuffer the handle.
  A> It doesn't explain how to flush a filehandle.

  A> I have to say, flushing a filehandle in Perl is unintuitive, awkward
  A> and phrone to do it while doing unintended side-effects. And, amazingly,
  A> it only takes one line in C.

that is because you (and the rest of this thread) are confusing
autoflushing (setting $|) with actual flushing which can be done with
the flush call in IO::Handle. it used to be fflush in POSIX but that
refers to IO::Handle now. so for older perls look for fflush in POSIX.

setting $| may not be a desirable thing as it will flush for each
print. sometimes you do want to let buffering work for you and flush as
needed. i prefer to buffer stuff myself with .= into a string and use
syswrite (or File::Slurp::write_file). it has many benefits including
more control over where and when you write.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 28 Jan 2007 18:34:39 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: how to flush a  file
Message-Id: <slrnerpr5o.tcf.abigail@alexandra.abigail.be>

Uri Guttman (uri@stemsystems.com) wrote on MMMMDCCCXCVIII September
MCMXCIII in <URL:news:x7odojuhs2.fsf@mail.sysarch.com>:
!! >>>>> "A" == Abigail  <abigail@abigail.be> writes:
!!  
!!   A> Tad McClellan (tadmc@augustmail.com) wrote on MMMMDCCCXCVIII September
!!   A> MCMXCIII in <URL:news:slrnerpmio.8io.tadmc@tadmc30.august.net>:
!!   A> &&  Data Cruncher <dcruncher4@aim.com> wrote:
!!   A> &&  
!!   A> && > How do I flush it.
!!   A> &&  
!!   A> &&  
!!   A> &&     perldoc -q flush
!!   A> &&  
!!   A> &&         How do I flush/unbuffer an output filehandle?  Why must I do this?
!!  
!!   A> To be fair to the OP, this FAQ only explains how to unbuffer the handle.
!!   A> It doesn't explain how to flush a filehandle.
!!  
!!   A> I have to say, flushing a filehandle in Perl is unintuitive, awkward
!!   A> and phrone to do it while doing unintended side-effects. And, amazingly,
!!   A> it only takes one line in C.
!!  
!!  that is because you (and the rest of this thread) are confusing
!!  autoflushing (setting $|) with actual flushing which can be done with
!!  the flush call in IO::Handle. it used to be fflush in POSIX but that
!!  refers to IO::Handle now. so for older perls look for fflush in POSIX.
!!  setting $| may not be a desirable thing as it will flush for each
!!  print.

Hmm, clearly you haven't been reading what I wrote. I did point how to use
$| for flushing correctly, and I did point out how to use IO::Handle for it.

That of course doesn't invalidate what I wrote about it. Having to use
IO::Handle while opening, reading, writing, seeking, locking etc doesn't
require using IO::Handle is hateful.



Abigail
-- 
perl -Mstrict -we '$_ = "goto Y.print chop;\n=rekcaH lreP rehtona tsuJ";Y1:eval'


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

Date: Sun, 28 Jan 2007 15:12:06 GMT
From: Peter Scott <Peter@PSDT.com>
Subject: Re: Seperating Perl code and HTML using Here Documents...
Message-Id: <pan.2007.01.28.15.12.05.272088@PSDT.com>

On Sat, 27 Jan 2007 22:09:32 -0800, barrybevel wrote:
> Thanks Sherm & Uri, very quick response.
> 
> I'll have a look at:
> 
> Template::Simple
> Template::Toolkit
> HTML::Mason

Don't forget HTML::Template.

If, for some reason, separating the HTML into separate template files
isn't a good idea in your design, try Inline::File.  (But it would be a
rare reason.)

-- 
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/



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

Date: 28 Jan 2007 07:25:00 -0800
From: barrybevel@ananzi.co.za
Subject: Re: Seperating Perl code and HTML using Here Documents...
Message-Id: <1169997900.277165.257760@v33g2000cwv.googlegroups.com>

Mark, thanks for the HTML::Template suggestion I will keep it in mind.

Michele,
My requirements are not that complex, I just need to put a few 
variables in a HTML page,
so I'm going to implement your suggestions straight away.
If my code is still too complex I can always use one of the modules 
suggested.
But it looks like I wont need to, your ideas look like they will make 
a huge difference.
Thanks very much.



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

Date: Sun, 28 Jan 2007 11:32:00 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Seperating Perl code and HTML using Here Documents...
Message-Id: <x7y7nnun7j.fsf@mail.sysarch.com>

>>>>> "MD" == Michele Dondi <bik.mido@tiscalinet.it> writes:

  MD> So these external Perl scripts only "load" a page into a scalar. One
  MD> may wonder why you don't get rid of the Perl code and directly load
  MD> the HTML pages. Of course the answer is that you interpolare $var1,
  MD> $var2, etc. This is where one sees the usefulness of a templating
  MD> system. If things are really this simple, you may roll your own
  MD> templating system though, so you may have a file like:

  MD>   <html>
  MD>   ...
  MD>   Good Page [var1]
  MD>   ...
  MD>   </html>

  MD> called good-page.tpl, and in your Perl script you would do something
  MD> like

  MD>   my %config=( var1 => 'foo',
  MD>                var2 => 'bar' );
  MD>   my $default='baz';
  
  MD>   my $webpage;
  MD>   if( whatever() ) {
  MD>       $webpage=load('good-page.tpl');
  MD>   } else {
  MD>       $webpage=load('bad-page.tpl');
  MD>   }
  MD>   $webpage =~ s/\[(\w+?)\]/$config{$1}||$default/ge;
  
  MD>   sub load {
  MD>       my $file=shift;
  MD>       open my $fh, '<', $file
  MD>         or die "Can't open `$file': $!\n";
  MD>       local $/;
  MD>       scalar <$fh>;
  MD>   }

  MD> Of course, the more you need to add features, the more you will create
  MD> yet another full fledged templating system, with all the difficulties
  MD> of doing so, so you will realize that maybe it would have been better
  MD> to choose a ready made one in the first place. It all really depends
  MD> on how complex your requirements actually are.

that exactly is how template::simple evolved. i had done trivial scalar
expansions many times and i just added the minimal set of features i
needed over time (chunks, implied loops, include files) until i had
something interesting and productive. then i cpan'ed it into
template::simple. even with such short pseudo code as you show there be
subtle issues and quickly desired features that a module is the way to
go even for beginners. it will amaze the OP how fast he will want
conditionals and loops and nesting. as soon as he needs to fill in
tables and rows he will scream when trying to do it from scratch. just
my observations on how simple requirements never stay simple. so it is
best to use a template module from the beginning IMO (of course i didn't
and wrtoe my own but i am kinda that way).

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 28 Jan 2007 09:11:58 -0800
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: Seperating Perl code and HTML using Here Documents...
Message-Id: <1170004317.992744.171830@v33g2000cwv.googlegroups.com>

On Jan 28, 9:32 am, Uri Guttman <u...@stemsystems.com> wrote:
> >>>>> "MD" == Michele Dondi <bik.m...@tiscalinet.it> writes: 
>   MD> If things are really this simple, you may roll your own
>   MD> templating system though, so you may have a file like:
>   MD> <snip homemade templater>
>
> that exactly is how template::simple evolved.
> <snip>
> it is best to use a template module from the beginning IMO (of
> course i didn't and wrtoe my own but i am kinda that way).

very funny :-))

according to Simon's recollection of a clp.moderated thread, every 
Perl programmer eventually tries to re-invent the following wheels:

  1) templating system :-D
  2) database abstraction layer
  3) HTML parser
  4) command-line argument processor
  5) date/time manipulation module

It's nice to see that despite everything that's going on in the world 
these days, the universe is still obeying her natural laws :p

-jp



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

Date: Sun, 28 Jan 2007 13:23:37 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Seperating Perl code and HTML using Here Documents...
Message-Id: <x7sldvui1i.fsf@mail.sysarch.com>

>>>>> "DS" == DJ Stunks <DJStunks@gmail.com> writes:

  DS> On Jan 28, 9:32 am, Uri Guttman <u...@stemsystems.com> wrote:
  >> >>>>> "MD" == Michele Dondi <bik.m...@tiscalinet.it> writes: 
  MD> If things are really this simple, you may roll your own
  MD> templating system though, so you may have a file like:
  MD> <snip homemade templater>
  >> 
  >> that exactly is how template::simple evolved.
  >> <snip>
  >> it is best to use a template module from the beginning IMO (of
  >> course i didn't and wrtoe my own but i am kinda that way).

  DS> very funny :-))

  DS> according to Simon's recollection of a clp.moderated thread, every 
  DS> Perl programmer eventually tries to re-invent the following wheels:

  DS>   1) templating system :-D

as i said, i did many dinky ones until it bloated to 37 lines of code!

  DS>   2) database abstraction layer

sorta did that with a message passing wrapper in stem for dbi. it works
well but isn't an abstraction layer. i do plan a proper abstraction one
day that will not be anything like what is out there. more for an
abstract persistance backend than a classic dbms.

  DS>   3) HTML parser

never will try that. 

  DS>   4) command-line argument processor

my first perl5 project was one of those. never did publish/cpan it and i
don't even use it. interesting learning experiment for me. it is on
sysarch.com somewhere. still is very different than most (table driven
with lots of interesting features). damian conway implemented most of
those in his.

  DS>   5) date/time manipulation module

never will try that. too much human cruft to deal with. 

  DS> It's nice to see that despite everything that's going on in the world 
  DS> these days, the universe is still obeying her natural laws :p

so i have only tried 3 of those (and only one proper success). i only
tackle these types of problems when i need it myself and i rarely agree
with how they are done on cpan. template::simple is my case in point for
how to really abstract out the core needs and make it simple to use and
to code.

i am currently working on CMS::Simple (which uses Template::Simple of
course) which will support a simple plain text content format with
minimal markup, flexible sharing of content and template components,
custom filtering (with a core lib of filters) and a very clean data flow
which is easy to understand and change. this is meant for any form of
publishing but will initially be web centric to start. i haven't seen
anything that allows for the sharing of content and templates in the way
this does. and sharing is the key to simplicity as you can build up libs
of stuff at a high and low level (e.g. a single page body template
includes all custom pages which are rendered as needed). again, my views
of what is important (maximum sharing and reuse and minimal complexity)
don't jibe with the cms modules out there.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Sun, 28 Jan 2007 18:04:13 +0100
From: Larry <dontmewithme@got.it>
Subject: socket and fork
Message-Id: <dontmewithme-D79006.18041328012007@news.tin.it>

Hello everybody,

     I don't know if this has been covered before, I'd love to code a 
tiny server that can hanlde several requests at the same...the following 
chuck of code can only handle one connection at a time:

use Socket qw(:DEFAULT :crlf);

$socket = IO::Socket::INET->new() || die "unableto listen";
$socket->listen();

$| = 1;

while (1)
{
   $client = $socket->accept;

   if ($client)
   {
      ...get data...send response...
      close $client;
   }
   
}

How can I go about using fork() ? it's just a tiny server so a couple of 
connections at the same time would be good...

thanks


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

Date: Sat, 27 Jan 2007 22:32:32 -0600
From: "Mumia W. (NOSPAM)" <paduille.4060.mumia.w+nospam@earthlink.net>
Subject: Re: Undefined subroutine even though it appears in symbol table?
Message-Id: <epiam2$ni5$1@aioe.org>

On 01/27/2007 09:58 AM, max.gruber wrote:
> Suppose I've got a subroutine subA in PackageA which calls subB from 
> PackageB.
> 
> Now somehow I keep getting "Undefined subroutine &PackageB::subB 
> called at PackageA line n" (line number points to subA) depending on 
> from where I call subA.
> [...]
> When I dump the symbol table %:: just before the call to subB, 

That's the wrong symbol table to dump. You would need to dump the symbol 
table for the current package: %PackageA::

> in all 
> cases where the error appears, it will actually contain a reference to 
> subB. In all cases where the error doesn't appear, it won't contain a 
> reference. (WTF?)
> [...]

Most probably your "use" statement is in the wrong place. Evidently, you 
"use" PackageB while the current package scope is main, so PackageB's 
functions are imported into the main package instead of PackageA.

This will import names into the main package:

#!/usr/bin/perl
use PackageB;

package PackageA;
 ... some stuff ...

This will import names into PackageA:

#!/usr/bin/perl
package PackageA;
use PackageB;
 ... some stuff ...


HTH

-- 
Windows Vista and your freedom in conflict:
http://techdirt.com/articles/20061019/102225.shtml


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

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


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