[12797] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 207 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 21 02:07:26 1999

Date: Tue, 20 Jul 1999 23:05:14 -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           Tue, 20 Jul 1999     Volume: 9 Number: 207

Today's topics:
    Re: Appeasing the Java and Perl naming gods (Abigail)
    Re: basename regexp? (Ronald J Kimball)
    Re: cant install Thread module smnayeem7346@my-deja.com
    Re: Execute file association in Win32 <kenhirsch@myself.com>
    Re: flock() replacement in Win32 ? <cassell@mail.cor.epa.gov>
    Re: Hashes (Tad McClellan)
    Re: How to open database just once? (Abigail)
    Re: Is there a real Perl interpreter for Apache? pgweiss@arity.com
    Re: Is there a real Perl interpreter for Apache? pgweiss@arity.com
        Need help to get DNS IP's <tigrank@inreach.com>
        Newbie: Arrays & Comparing Arrays <scoobyshake@earthlink.net>
        RE: Newbie: Arrays & Comparing Arrays <scoobyshake@earthlink.net>
        RE: Newbie: Arrays & Comparing Arrays (Larry Rosler)
    Re: Porsche: Perl Programmer Please! (Help Wanted) (Ronald J Kimball)
    Re: Possible to tr/// within s/// ??? (elephant)
    Re: Possible to tr/// within s/// ??? <cassell@mail.cor.epa.gov>
    Re: Possible to tr/// within s/// ??? (elephant)
    Re: Reading binary files (Abigail)
        recursive anonymous functions -- problem (Rachael Ludwick)
    Re: recursive anonymous functions -- problem (elephant)
    Re: regular Expression (Ilya Zakharevich)
    Re: regular Expression (Ronald J Kimball)
    Re: regular Expression (Abigail)
        Runtime Error in LanMan EnumShares <gio98dr@yahoo.com>
    Re: Unique IP Address Extraction (Larry Rosler)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 21 Jul 1999 00:43:24 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Appeasing the Java and Perl naming gods
Message-Id: <slrn7paneo.oqh.abigail@alexandra.delanet.com>

Bill Wohler (wohler@gbr.newt.com) wrote on MMCXLIX September MCMXCIII in
<URL:news:vplncb82ic.fsf@gbr.newt.com>:
;; 
;;   I'd like to be able to put Bar.pm and Bar.java in the same
;;   directory. How do you resolve this dilemma? My thoughts would be to
;;   follow the Java conventions and use lowercase package names. How
;;   "bad" would it be to put Bar.pm in com/newt/foo and invoke it with
;;   com::newt::foo?


Try it, and then answer the following questions:

    -  Did your wife blow up?
    -  Did you get pimples?
    -  Did your car break down?
    -  Did your cat run away from home?
    -  Did your daughter start dating a drug dealer?
    -  Did you find a hair on your toothbrush?
    -  Did the TV network move your favourite show to 4 am?
    -  Did the pizza never get delivered?
    -  Did your goldfish die?
    -  Did your mother-in-law permanently move in?
    -  Did your boss assign you to a Cobol Y2K project?

If you answer 6 or more times 'no', how "bad" would it have been?



Abigail
-- 
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
                                      print } sub __PACKAGE__ { &
                                      print (     __PACKAGE__)} &
                                                  __PACKAGE__
                                            (                )


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Wed, 21 Jul 1999 00:52:00 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: basename regexp?
Message-Id: <1dv9mu0.rpgcmx110b9z4N@p55.tc18.metro.ma.tiac.com>

Jona Andersen <jona@ds10.hobby.nl> wrote:

> I need to know the name of my script.
> $0 you'd say right? I know, but I just want the name, not the full
> pathname.
> I'd rather not use a shell
> Now I don't speak too fluently regular expressions (nor perl, for that
> matter),
> So, how do I strip the full path?


A basename regexp, you say?


($script = $0) =~ s/(.*)/use File::Basename;basename($1)/se;


Enjoy!


-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
       perl -le 'print "Just another \u$^X hacker"'


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

Date: Wed, 21 Jul 1999 04:01:58 GMT
From: smnayeem7346@my-deja.com
Subject: Re: cant install Thread module
Message-Id: <7n3gnh$h28$1@nnrp1.deja.com>



In article <O6al3.16963$y92.9367@news.rdc1.ct.home.com>,
  <dan@tuatha.sidhe.org> wrote:
> smnayeem7346@my-deja.com wrote:
> > Does anyone know why I cannot install the Thread module. I went to
the
> > threads directory and installed it using perl Makefile.pl, make,
> > make test, make install.
> > however when i try to use it in the program it says cant find in
@INC.
>
> You have enable thread support and build the Thread module when you
first
> build perl. It can't be done after the fact.

But I have already had perl installed. And there doesnt seem to be any
way of uninstalling except for maybe resetting up the whole computer
from scratch again (or is there?)
Or do I just install Perl again? but last time I did it I ended up
having many perls installed and had hard time keeping track of where is
which perl (and I only needed one).

>
> > and one more question is how do i install this module under winNT?
it
> > gives error when i try perl makefile.pl
>
> I don't know that anyone's actually built it under WinNT.
>
> 					Dan
>
So is it that the Win32::Process is a good alternative to threads in
Windows? Actually apart from forking I dont know all the details (such
as memory complexities, process killing etc) of neither Threads nor
Win32::Process. So does anyone know where I can find good examples of
the use of any /all of these modules?
And what IS the difference between Forks, Threads and Win32::Process??

Any help would be greatly appreciated.

Nayeem
smnayeem@agni.com
Programmer, Agni Systems Ltd.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 20 Jul 1999 23:56:09 -0400
From: "Ken Hirsch" <kenhirsch@myself.com>
Subject: Re: Execute file association in Win32
Message-Id: <7n3gic$qrf$1@ash.prod.itd.earthlink.net>


Andy Davidson <pheon@hevanet.com> wrote
> What
> I want is a way to cause a browser to be launched by 'running' a .html
> file.  In other words, from a perl script I want to cause the same
> action that occurs when I use the Start Menu 'Run' command and enter
> 'index.html' without my having to know which browser they have
> installed.

system("start index.html");






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

Date: Tue, 20 Jul 1999 20:05:29 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: flock() replacement in Win32 ?
Message-Id: <379538F9.9E023A9F@mail.cor.epa.gov>

arpith@hotmail.com wrote:
> [my response unattributed, but I'm foolishly claiming it]
> > It won't work reliably.  There are icky, non-atomic kludges to try
> > to get around this [like creating a lock file when you want the file
> > to be locked, and deleting it when your process is finished writing -
> > note
> > that this is generally considered A Bad Idea (tm) and can cause
> > annoying failures when the lock file doesn't get deleted].  But if
> > your website is going to be fairly low-traffic, you should be able to
> > get away with this for the most part.
> 
> I'm really only learning it on win95. So i guess, finally it will be on
> a Unix system. But till then I am using all the scripts as CGIs on a

Well, linux and several BSD-ish versions of unix all run on PC
hardware.  If you have the hardware to run a webserver on win95,
you may already have the hardware to run linux on the same machine.

> win95 platform.. on my computer using a Free server. But I may get a few
> people to test it, and they may be on simultaneously.. so...

If you go to Randal Schwartz's website, you can read some of his
past computer columns.  They might help you with your CGI scripts.
I can't tell from here what CGI programs you're using, but some
of them are ugly pieces of junk that make the lockfile kludge look
elegant.

> I guess, I will try the lock file.. how does it work ? Just create a
> lock file OR create a lock file and keep changing a value inside:
> 1/0/1/0 etc.. ??

Each process, before writing to the file, checks to see if the
lockfile exists.  If so, it waits.  If not, it creates the lockfile,
then writes to the file, then closes the file and deletes the 
lockfile.  This has *lots* of technical flaws, but it may hold you
until you move to unix.  The worst problem is that this is not
'atomic', so that in between that check and the file-creation, 
another process has the time to waltz in and create the file for
itself.  Then what happens?  [Answer: icky stuff]  Another
highlight is a system hang, which could leave an orphan lockfile
lying around with no one to delete it - so nothing gets written
to your guestbook until you find the lockfile and delete it.
So don't do this unless someone is pointing a gun at your mother,
or other equally desperate situations.

> Also shouldn't windows in general already have some file protecting
> mechanism like share.exe or something ???

It certainly should.  :-(  But I don't think that share.exe will
do what you seem to expect of it.
 
HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Tue, 20 Jul 1999 18:06:28 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Hashes
Message-Id: <4tr2n7.2s6.ln@magna.metronet.com>

05317@stblaw.com wrote:
: In using Hashes, every once in a while I get, Odd number of elements in
: hash.  What am I doing wrong ?


   You are giving an odd number of elements in a hash   :-)


: these hashes have at least 4500 items in them.


   You very likely have a bug in your code somewhere if you
   are getting that message.

   Of course we can't really help you, 'cause we haven't seen
   any of the code.


   All of the messages that perl might generate are documented
   in the 'perldiag.pod' file that comes with perl.

   For your message it says:

----------------------------------------
=item Odd number of elements in hash assignment

(S) You specified an odd number of elements to initialize a hash, which
is odd, because hashes come in key/value pairs.
----------------------------------------


   When you do something like:

      %h = ( 'key1', 'value1', 'key2', 'value2', 'key3' );


   the assignment is done in *pairs*, so there better be an _even_
   number of them.

   But you have an odd number, so something is probably Not Right...


   Go look over all your hash assignments (this will find _some_ of them):

      perl -ne 'print if /%\w+\s*=/' myprog


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 20 Jul 1999 23:59:46 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: How to open database just once?
Message-Id: <slrn7paksu.oqh.abigail@alexandra.delanet.com>

yangsu@ustc.edu (yangsu@ustc.edu) wrote on MMCXLIX September MCMXCIII in
<URL:news:7n257q$vc5$1@nnrp1.deja.com>:
|| My thought is that I can have some function like init() which
|| will be called just once when the program runs. because the

Uhm, perhaps there is. But it has such a silly name, INIT, that you
would have never ever guessed it to search the manual for that.

|| database operation is frequent and I don't want to waste time
|| open the database connection again and again.
|| 
|| I also hope I can have a cleanup function available when the program
|| exits. This is done only once. (so it is similar to java servlet)

There is. This time, I ain't giving the answer. But it's in the manual.



Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Wed, 21 Jul 1999 04:19:20 GMT
From: pgweiss@arity.com
Subject: Re: Is there a real Perl interpreter for Apache?
Message-Id: <7n3ho1$hcc$1@nnrp1.deja.com>

FastCGI seems like what you want, see
http://www.fastcgi.com.

In article <oghhrecn.fsf@centernet.jhuccp.org>,
  James Meacham <jmeacham@intranet.jhuccp.org> wrote:
> I've spent some time looking for what seems to me an obvious need: a
way
> of using real Perl as a server-side WWW language with Apach/mod_perl.
> What I'm looking for is a module that will allow me to do things like
> this:
>
> <UL>
> <script language="perl">
> @somethings = qw(This that theother) ;
> foreach $thing (@somethings) {
> print "<LI>$thing\n" ;
> }
> </script>
> </UL>
>
> where any output going to STDOUT would instead go into the http
stream.
> Like javascript only with a language the has a full number of
features.
> Here are the things I've considered already and the reasons they
don't fit
> the bill:
>
> Embperl: Doesn't use real perl.  Uses perl-like constructs, e.g.,
>
> [$ if
> $ENV{REQUEST_METHOD} eq 'GET' $]
> This is a GET request
> [$ elsif $ENV{REQUEST_METHOD} eq 'POST' $]
> This is a POST request
> [$ else $]
> This is not GET and not POST
> [$ endif $]
>
> Eperl: Is aimed at ASCII, not HTML, and mod_perl is only partially
supported
>
> HTML::EP: No mod_perl support
>
> PerlEx: Only available for NT
>
> PHP: I want perl, dammit!
>
> VelociGen: Commercial, doesn't compile with my version of Apache
>
> So, can anyone help me?  It seems like it should be a relatively easy
> thing to do (says he of the limited programming skills).  Thanks,
>
> James
>
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 21 Jul 1999 04:19:23 GMT
From: pgweiss@arity.com
Subject: Re: Is there a real Perl interpreter for Apache?
Message-Id: <7n3ho3$hcd$1@nnrp1.deja.com>

FastCGI seems like what you want, see
http://www.fastcgi.com.

In article <oghhrecn.fsf@centernet.jhuccp.org>,
  James Meacham <jmeacham@intranet.jhuccp.org> wrote:
> I've spent some time looking for what seems to me an obvious need: a
way
> of using real Perl as a server-side WWW language with Apach/mod_perl.
> What I'm looking for is a module that will allow me to do things like
> this:
>
> <UL>
> <script language="perl">
> @somethings = qw(This that theother) ;
> foreach $thing (@somethings) {
> print "<LI>$thing\n" ;
> }
> </script>
> </UL>
>
> where any output going to STDOUT would instead go into the http
stream.
> Like javascript only with a language the has a full number of
features.
> Here are the things I've considered already and the reasons they
don't fit
> the bill:
>
> Embperl: Doesn't use real perl.  Uses perl-like constructs, e.g.,
>
> [$ if
> $ENV{REQUEST_METHOD} eq 'GET' $]
> This is a GET request
> [$ elsif $ENV{REQUEST_METHOD} eq 'POST' $]
> This is a POST request
> [$ else $]
> This is not GET and not POST
> [$ endif $]
>
> Eperl: Is aimed at ASCII, not HTML, and mod_perl is only partially
supported
>
> HTML::EP: No mod_perl support
>
> PerlEx: Only available for NT
>
> PHP: I want perl, dammit!
>
> VelociGen: Commercial, doesn't compile with my version of Apache
>
> So, can anyone help me?  It seems like it should be a relatively easy
> thing to do (says he of the limited programming skills).  Thanks,
>
> James
>
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 20 Jul 1999 20:16:00 -0700
From: Tigran <tigrank@inreach.com>
Subject: Need help to get DNS IP's
Message-Id: <37953B70.F3506579@inreach.com>

Hi,

I have a problem w/ below code, I'm trying to get IP addresses from
domain,
but I'm getting same IP's when in loop.  Anybody knows what's going on,
only don't
tell me to use Net:DNS, it's slow (I mean very slow).

Thanks, Tigran.

Here is the simple code:

END:
while ( 1 )
{
     ( $nme, $als, $adtyp, $length,  @addrs ) = gethostbyname
('ftp.netscape.com');
     ( $a, $b, $c, $d ) = unpack ( 'C4', $addrs[0] );
     $ftp_address = join ( ".", $a, $b, $c, $d  );
     push ( @ftp_address_array, $ftp_address );
     $array_length = @ftp_address_array;

     if ( $array_length != 1 )
         {
              for ( $i = 0; $i < $array_length; $i++ )
                  {
                       last END if ( $ftp_address_array[$i] =~
/$ftp_address/ );
                  }
         }

     next;
}




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

Date: Tue, 20 Jul 1999 22:13:48 -0500
From: James Deleon <scoobyshake@earthlink.net>
Subject: Newbie: Arrays & Comparing Arrays
Message-Id: <37953AEC.B29F4936@earthlink.net>

I've created 2 arrays that consists
of lines from a file that contain a
particular word.
The resulting arrays looks like:

word1 word2 word3 word4    # Array
1. All lines contain word1
word1 word5 word6 word7
word1 word8 word9 word10

word11 word2 word13 word14    #
Array 2. All lines contain word11
word11 word5 word16 word17
word11 word18 word19 word20

How do print words from
array1-column2 that do not exist in
array2-column2,
and words from array2-column2 that
are not in array1-column2?

Output should be:
# words in array1 not array2
(column2)
word8
# words in array2 not array1
(column2)
word18


james




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

Date: Tue, 20 Jul 1999 22:52:22 -0500
From: James Deleon <scoobyshake@earthlink.net>
To: scoobyshake@earthlink.net
Subject: RE: Newbie: Arrays & Comparing Arrays
Message-Id: <379543F5.864DF1AA@earthlink.net>

Sorry.  The previous message should have looked as follows.

I've created 2 arrays that consists of lines from a file that contain a
particular word. The resulting arrays looks like:

word1 word2 word3 word4    # Array1. All lines contain word1
word1 word5 word6 word7
word1 word8 word9 word10

word11 word2 word13 word14    #Array 2. All lines contain word11
word11 word5 word16 word17
word11 word18 word19 word20

How do print words from array1-column2 that do not exist in array2-column2,
and words from array2-column2 that are not in array1-column2?

Output should be:
# words in array1 not array2 (column2)
word8
# words in array2 not array1 (column2)
word18

james




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

Date: Tue, 20 Jul 1999 22:29:51 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: RE: Newbie: Arrays & Comparing Arrays
Message-Id: <MPG.11fefaa33af0d231989d08@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <379543F5.864DF1AA@earthlink.net> on Tue, 20 Jul 1999 
22:52:22 -0500, James Deleon <scoobyshake@earthlink.net> says...
> Sorry.  The previous message should have looked as follows.
> 
> I've created 2 arrays that consists of lines from a file that contain a
> particular word. The resulting arrays looks like:
> 
> word1 word2 word3 word4    # Array1. All lines contain word1
> word1 word5 word6 word7
> word1 word8 word9 word10
> 
> word11 word2 word13 word14    #Array 2. All lines contain word11
> word11 word5 word16 word17
> word11 word18 word19 word20
> 
> How do print words from array1-column2 that do not exist in array2-column2,
> and words from array2-column2 that are not in array1-column2?
> 
> Output should be:
> # words in array1 not array2 (column2)
> word8
> # words in array2 not array1 (column2)
> word18

Read the section on Arrays in perlfaq4 to get a better handle on what's 
going on in this program.


#!/usr/local/bin/perl -w
use strict;

my @array1 = (
  'word1 word2 word3 word4',
  'word1 word5 word6 word7',
  'word1 word8 word9 word10',
);

my @array2 = (
  'word11 word2 word13 word14',
  'word11 word5 word16 word17',
  'word11 word18 word19 word20',
);

my (%hash1, %hash2);
@hash1{map { (split)[1] } @array1} = ();
@hash2{map { (split)[1] } @array2} = ();

print "# words in array1 not array2 (column2)\n";
print map "$_\n", sort grep !exists $hash2{$_}, keys %hash1;
print "# words in array2 not array1 (column2)\n";
print map "$_\n", sort grep !exists $hash1{$_}, keys %hash2;

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 21 Jul 1999 00:52:04 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Porsche: Perl Programmer Please! (Help Wanted)
Message-Id: <1dv9no3.d310ca1po54c1N@p55.tc18.metro.ma.tiac.com>

Brian Tully <gstock@gstockco.com> wrote:

> Looking for Perl programmer(s)/web developers to help write/edit CGI scripts
> for Porsche's web sites.  mSQL a big plus.  Exciting opportunity.  Flexible
> arrangements.

I have two words for you:  Company car?

(Who cares if I can work from home.  That's not the point!)

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Wed, 21 Jul 1999 13:08:37 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: Possible to tr/// within s/// ???
Message-Id: <MPG.11ffe4c21f38b0a3989b59@news-server>

Robert Lowe writes ..
>How can one use s/FOO/foo/, when FOO is determined in the context of
>a regular expression?  In this case, I was interested in replacing
>USERNAME@domain.com with username@domain.com, when found at the
>beginning of a line.  Is this possible with one line?

assuming that you're happy with lc's version of lower case alphabetics

  s/^(\S+)(@\S+\.\S+)/ lc( $1) . $2/e;

-- 
 jason - remove all hyphens for email reply -


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

Date: Tue, 20 Jul 1999 20:18:01 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Possible to tr/// within s/// ???
Message-Id: <37953BE9.4998D259@mail.cor.epa.gov>

Robert Lowe wrote:
> 
> Just curious...
> 
> How can one use s/FOO/foo/, when FOO is determined in the context of
> a regular expression?  In this case, I was interested in replacing
> USERNAME@domain.com with username@domain.com, when found at the
> beginning of a line.  Is this possible with one line?

Yes, given a list of caveats as long as your arm.  If you're 
just interested in the dynamics of the language, or you can
control how the local-part [the 'USERNAME' part] looks, you
can just say something like:

$line =~ s/(\S+)\@\w+(?:\.\w+)*/ lc $1/e;

But this is hardly adequate to handle the full scope of
RFC 822-compliant e-mail addresses.  The subject has been 
thrashed out here many times.  If you really want a regex to
do full [well, nearly full] handling of all the possible
legal addresses, then you have to go to something like the
4,274 byte regex in the last chapter of Jeffrey Friedl's
"Mastering Regular Expressions".  The line above is not
going to handle a lot of components of a legal address,
starting with spaces in comments to the left of the at-sign
and going from there onward.  

So, as long as you don't care about that, the
expression-in-the-right-hand-side bit should do what you 
want.  

And lc() will work better when you say 'use locale;' than 
tr/// will.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 21 Jul 1999 13:51:32 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: Possible to tr/// within s/// ???
Message-Id: <MPG.11ffeeccee304bb6989b5b@news-server>

Uri Guttman writes ..
>	s/(whatever)/\L$1/ ;

doh ! .. forgot about that one

-- 
 jason - remove all hyphens for email reply -


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

Date: 21 Jul 1999 00:35:01 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Reading binary files
Message-Id: <slrn7pamv2.oqh.abigail@alexandra.delanet.com>

Randal L. Schwartz (merlyn@stonehenge.com) wrote on MMCXLIX September
MCMXCIII in <URL:news:m1wvvvxqgp.fsf@halfdome.holdit.com>:
@@ >>>>> "Kim" == Kim Saunders <kims@emmerce.com.au> writes:
@@ 
@@ Kim> a quick question: Can someone pls help me out with a bit of code to read
@@ Kim> data from a binary file (an image), and then print it out to STDOUT??? J
@@ Kim> can't find it ANYWAY, pls email me the 3 or whatever lines!
@@ 
@@ <abigail>
@@ system 'cat','image';
@@ </abigail>


Oh, first Larry is trying to imitate me, now Randal.... 


Abigail
-- 
And I'm not even dead yet!


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Wed, 21 Jul 1999 03:45:18 GMT
From: raludwicREMOVETHIS@u.arizona.edu (Rachael Ludwick)
Subject: recursive anonymous functions -- problem
Message-Id: <37953b84.5879100@news.arizona.edu>

I have code something like the following:

my $func = sub {
    my $param = shift;
    if($param > 1) { 
        return $param * &$func($param - 1);
    }
    else {
        return 1;
    }
}

Now, this won't compile with something like this:
    "Global symbol $func requires explicit package name"
(I use strict).

This bothers me because it is basically not recognizing
it's definition, but if one does

sub func {
    my $param = shift;
    if($param > 1) { 
        return $param * func($param - 1);
    }
    else {
        return 1;
    }
}

then it compiles fine, even though func as a normal function 
is just as "undefined" as the variable $func -- both are in the middle
of being defined.

So am I missing something fundamental about the meaning of 
anonymous functions and closures or is this something that is just
missing from the language that does make sense to have?  Or something
else?



(PS I tried to read the faq, but could find one specifically for any
of the comp.lang.perl.* that wasn't at least 2 years old, so I gave
up.  But then, I don't expect that this would be a faq!  I also
couldn't determine which of the comp.lang.perl.* would be the best to
post this in, so...?)
--
Rachael Ludwick
raludwic@REMOVEu.arizona.edu
http://www.u.arizona.edu/~raludwic


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

Date: Wed, 21 Jul 1999 14:47:01 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: recursive anonymous functions -- problem
Message-Id: <MPG.11fffbd2588f3602989b5c@news-server>

Rachael Ludwick writes ..
>I have code something like the following:
>
>my $func = sub {
>    my $param = shift;
>    if($param > 1) { 
>        return $param * &$func($param - 1);
>    }
>    else {
>        return 1;
>    }
>}

you need to learn more about 'my' and how it is scoped in this instance 
 .. the following will work

#--begin
my $func;
$func = sub {
    my $param = shift;
    if($param > 1) { 
        return $param * &$func($param - 1);
    }
    else {
        return 1;
    }
}
#--end

-- 
 jason - remove all hyphens for email reply -


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

Date: 21 Jul 1999 04:27:47 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: regular Expression
Message-Id: <7n3i83$eca$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Tom Christiansen 
<tchrist@mox.perl.com>],
who wrote in article <3794c4ff@cs.colorado.edu>:
> And perlre (that's 5.005_57, mind you) also brands these "very
> experimental".  I don't think it's fair to chastise someone
> for not using a "very experimental" feature.

Try to guess using 3 tries: who wrote this "very experimental" catchphrase?

Ilya


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

Date: Wed, 21 Jul 1999 00:52:05 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: regular Expression
Message-Id: <1dv9ny5.1rnd6bmrwq28yN@p55.tc18.metro.ma.tiac.com>

Tom Christiansen <tchrist@mox.perl.com> wrote:

> Daniel Grisinger <dgris@perrin.dimensional.com> writes:
> :The perlfaq* documents are primarily political pieces 
> 
> I cannot believe that you believe that.  But if they are, they should
> be deleted from the distribution.  Before we do that, do you consider
> Larry's TMTOWTDI a political statement, or not?

Well, there were those comments in perlfaq5 about 'Prisoners of Bill'
and 'paying the billtax'.  Happily, Tom and I worked out a patch to
rephrase that section, which in fact removed the OS-specific comments
entirely.

Perhaps there are similar comments elsewhere in the FAQs that Daniel is
referring to?  I think he should go ahead and submit a patch; it worked
for me.

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 21 Jul 1999 00:12:41 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: regular Expression
Message-Id: <slrn7pall5.oqh.abigail@alexandra.delanet.com>

Tom Christiansen (tchrist@mox.perl.com) wrote on MMCXLIX September
MCMXCIII in <URL:news:3794c4ff@cs.colorado.edu>:
``      [courtesy cc of this posting mailed to cited author]
`` 
`` In comp.lang.perl.misc, 
``     Daniel Grisinger <dgris@perrin.dimensional.com> writes:
`` :# snipped straight from perlre
`` :$re = qr{ \(
`` :            (?:
`` :             (?> [^()]+ )  # non-parens, no backtracking
`` :            |
`` :             (?p{$re})     # me, again
`` 
`` And perlre (that's 5.005_57, mind you) also brands these "very
`` experimental".  I don't think it's fair to chastise someone
`` for not using a "very experimental" feature.


I've given the "detect whether an expression has balanced parenthesis"
so often to newbie students, and it's so trivial to do in any language,
I wouldn't even think 'regex' if I want to solve this.

for (my $i = my $c = 0; $i < length ($str); $i ++) {
    my $char = substr ($str, $i, 1);
    $c ++ if $char eq '(';
    $c -- if $char eq ')';
    die "Not balanced" if $c < 0;
}
die "Not balanced" if $c;


Extracting the balanced pieces is left as an exercise to the reader.


Abigail
-- 
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
                                      print } sub __PACKAGE__ { &
                                      print (     __PACKAGE__)} &
                                                  __PACKAGE__
                                            (                )


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Wed, 21 Jul 1999 03:23:57 GMT
From: "Giovanni Davila" <gio98dr@yahoo.com>
Subject: Runtime Error in LanMan EnumShares
Message-Id: <h3bl3.2911$OP.8460@news1.frmt1.sfba.home.com>

I'm getting all the shares from my NT servers but when this function fails I
get a  "runtime error". Even though, I'm using if (!Win32::LanMan....) my
function does not seem to handle the  error and it quits.
Any ideas?
Thank you.




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

Date: Tue, 20 Jul 1999 21:59:35 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Unique IP Address Extraction
Message-Id: <MPG.11fef38ba3584a35989d07@nntp.hpl.hp.com>

In article <7n2qia$6n0$1@bbnews1.unisys.com> on Tue, 20 Jul 1999 
16:43:33 -0500, Paul Glidden <paul.glidden@unisys.com> says...
 ... 
> @unique_ip="";

I presume you mean

  @unique_ip = ();

But you don't want an array anyhow; you want a hash.

> open (INFILE,"filename");
> while ($line=<INFILE>)
> {
>     chomp $line;
>     @array= split /;/,$line;
>     $ip = pop @array;

A bit nicer:

      my $ip = (split /;/, $line)[-1];

>     foreach $unique (@unique_ip)
>     {
>         code to test each ip for uniqueness
>     }
> }

I assume you push $ip onto @unique_ip if this loop fails to find it.  
This is an O(N**2) algorithm, which might well matter for this 
reasonably large data set.  The Right Way To Do It is to read perlfaq4: 
"How can I extract just the unique elements of an array?"

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V9 Issue 207
*************************************


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