[23977] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6178 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 22 18:05:54 2004

Date: Sun, 22 Feb 2004 15:05:09 -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, 22 Feb 2004     Volume: 10 Number: 6178

Today's topics:
        (most probably) OT: /dev/random and /dev/urandom <bik.mido@tiscalinet.it>
    Re: (most probably) OT: /dev/random and /dev/urandom (Anno Siegel)
        finding common words (viv2k)
    Re: finding common words <noreply@gunnar.cc>
        Get module location from module <ppagee@yahoo.com>
    Re: Get module location from module <usenet@morrow.me.uk>
    Re: Help with end of line charaters <tadmc@augustmail.com>
    Re: Help with end of line charaters <invalid-email@rochester.rr.com>
    Re: I wish buy Perl book <jwillmore@remove.adelphia.net>
    Re: I wish buy Perl book <uri@stemsystems.com>
    Re: Installation Problem with XML::Parser perl module (Anno Siegel)
    Re: Newbie file / string question <tadmc@augustmail.com>
    Re: Newbie file / string question <noreply@gunnar.cc>
    Re: Newbie file / string question (Anno Siegel)
    Re: Newbie file / string question (Anno Siegel)
    Re: Newbie file / string question <noreply@gunnar.cc>
    Re: Newbie file / string question (Anno Siegel)
    Re: Newbie file / string question <gnari@simnet.is>
    Re: Newbie file / string question <noreply@gunnar.cc>
    Re: Newbie file / string question (Anno Siegel)
        Perl causing scheduler to hang (Cosmic Cruizer)
    Re: perl fileio <uri@stemsystems.com>
        Private methods within a Perl Object module <johnj@nospam.here.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 22 Feb 2004 15:13:39 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: (most probably) OT: /dev/random and /dev/urandom
Message-Id: <sa4h30509i134h59kg1itg1ok7b7s453og@4ax.com>

I apologize in advance for posting this question that I feel is most
probably OT (if it actually is OT). I have this small script:

  #!/usr/bin/perl
  
  use strict;
  use warnings;
  
  $/=\0x100_000;
  open my $fh, '<:raw', '/dev/urandom' or die $!;
  print scalar <$fh>;
  
  __END__

If I run it I get:

  # ./foo.pl | wc -c
  1048576
  # ./foo.pl | wc -c
  1048576
  # ./foo.pl | wc -c
  1048576
  # ./foo.pl | wc -c
  1048576

[ad libitum]

If I change /dev/urandom to /dev/random, then I get:

  # ./foo.pl | wc -c
       89
  # ./foo.pl | wc -c
       89
  # ./foo.pl | wc -c
       89
  # ./foo.pl | wc -c
       82
  # ./foo.pl | wc -c
  ^[[A
  
["hangs", had to press CTRL-C]

FWIW I'm running a 2.6.3 kernel. May something be wrong with my system
or am I doing this *in perl* the wrong way?!?


TIA,
Michele
-- 
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
  "perl bug File::Basename and Perl's nature"


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

Date: 22 Feb 2004 15:55:11 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: (most probably) OT: /dev/random and /dev/urandom
Message-Id: <c1ajcv$j2h$1@mamenchi.zrz.TU-Berlin.DE>

Michele Dondi  <bik.mido@tiscalinet.it> wrote in comp.lang.perl.misc:
> I apologize in advance for posting this question that I feel is most
> probably OT (if it actually is OT). I have this small script:
> 
>   #!/usr/bin/perl
>   
>   use strict;
>   use warnings;
>   
>   $/=\0x100_000;
>   open my $fh, '<:raw', '/dev/urandom' or die $!;
>   print scalar <$fh>;
>   
>   __END__
> 
> If I run it I get:
> 
>   # ./foo.pl | wc -c
>   1048576

 ...as expected.

[...]

> If I change /dev/urandom to /dev/random, then I get:
> 
>   # ./foo.pl | wc -c
>        89

That behavior is wrong.  The only difference in /dev/urandom and /dev/random
is that random may block when it runs out of entropy while urandom continues
to deliver random data of lower quality.  Stick to urandom until the other
can be repaired.

Anno


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

Date: 22 Feb 2004 13:20:54 -0800
From: viv2k@hotmail.com (viv2k)
Subject: finding common words
Message-Id: <6fd673b3.0402221320.7a415702@posting.google.com>

I'm new to Perl but a friend has told me that the task I wana do can
be done very efficiently by Perl.

Right now, I have two very long lists of words with comments attached
to each of the words and I want to find the words that are common in
both of them.

example:

ListA                ListB

apple   1.1          apple 100
banana  2.2          boy   500
cat     3.3          cat   1000

And I want the result to look something like:

ListA                ListB
apple   1.1          apple 100
cat     3.3          cat   1000

any idea on how to tackle this? I'm off to reading some Perl
introductory books now koz I really need that list asap. Any help
would be greatly appreciated.

thanks
viv


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

Date: Sun, 22 Feb 2004 22:36:11 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: finding common words
Message-Id: <c1b7qa$1fpfks$1@ID-184292.news.uni-berlin.de>

viv2k wrote:
> Right now, I have two very long lists of words with comments
> attached to each of the words and I want to find the words that are
> common in both of them.
> 
> example:
> 
> ListA                ListB
> 
> apple   1.1          apple 100
> banana  2.2          boy   500
> cat     3.3          cat   1000
> 
> And I want the result to look something like:
> 
> ListA                ListB
> apple   1.1          apple 100
> cat     3.3          cat   1000

     my %ListA = ( apple => 1.1, banana => 2.2, cat => 3.3 );
     my %ListB = ( apple => 100, boy => 500, cat => 1000 );

     for (keys %ListA) {
         delete $ListA{$_} unless exists $ListB{$_};
     }
     for (keys %ListB) {
         delete $ListB{$_} unless exists $ListA{$_};
     }

     print "ListA\n";
     print "$_\t$ListA{$_}\n" for sort keys %ListA;
     print "\n";
     print "ListB\n";
     print "$_\t$ListB{$_}\n" for sort keys %ListB;

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



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

Date: Sun, 22 Feb 2004 20:38:09 +0100
From: Mike Mimic <ppagee@yahoo.com>
Subject: Get module location from module
Message-Id: <c1b0ed$7b1$1@planja.arnes.si>

Hi!

How can module get its location on system?

Executable variables show Perl program which
include module.


Mike


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

Date: Sun, 22 Feb 2004 20:19:54 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Get module location from module
Message-Id: <c1b2ta$fk1$1@wisteria.csv.warwick.ac.uk>


Mike Mimic <ppagee@yahoo.com> wrote:
> Hi!
> 
> How can module get its location on system?
> 
> Executable variables show Perl program which
> include module.

$INC{'Foo/Bar.pm'}

If you want the Perl program's location, use FindBin.

Ben

-- 
perl -e'print map {/.(.)/s} sort unpack "a2"x26, pack "N"x13,
qw/1632265075 1651865445 1685354798 1696626283 1752131169 1769237618
1801808488 1830841936 1886550130 1914728293 1936225377 1969451372
2047502190/'                                                 # ben@morrow.me.uk


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

Date: Sun, 22 Feb 2004 07:48:30 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Help with end of line charaters
Message-Id: <slrnc3hcpe.j2i.tadmc@magna.augustmail.com>

Andy <andy.westcott@motorola.com> wrote:

> The file has to 2 fields that are tab separated and each field is made
> up of items separated by some type of linefeed character. 


There is only ONE type of linefeed character, ASCII defines 
the LF character as character #10 (decimal).


> The end of
> the second field is identified by another type of linefeed character.


There is no "other type" of linefeed character.


> When I view the file in VIM the second linefeed shows as a ^M 


That is not a "linefeed" (LF) character, that is a "carriage return" (CR)
character (#13 in ASCII).


> I have tried searching for \r \n  %CR %LF $VT $FF but nothing seems to
> give the required effect.


I cannot tell what effect it is that you require...


> Please can you offer some advice or possible places to look.


Show us your data.


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


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

Date: Sun, 22 Feb 2004 20:58:54 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Help with end of line charaters
Message-Id: <40391624.8030305@rochester.rr.com>

Andy wrote:

 ...
> The file has to 2 fields that are tab separated and each field is made
> up of items separated by some type of linefeed character. The end of

---------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


> the second field is identified by another type of linefeed character.

------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I was only aware of one "type of linefeed character", the newline, or 
0x0a.  You'll have to fill us in on this new information.


> 
> When I view the file in VIM the second linefeed shows as a ^M so there
> must be a way of identifying these separately.


^M would be a carriage return (0x0d).  In VIM, the file was probably 
interpreted as a "UNIX" file (it will say so on the status line if it 
was, assuming you have the status line turned on) but actually has 
Windoze line endings.  Maybe the very first line has just a newline, and 
the rest have Windoze line endings?


> 
> I have tried searching for \r \n  %CR %LF $VT $FF but nothing seems to
> give the required effect.
> 
> I need to run the script on a PC. 
> 
> Please can you offer some advice or possible places to look.
 ...


> Andy
> 

You need to identify exactly what characters are present in your data 
file.  Since it looks like you're running Windoze (you say PC, so it 
could be Linux, BSD, DOS, OS/2, etc, I suppose), you don't have a dump 
command -- so you can use the following to give you a nice dump of your 
file contents:

die "One argument required:  name of file to dump" unless scalar @ARGV;
open IN,$ARGV[0] or die "Oops, couldn't open $ARGV[0], $!";
binmode IN;
if(scalar(@ARGV)>1){
         open OUT,">$ARGV[1]" or die "Oops, couldn't open $ARGV[1] for 
write, $!"
;
}
else{
         *OUT=*STDOUT;
}
while($l=read(IN,$in,16)){
         @in=split '',$in;
         for(@in){$_=ord $_}
         printf OUT "%08x ",$add;
         $i=0;
         for(0..15){
                 if($_<@in){printf OUT "%02x ",$in[$_]}
                 else{printf OUT "   "}
                 $i++;
                 printf OUT " " if $i%4==0;
                 printf OUT " " if $i==8;
         }
         $in=~y [\000-\037] [.];
         $in=~y [\177-\377] [.];
         print OUT "$in\n";
         $add+=16;
}

Then you can use ord() to look at what it is Perl is actually reading in 
your program.  Note that Perl will make an attempt to "fix" Windoze line 
endings (that's a feature) upon reading (if it is Win32 Perl), so what 
shows up internally in Perl may be different that what is in the file. 
If all is well, a file with Windoze line endings will actually contain 
newline (or UNIX) line endings internally in Perl -- and the Windoze 
line endings will be regenerated at output time.  That way, the Perl 
internals can deal with a constant, rather than have to deal with OS 
differences.

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Sun, 22 Feb 2004 15:09:27 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: I wish buy Perl book
Message-Id: <pan.2004.02.22.20.09.25.90729@remove.adelphia.net>

On Sun, 22 Feb 2004 21:48:20 +0800, toylet wrote:

>>> It's actually found by google.com. I myself has my own stock of web 
>>> server cd shelf. I was not promoting the site. Maybe I should just post 
>>> http://www.google.com
>> 
>> No.  You should post the O'Reilly web site - since they already have a way
>> to view books on line.  It's called Safari - and it's the *only* place to
>> view O'Reilly books on line.
> 
> Or pay a visit to a library (be it online, public or private) and borrow 
> a book. I think we could find Oreilly books in public libraries, right? :)

Maybe ... I haven't been in a public library in 20+ years and have not
been in a college library in about 15 years (since I earned my degree) :-)

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
Bipolar, adj.:  Refers to someone who has homes in Nome, Alaska, 
and Buffalo, New York 



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

Date: Sun, 22 Feb 2004 21:11:13 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: I wish buy Perl book
Message-Id: <x7llmuhlam.fsf@mail.sysarch.com>

>>>>> "MG" == Matt Garrish <matthew.garrish@sympatico.ca> writes:

  MG> "toylet" <toylet@mail.hongkong.com> wrote in message
  MG> news:4036ff85$1_2@rain.i-cable.com...

  >> This kind of links could easily be found by google. There are even *.edu
  >> that did that, Notably in certain 3rd world countries. I had nothing to
  >> do with the site. DOn't mis-understand.

  MG> I don't think anyone is blaming you (well, maybe Uri) for posting
  MG> those books online. Just be aware that there are people who read
  MG> this newsgroup, like Randal, who authored or contributed to those
  MG> books, so this is not the forum to be recommending pirated
  MG> information. Either point people to the free documentation or
  MG> suggest they buy a book / subscription.

i do blame him for even posting the link. if he knows it is a bootleg
and he still posts the link then he is either very stupid or condoning
the theft. sorry to be so harsh but i have to ask why he did that at
all? and then he says google has plenty of hits. so let the kiddies
google for themselves and not give them any extra help.

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: 22 Feb 2004 22:32:45 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Installation Problem with XML::Parser perl module
Message-Id: <c1bamd$2gv$1@mamenchi.zrz.TU-Berlin.DE>

Ben Morrow  <usenet@morrow.me.uk> wrote in comp.lang.perl.misc:

[...]

> Is there another XML/Parser/Expat.pm somewhere in @INC that is getting loaded
> first?
> 
> Try adding
> 
> BEGIN {
>     $SIG{__DIE__} = sub {
>         die <<DIE
> Parser.pm is $INC{'XML/Parser.pm'}
> Expat.pm  is $INC{'XML/Parser/Expat.pm'}
> $@
> DIE
>     }
> }
> 
> at the top of your program.

Ugh, that won't work.  It's interpolating $INC{ ...} before anything is
loaded.  Did you mean to eval() something?  Otherwise, $@ is useless.

Adapting things a bit, I came up with

    BEGIN {
        $SIG{__DIE__} = sub {
            die "MyLib is $INC{ 'MyLib.pm'}\n" . shift;
        }
    }

    use MyLib;

However, the sub is called tree times (accumulating identical messages)
when MyLib dies.  I don't understand that offhand.

Anno


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

Date: Sun, 22 Feb 2004 08:56:44 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Newbie file / string question
Message-Id: <slrnc3hgpc.j54.tadmc@magna.augustmail.com>

Ren <rlpreston@sbec.com> wrote:

>:10000000E7280530AC00A530AD00AD0B0528AC0BE2
> 
> The data I want to extract are 8 hexadecimal strings, the first of
> which is E728, 


Since you don't tell us _why_ that is the start of the interesting
part, we will have to leave it to you to strip out the leading
stuff. Maybe this would do it:

   s/^:\d{8}//;  # strip prefix

??

> like this:
> 
>:10000000 E728 0530 AC00 A530 AD00 AD0B 0528 AC0B E2


   my @word16 = /(\w{2,4})/g;


> Also, the bytes in the string are reversed. The E728 needs to be 28E7,
> 0530 needs to be 3005 and so on.


   s/(\w\w)(\w\w)/$2$1/ for @word16;  # swap "byte order"


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


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

Date: Sun, 22 Feb 2004 16:46:37 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Newbie file / string question
Message-Id: <c1aj9o$1ganc7$1@ID-184292.news.uni-berlin.de>

Gunnar Hjalmarsson wrote:
> 
>     my @hex;
>     while (<DATA>) {
>         s/:\d{8}//;
>         my @line = map { s/(..)(..)/$2$1/; $_ } /(\w{4})/g;
>         push @hex, [ @line ];
>     }
>     print "@{$hex[0]}\n" for 0..$#hex;

Correction:

     print "@{$hex[$_]}\n" for 0..$#hex;
------------------^^

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



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

Date: 22 Feb 2004 17:27:08 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Newbie file / string question
Message-Id: <c1aopc$lqq$1@mamenchi.zrz.TU-Berlin.DE>

Gunnar Hjalmarsson  <noreply@gunnar.cc> wrote in comp.lang.perl.misc:

>      my @hex;
>      while (<DATA>) {
>          s/:\d{8}//;
>          my @line = map { s/(..)(..)/$2$1/; $_ } /(\w{4})/g;
>          push @hex, [ @line ];

"[ @line ]" makes a needless copy here.  Since @line is declared inside the
loop, "\ @line" is sufficient.

>      }
>      print "@{$hex[0]}\n" for 0..$#hex;

Anno


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

Date: 22 Feb 2004 17:30:54 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Newbie file / string question
Message-Id: <c1ap0e$lqq$2@mamenchi.zrz.TU-Berlin.DE>

Gunnar Hjalmarsson  <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
> Gunnar Hjalmarsson wrote:
> > 
> >     my @hex;
> >     while (<DATA>) {
> >         s/:\d{8}//;
> >         my @line = map { s/(..)(..)/$2$1/; $_ } /(\w{4})/g;
> >         push @hex, [ @line ];
> >     }
> >     print "@{$hex[0]}\n" for 0..$#hex;
> 
> Correction:
> 
>      print "@{$hex[$_]}\n" for 0..$#hex;

Correction:

    print "@$_\n" for @hex;

Anno


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

Date: Sun, 22 Feb 2004 20:16:32 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Newbie file / string question
Message-Id: <c1avk3$1g8ha3$1@ID-184292.news.uni-berlin.de>

Anno Siegel wrote:
> Gunnar Hjalmarsson wrote:
>> Correction:
>>
>>     print "@{$hex[$_]}\n" for 0..$#hex;
> 
> Correction:
> 
>     print "@$_\n" for @hex;

Err.. Better, yes, but both are *correct*, right?

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



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

Date: 22 Feb 2004 19:35:36 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Newbie file / string question
Message-Id: <c1b0a8$ptc$1@mamenchi.zrz.TU-Berlin.DE>

Gunnar Hjalmarsson  <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> > Gunnar Hjalmarsson wrote:
> >> Correction:
> >>
> >>     print "@{$hex[$_]}\n" for 0..$#hex;
> > 
> > Correction:
> > 
> >     print "@$_\n" for @hex;
> 
> Err.. Better, yes, but both are *correct*, right?

Well, yes.  I'd still say it should be replaced, even if it works.  When
I read it first I didn't notice what exactly it does.  Instead, I assumed
that @hex contained stuff that takes some doing to print.

That's the problem with all code that does more than needs to be done.
Even if it doesn't hurt, it leads the reader to false conclusions.

Anno


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

Date: Sun, 22 Feb 2004 19:55:17 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Newbie file / string question
Message-Id: <c1b1d6$l3c$1@news.simnet.is>

"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:c1aopc$lqq$1@mamenchi.zrz.TU-Berlin.DE...
> Gunnar Hjalmarsson  <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
>
> >      my @hex;
> >      while (<DATA>) {
> >          s/:\d{8}//;
> >          my @line = map { s/(..)(..)/$2$1/; $_ } /(\w{4})/g;
> >          push @hex, [ @line ];
>
> "[ @line ]" makes a needless copy here.  Since @line is declared inside
the
> loop, "\ @line" is sufficient.

or drop the variable
    push @hex, [ map { s/(..)(..)/$2$1/; $_ } /(\w{4})/g ];


gnari






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

Date: Sun, 22 Feb 2004 21:19:57 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Newbie file / string question
Message-Id: <c1b3b6$1fc0jo$1@ID-184292.news.uni-berlin.de>

gnari wrote:
> Anno Siegel wrote:
>> Gunnar Hjalmarsson wrote:
>>>
>>>     my @hex;
>>>     while (<DATA>) {
>>>         s/:\d{8}//;
>>>         my @line = map { s/(..)(..)/$2$1/; $_ } /(\w{4})/g;
>>>         push @hex, [ @line ];
>>
>> "[ @line ]" makes a needless copy here.  Since @line is declared
>> inside the loop, "\ @line" is sufficient.
> 
> or drop the variable
>     push @hex, [ map { s/(..)(..)/$2$1/; $_ } /(\w{4})/g ];

I thought of that, and dropped the idea for readability reasons. But 
now when I look at it, it's not *that* terrible. Or is it? ;-)

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



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

Date: 22 Feb 2004 21:16:30 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Newbie file / string question
Message-Id: <c1b67e$77$1@mamenchi.zrz.TU-Berlin.DE>

Gunnar Hjalmarsson  <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
> gnari wrote:
> > Anno Siegel wrote:
> >> Gunnar Hjalmarsson wrote:
> >>>
> >>>     my @hex;
> >>>     while (<DATA>) {
> >>>         s/:\d{8}//;
> >>>         my @line = map { s/(..)(..)/$2$1/; $_ } /(\w{4})/g;
> >>>         push @hex, [ @line ];
> >>
> >> "[ @line ]" makes a needless copy here.  Since @line is declared
> >> inside the loop, "\ @line" is sufficient.
> > 
> > or drop the variable
> >     push @hex, [ map { s/(..)(..)/$2$1/; $_ } /(\w{4})/g ];
> 
> I thought of that, and dropped the idea for readability reasons. But 
> now when I look at it, it's not *that* terrible. Or is it? ;-)

I think it's fine.  The individual components are easy to understand.
It does take some Perl skills to see what the individual components
*are*, but then, it's Perl code.

One perceived problem with this kind of code is that the left-to-right
sequence doesn't represent the sequence of events when the code runs.
Obviously, "/(\w{4})/g" in list context must happen first, but it's almost
last.

The sequence of events is not necessarily the best way to understand the
code.  At least in this case, reading left to right, with a few glances
(one, really) to the end of the statement, gives you what you need to know
in a reasonable sequence.

Another point about compact code is that, when it takes time to read, it
also contains more information per unit than longer code.  It can't be
expected to read as fast.

Anno


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

Date: Sun, 22 Feb 2004 22:09:25 GMT
From: XXjbhuntxx@white-star.com (Cosmic Cruizer)
Subject: Perl causing scheduler to hang
Message-Id: <Xns94979003935D2ccruizermydejacom@64.164.98.50>

I'm using the Windows 2000 Server scheduler to execute a few Perl scripts. 
Unfortunately, several of the scripts appear to be causing the Windows 
scheduler to hang. I'm using Perl, v5.6.1 built for MSWin32-x86-multi-
thread, binary build 631 provided by ActiveState.

This is the only server I'm using this version of Perl and it's the only 
server having problems where Perl appears to be causing the scheduler to 
hang. Has anybody else experienced problems with Perl causing the Windows 
2000 scheduler to hang? If so, did you find a way to resolve the problem?

Thanks


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

Date: Sun, 22 Feb 2004 21:31:41 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: perl fileio
Message-Id: <x7brnqhkcj.fsf@mail.sysarch.com>

>>>>> "t" == toylet  <toylet_at_mail.hongkong.com> writes:

  >> Linux != server && Windows != server
  t> I rather make it:

  t> Linux = (server|client)
  t> Windows = (server|client)

wrong again. stop making up shit.

you can have a box running an OS that is neither a server nor a
client. it could be simply not communicating with any other boxes and so
calling it client or server is dumb. boxes are cpus running an OS. how
they are used is irrelevent to running perl (or any other program) on it.

  >> Linux == OS && Windows == OS
  >> Think about it :-)

  t> I agree.

then stop calling them client or server.

and just to annoy you, what is a box is both a client AND a server? will
your head explode? best to not use those terms unless you have a proper
context and understand it. perl does not need a server nor client to
run. it needs an OS.

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, 22 Feb 2004 22:43:08 GMT
From: Johnny J <johnj@nospam.here.com>
Subject: Private methods within a Perl Object module
Message-Id: <0ga_b.44484$um1.42898@twister.nyroc.rr.com>

I'm doing object oriented programming w/ Perl and created a Perl module 
for a class.  What I am trying to do within the module itself is 
implement private methods or subroutines that can only be used by 
(possibly public) methods within the module; I do not want them 
accessible outside the module.

Here's how I'm trying to do it in the module.  For flexibility, I wanted 
some of my public methods to invoke the private subroutines via a hash 
table to subroutine refs (which are the private subs).  For what I am 
trying to do, this scheme adds much flexibility and manageability, as 
opposed to calling the private subroutines explicitly in the methods by 
name.
-------------------------------------------------
my %PRIVMETHS = ( 'MOVE'  => $prv_MOVE,
                   'WRITE'  => $prv_WRITE,
                   'READ'   => $prv_READ,
                   'DELETE' => $prv_DELETE, );

##### Private Subroutines (not access. to public) ########
my $prv_MOVE = sub {
    ....
}

my $prv_WRITE = sub {
    ....
}

my $prv_READ = sub {
    ....
}

my $prv_DELETE = sub {
    ....
}

##### Public Methods for Object Class  ########
sub action {
   my $self = shift;
   # Method called as $obj->action(<action>, <value>), where <action> is
   # any one of MOVE, WRITE, READ, DELETE, ...

   ...
   $PRIVMETHS{$action}->($value);
   ...
}
-------------------------------------------------

Unfortunately, I have not been able to get this to work.  I have tried 
so many other convolutions to get this to work, even using evals, but no 
go.   Any help would be greatly appreciated!

--john



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

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


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