[12194] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5794 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 26 18:07:36 1999

Date: Wed, 26 May 99 15:00:25 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 26 May 1999     Volume: 8 Number: 5794

Today's topics:
        ActivePerl 516 install fails (Win32) mkx@excite.com
    Re: Error with HTTP::Message <gisle@aas.no>
    Re: Flexibility questions.... <jdporter@min.net>
        Funny Interaction Between \. and ?? <william.fisher@nist.gov>
    Re: Funny Interaction Between \. and ?? <tchrist@mox.perl.com>
    Re: Funny Interaction Between \. and ?? <garethr@cre.canon.co.uk>
    Re: Funny Interaction Between \. and ?? (Andrew Johnson)
    Re: gettin a "file" argument in perl (Bob Trieger)
        Getting iODBC to work with SequeLink. <brian.findley@brightware.com>
    Re: Help needed! <upsetter@ziplink.net>
    Re: Help needed! <jdporter@min.net>
    Re: Help needed! (Larry Rosler)
        Help, I'll pay money for solution!!! <barr@hancock.net>
    Re: leeches, compilers, and perl, oh my (all mine?) <rra@stanford.edu>
        location of socket.pm <dbws@----nospam----hotmail.com>
    Re: location of socket.pm <rra@stanford.edu>
    Re: Nested Data in MySQL.. getting at it with DBI.. <jll@skynet.be>
        Non-blocking Sockets on Win32 (Malcolm Hoar)
    Re: OO: Perl resources <cassell@mail.cor.epa.gov>
    Re: Open a textfile with a cgi-programm (Larry Rosler)
    Re: Pattern Matching -- Up a Certain Creek with no Padd (Larry Rosler)
    Re: Pattern Matching -- Up a Certain Creek with no Padd <uri@sysarch.com>
    Re: Pattern Matching -- Up a Certain Creek with no Padd (Larry Rosler)
    Re: Pattern Matching -- Up a Certain Creek with no Padd <jdporter@min.net>
    Re: perl -w, "uninitialized" variables, and the Perl la (Andrew Allen)
    Re: perl -w, "uninitialized" variables, and the Perl la <macintsh@cs.bu.edu>
    Re: perl -w, "uninitialized" variables, and the Perl la (Andrew Allen)
    Re: Perl compiler...If or when <*@qz.to>
        Perl Help needed (Bhavesh Gosar)
    Re: Perl Help needed (Bob Trieger)
        Perl Newbie Question <brybunch@ix.netcom.com>
        perl syntax error <jahn@bluecloud.com>
    Re: PERLFUNC: y/// - transliterate a string <cassell@mail.cor.epa.gov>
    Re: Please help ? (Larry Rosler)
    Re: removings " "s from strings <latsharj@my-deja.com>
    Re: system command to string (DATE) <jeromeo@atrieva.com>
        using ~ with chdir <hamiltaj@sgi.com>
    Re: using ~ with chdir <tchrist@mox.perl.com>
        workarounds for prototypes (Tim Herzog)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 26 May 1999 21:30:51 GMT
From: mkx@excite.com
Subject: ActivePerl 516 install fails (Win32)
Message-Id: <3751672f.4069721@news.iag.net>

I am attempting to install ActivePerl build 516, to update my Perl
Resource Kit, on a Windows NT workstation. No matter what I do, the
upgrade always generates a Dr.Watson in _INS0432._MP.exe.

I have attempted to upgrade a plain PRK install, a PRK with Service
Pack 1. The only time I was able to get AP 516 to install was in an
empty directory, but this does not upgrade my PRK.

Has anyone else encountered this problem? Found a solution?



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

Date: 26 May 1999 23:13:09 +0200
From: Gisle Aas <gisle@aas.no>
Subject: Re: Error with HTTP::Message
Message-Id: <m3aeurpmai.fsf@eik.g.aas.no>

kawaru@my-dejanews.com writes:

> I'm trying to write a cgi script in perl that will
> POST to another cgi program.  When I try to create
> a HTTP::Request as a POST operation in the format:
> 
> my $req = new HTTP::Request POST =>
> 'http://test.test.com/test.cgi',
>   [ page => 'test',
>     test1 => 'test',
>     test2 => 'test',
>     test3 => 'test'];
>   $req->authorization_basic('username',
> 'password');
> 
> I get the error:
> 
> Can't call method "clone" on unblessed reference
> at C:\Perl\site\5.005\lib/HTTP/Message.pm line 50.

Try to write it like this instead:

   use HTTP::Request::Common qw(POST);
   my $req = POST 'http://test.test.com/test.cgi',
                  [ page => 'test',
                    test1 => 'test',
                    test2 => 'test', 
                    test3 => 'test'
                  ];
   $req->authorization_basic('username', 'password');
   #print $req->as_string;

-- 
Gisle Aas


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

Date: Wed, 26 May 1999 20:30:01 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Flexibility questions....
Message-Id: <7ihlk6$b9h$1@nnrp1.deja.com>

In article <7ihfd7$6d3$1@nnrp1.deja.com>,
  jknoll@my-deja.com wrote:
> I am a Information systems intern for a large Honda supplier called
> Indiana Percision Technology.  I am in charge of researching different
> tools to develope their webpage.
> How does Perl rate on the following?

You'll pardon us if our opinions arene't exactly unbiased...  :-)


> Database linkability

  10

> Cross platform ability

  10

> Easy to learn?

  Anywhere from 1 to 10, depending on who's doing the learning.

> Performance?

  See Kernighan and VanWyk's research at:
  http://inferno.bell-labs.com/cm/cs/who/bwk/interps/pap.html

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


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


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

Date: Wed, 26 May 1999 16:44:03 -0400
From: Bill Fisher <william.fisher@nist.gov>
Subject: Funny Interaction Between \. and ??
Message-Id: <374C5D13.5E16@nist.gov>

In investigating a problem in which "?" looked like
an anti-greedy quantifier, I boiled it down to this:

Executing

 echo "dog ... cat" | perl -pe 's/\./boom/;'

yields "dog boom.. cat", properly.

but executing

echo "dog ... cat" | perl -pe 's/\.\b/boom/;'


yields "dog ... cat", NO CHANGE!


  Why can't it find a period followed by a word boundary?

  Nobody here can figure this out.

  Many thanks if you can help.

-- 
Bill Fisher


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

Date: 26 May 1999 14:56:28 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Funny Interaction Between \. and ??
Message-Id: <374c5ffc@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, Bill Fisher <william.fisher@nist.gov> writes:
:In investigating a problem in which "?" looked like
:an anti-greedy quantifier, I boiled it down to this:
:
:Executing
: echo "dog ... cat" | perl -pe 's/\./boom/;'
:yields "dog boom.. cat", properly.
:but executing
:echo "dog ... cat" | perl -pe 's/\.\b/boom/;'
:yields "dog ... cat", NO CHANGE!
:
:  Why can't it find a period followed by a word boundary?
:  Nobody here can figure this out.
:  Many thanks if you can help.

You have no word boundary after the period.  m#\.\b# is 
just like saying m#\.(?=\w)#, and as you see, there's no 
\w following the period.

>From perlfaq6.pod, on your very system:

    =head2 Why don't word-boundary searches with C<\b> work for me?

    Two common misconceptions are that C<\b> is a synonym for C<\s+>, and
    that it's the edge between whitespace characters and non-whitespace
    characters.  Neither is correct.  C<\b> is the place between a C<\w>
    character and a C<\W> character (that is, C<\b> is the edge of a
    "word").  It's a zero-width assertion, just like C<^>, C<$>, and all
    the other anchors, so it doesn't consume any characters.  L<perlre>
    describes the behavior of all the regex metacharacters.

    Here are examples of the incorrect application of C<\b>, with fixes:

	"two words" =~ /(\w+)\b(\w+)/;          # WRONG
	"two words" =~ /(\w+)\s+(\w+)/;         # right

	" =matchless= text" =~ /\b=(\w+)=\b/;   # WRONG
	" =matchless= text" =~ /=(\w+)=/;       # right

    Although they may not do what you thought they did, C<\b> and C<\B>
    can still be quite useful.  For an example of the correct use of
    C<\b>, see the example of matching duplicate words over multiple
    lines.

    An example of using C<\B> is the pattern C<\Bis\B>.  This will find
    occurrences of "is" on the insides of words only, as in "thistle",
    but not "this" or "island".

Make sense?

--tom
-- 
And don't tell me there isn't one bit of difference between null and space,
because that's exactly how much difference there is.  :-)
        --Larry Wall in <10209@jpl-devvax.JPL.NASA.GOV>


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

Date: Wed, 26 May 1999 21:01:32 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: Funny Interaction Between \. and ??
Message-Id: <sin1yrbl5f.fsf@cre.canon.co.uk>

Bill Fisher <william.fisher@nist.gov> wrote:
> executing
> 
> echo "dog ... cat" | perl -pe 's/\.\b/boom/;'
> 
> yields "dog ... cat", NO CHANGE!

Take a look at `perldoc perlre':

     A word boundary (\b) is defined as a spot between two
     characters that has a \w on one side of it and a \W on the
     other side of it (in either order), counting the imaginary
     characters off the beginning and end of the string as
     matching a \W

So your string "dog ... cat" has exactly four word boundaries, as you
can check for yourself by executing:

     perl -e '$_ = "dog ... cat"; s/\b/<BOUNDARY>/g; print'

-- 
Gareth Rees


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

Date: Wed, 26 May 1999 21:10:17 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: Funny Interaction Between \. and ??
Message-Id: <ZqZ23.27164$Q_5.4157792@news2.rdc1.on.home.com>

In article <374C5D13.5E16@nist.gov>,
 Bill Fisher <william.fisher@nist.gov> wrote:
! In investigating a problem in which "?" looked like
! an anti-greedy quantifier, I boiled it down to this:
! 
! Executing
! 
!  echo "dog ... cat" | perl -pe 's/\./boom/;'
! 
! yields "dog boom.. cat", properly.
! 
! but executing
! 
! echo "dog ... cat" | perl -pe 's/\.\b/boom/;'
! 
! 
! yields "dog ... cat", NO CHANGE!
! 
! 
!   Why can't it find a period followed by a word boundary?

Because there isn't a period followed a word boundary
in that string. A word boundary exists between a \w and a \W
character (or vica-versa) ... periods are \W as are spaces,
hence, no \.\b

refresh yourself with 'man perlre' (or 'perldoc perlre')

regards
andrew
 


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

Date: Wed, 26 May 1999 21:43:55 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: gettin a "file" argument in perl
Message-Id: <7ihoci$a93$1@oak.prod.itd.earthlink.net>

[ courtesy cc sent by mail if address not munged ]
     
maas@ensae.fr wrote:
>Hello,
>I am trying to get a file from a form,
>I use the
><INPUT NAME="FichierATraiter" TYPE="FILE" VALUE="">
>syntax, but when trying to get this file (or file handle?) to a perl
>script for further treatment, but when I use
>$FichAT=CGI::param(FichierATraiter);
>and try to print $FichAT ... nothing
>the same with @FichAT
>
>Any clues, or place to get doc on howto?
>thank for any answer...
>if you could send a copy of your reply to

perldoc CGI

The is a very clear example in the doc that comes with CGI.pm.

HTH



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

Date: Wed, 26 May 1999 16:20:41 -0400
From: Brian Findley <brian.findley@brightware.com>
Subject: Getting iODBC to work with SequeLink.
Message-Id: <374C5798.B67D47F5@brightware.com>

Hi,

Has anyone attempted and/or succeeded in getting iODBC to work with the
SequeLink ODBC driver software?  I'm having trouble connecting to a Sql
Server database.  When running the 'make test' from the DBD::ODBC
package, iODBC is complaining that it can't load the specified driver -
but the .odbc.ini file looks correct - the 'Driver' location is
correct!  Any help would be appreciated.

Thanks in advance,
Brian




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

Date: Wed, 26 May 1999 20:18:52 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: Help needed!
Message-Id: <MGY23.785$nn.226216@news.shore.net>

hannibal josh <hannibal59@hotmail.com> wrote:
: as i wrote i am really beginner(what is perlfaq4?.or flush?)

Wherever perl is installed, there should be a program called "perldoc"
that allows you to read the perl docs. You would type "perldoc perlfaq4"
to read that part of the faqs, and "perldoc -f flush" to read the docs for
the function "flush". 

You can also read the docs on the www at www.perl.com. 

--Art

-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


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

Date: Wed, 26 May 1999 20:22:03 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Help needed!
Message-Id: <7ihl58$at9$1@nnrp1.deja.com>

In article <WZW23.2148$y6.1371036@WReNphoon3>,
  hannibal59@hotmail.com (hannibal josh) wrote:
> still same problem..:-(i have upploaded it ascii,permissions are
> set,i checked all white(empty)spaces before: End_of_prog,lines
> starting from left margin,
> and there is nothing else on line __EOF__,but still:
> "Can't find string terminator "End_of_prog" anywhere
> before EOF at /u/prox/cgi-bin/penv.cgi line 17.

I saved your code, exactly as you posted it, and did not have
that problem.  I found other problems, though...

> #!/usr/bin/perl -w
>
> use strict

The fact that the semicolon is missing from this line means 'strict'
is not in effect, and many yukky bugs therefore went undetected.
Add the semicolon and start debugging!


> $host = $ENV{'REMOTE_HOST'};

You might want to make that

  $host = $ENV{'REMOTE_HOST'} || $ENV{'REMOTE_ADDR'};

since sometimes only the IP address is given.

> $command = <<'End_of_prog';
> $ping =`ping-s$host64 1`;
> End_of_prog
>
> if (eval $command) {

First, your 'ping' command is missing some absolutely critical spaces!

	ping -s $host 64 1

Second, you don't need this here-doc contortion to do what you're
wanting to do.  How about this:

  $command = "ping -s $host 64 1";
  $ping = `$command`;
  if ( $ping ) {


> $* = 1; # Enable multi-line pattern match
> $ping =~ m#min/avg\/max = (\d*)/\d*\/\d*# ;

Use of the $* variable is extremely deprecated.
What version of Perl are you using?
Use the /m option instead:

  $ping =~ m,min/avg/max = (\d+)/\d+/\d+/m ;  # note the m at the end.


> print <<__EOF__;
> Content-type: text/html
>...

You might seriously consider using the CGI.pm module, if you're going
to be writing cgi scripts.  It will make your life so much easier,
you'll wonder how you ever got along without it.

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


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


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

Date: Wed, 26 May 1999 13:47:17 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Help needed!
Message-Id: <MPG.11b5fdb0457cabbb989b03@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <WZW23.2148$y6.1371036@WReNphoon3> on Wed, 26 May 1999 
10:18:51 -0800, hannibal josh <hannibal59@hotmail.com> says...
> Thank you very much for help(Scratchie,Larry Rosler,John Porter,
> Tony Greenwood)There is real gentlemans out there!
> But.....i did not understand you or....??
> as i wrote i am really beginner(what is perlfaq4?.or flush?)
> and...
> still same problem..:-(i have upploaded it ascii,permissions are
> set,i checked all white(empty)spaces before: End_of_prog,lines
> starting from left margin,
> and there is nothing else on line __EOF__,but still:
> "Can't find string terminator "End_of_prog" anywhere
> before EOF at /u/prox/cgi-bin/penv.cgi line 17.
 ...
> </html>
> __EOF__

I recall a bug report about some implementation if this is the exact 
last line in the source file.  Try adding a blank line, or a line with 
just a semicolon on it.

> ONCE AGAIN,THANK YOU!

YOU'RE WELCOME!

(Now please stop shouting, even if only nice things. :-) 

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


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

Date: Wed, 26 May 1999 21:14:10 GMT
From: "Barr" <barr@hancock.net>
Subject: Help, I'll pay money for solution!!!
Message-Id: <01bea7bc$a1b163c0$0100a8c0@digitech.hancock.net>

Sorry about being so long, but I think it's required.  Please read.

History of problem:
1. I have a cgi program that creates mail based on an html form. I made the
message look like it comes from an email address filled out in the form.
This cgi program uses my "hosters" sendmail program on his NT server.
   
2. The message includes a personal greeting which I must maintain (his/her
name filled out in the form).
 
3. The message gets send to me.  This all works great.

Requirement:
1. I need to send it back to the address it came from (the address which
came from the form) without changing the contents.

2. I need to be able to set up a program to do this (to receive mail and
send it back to the address it came from).

Here's the catch:
1. I need the requirement to work ONLY during specified hours of the day. I
can turn it on and off at the appropriate time.

OR HERE'S AN ALTERNATIVE...
Make the server only send the mail during specified hours of the day. The
form  must be available 24hrs everyday.

Please help!!!



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

Date: 26 May 1999 13:36:12 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: leeches, compilers, and perl, oh my (all mine?)
Message-Id: <ylso8jwoub.fsf@windlord.stanford.edu>

Greg Bartels <gbartels@xli.com> writes:
> Tom Christiansen wrote:

>> If I had information that would allow you to fire the nukes in Montana,
>> I'd withhold that as well.  It's a moral decision.

> there is no immorality in it.

It is, nonetheless, a moral decision.

> he wants to protect his copyrighted code.

Doing that while using a programming language that was made freely
available by its author is a little shady at best, and I don't feel
obligated to help.

> how would his actions in any way hurt whats already available in open
> source?

Doesn't matter.  That's not the point.

> the only way I can see this being wrong is if you are saying soemthing
> to the effect of "all copyrighted code must have freely available source
> code or said owners are bad"

It would be much more accurate to say that I prefer free software, prefer
to cooperate with people who will release their software for free, and am
much less interested in helping people who are not going to do that.
Given that I'm under no obligation to answer anyone's questions, I choose
to focus my volunteer time on people I enjoy working with.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Wed, 26 May 1999 17:02:47 -0400
From: "Dan Burke" <dbws@----nospam----hotmail.com>
Subject: location of socket.pm
Message-Id: <0nZ23.304$H5.3292@newsr1.twcny.rr.com>

Where can I download the latest version of socket.pm ?

Thanks,

Dan






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

Date: 26 May 1999 14:31:44 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: location of socket.pm
Message-Id: <ylemk3wm9r.fsf@windlord.stanford.edu>

Dan Burke <dbws@----nospam----hotmail.com> writes:

> Where can I download the latest version of socket.pm ?

Socket.pm (note capitalization) is part of core Perl.  It should come with
your Perl distribution.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Wed, 26 May 1999 22:03:07 +0200
From: Jean-Louis Leroy <jll@skynet.be>
Subject: Re: Nested Data in MySQL.. getting at it with DBI..
Message-Id: <VA.00000312.00dcbe6f@enterprise>

Take a look at Tangram: http://www.cpan.org/modules/by-module/Tangram/

Jean-Louis Leroy
http://ourworld.compuserve.com/homepages/jl_leroy/



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

Date: Wed, 26 May 1999 20:29:15 GMT
From: malch@malch.com (Malcolm Hoar)
Subject: Non-blocking Sockets on Win32
Message-Id: <7ihlir$g0rm_004@nntp1.best.com>

Has anyone even been able to make non-blocking sockets work on Win32?

fnctl() is not available, of course. 

However, perlport.pod says:

>=item ioctl FILEHANDLE,FUNCTION,SCALAR
>
>Available only for socket handles, and it does what the ioctlsocket() call
>in the Winsock API does. (Win32)

I'm darned if I can get it to work -- currently running ActiveState
Build 515.

-- 
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| Malcolm Hoar           "The more I practice, the luckier I get". |
| malch@malch.com                                     Gary Player. |
| http://www.malch.com/               Shpx gur PQN.                |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: Wed, 26 May 1999 14:36:44 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: OO: Perl resources
Message-Id: <374C696C.4C300A6@mail.cor.epa.gov>

Ryan Ngi wrote:
> 
> where can i find the free OO: perl resources on internet?
> please suggest

Well, start with your own machine, please.  That's cheaper
than paying your ISP.  Here are some Perl manpages to get
you started.  Since you're using Free Agent to post, I'll
assume you have ActiveState Perl on a win32 box.  So you
can read these using the perldoc program, or peruse the
HTML tree that was built with your install.

    perlref             Perl references
    perlreftut          Perl references short introduction
    perldsc             Perl data structures intro
    perllol             Perl data structures: lists of lists
    perltoot            Perl OO tutorial    
    perlobj             Perl objects
    perltie             Perl objects hidden behind simple variables
    perlbot             Perl OO tricks and examples

Then go to DejaNews (errm, that's Deja.com now) and
look up anything posted by Tom Christiansen in this 
newsgroup with the string 'perltoot' in it.  And you can
go to www.perl.com and follow the links to the tutorials
(Tom again) there.

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


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

Date: Wed, 26 May 1999 13:30:53 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Open a textfile with a cgi-programm
Message-Id: <MPG.11b5f9d4a79d57c1989b02@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <374C453D.18CD3BDC@atrieva.com> on Wed, 26 May 1999 12:02:21 
-0700, Jerome O'Neil <jeromeo@atrieva.com> says...
> Larry Rosler wrote:
 ...
> > On every CGI invocation, the program finds the configuration file in its
> > own directory by analyzing the $0 variable:
>  
> > BEGIN {
> >     require 5.002; # Because that's the most that I can rely on!!!
> >     $0 =~ m!(.*?)[^/\\]+$! && $1 and unshift @INC, $1;
> >     do 'config' or # The actual code also sends me email!
> >         print("Content-type: text/plain\n\nconfig failed. $!.\n"), exit;
> > }
> 
> Very clever.  I have a short package that loads my config data into a
> hash, and returns the reference.  I'm sure you won't mind if I steal
> this and incorporate it into my own stuff? 

As long as you know where to send the royalties.  :-)

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


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

Date: Wed, 26 May 1999 13:19:53 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Pattern Matching -- Up a Certain Creek with no Paddle
Message-Id: <MPG.11b5f73e23099a3c989b01@nntp.hpl.hp.com>

In article <7ihj5o$35t$1@news8.svr.pol.co.uk> on Tue, 25 May 1999 
14:22:52 +0100, Mug-O-Milk <webmaster@*nospam*mugomilk.freeserve.co.uk> 
says...
> Hello.  I've had several reports that my search engine is playing up
> When a user types "land" as in "Land Rover" they get everypage for "finland"
> , "England" etc.
> 
> Can anyone see where I am going wrong?
> I've tried "eq" and "==" instead of "=~" but they do not work.

Short answer:  Use "\b" on each side of the search pattern in the regex.

Long answer:  Revised code below.
 
> I need the search to be case insensitive, if possible [a-zA-Z]
> 
> Here is a snippet from the code
> 
> #BEGIN MAIN SEARCH
> $matches = 0;
> open(DATA, $datafile);

Do you *really* want to keep going if this fails, for whatever reason?

  open(DATA, $datafile) or die "Can't open '$datafile'. $!\n";

> while ($record[0] = <DATA>) {
>   chomp($record[0]);
> 
>   # SPLIT INPUT FROM DATAFILE
>   ($record[1], $record[2], $record[3], $record[4]) = split(/\|/,
> $record[0]);
> 
>   # TIDY UP DATA FROM DATAFILE
>   for ($i=0; $i < @record; $i++) {
>     $record[$i] =~ s/\s{1,}/ /g;
>     $record[$i] =~ s/^\s{1,}//;
>     $record[$i] =~ s/\s{1,}$//;
>   }

    for (@record) {
        tr/ \r\t\f\b/ /s;
        s/^ //;
        s/ $//;
    }

>   # SEARCH FOR KEYWORDS
>   $score = 0; # RESET SCORE FOR EACH RECORD IN DATAFILE
>   foreach $word (@searchword) {
>     if ($record[$sel] =~ /$word/i) {
>       $score += (100 / @searchword);
>     }
>   }

      if ($record[$sel] =~ /\b\Q$word\E\b/i) {

>   # STORE MATCHING RECORDS ALONG WITH SCORES
>   if ($score > 0) {
>     $score = int($score + 0.5);
>     $score = " " x (3 - length($score)) . $score;
>     $results[$matches] = "$score | $record[0]";
>     $matches++;
>   }
> }
> close(DATA);
> 
> $matches = @results + 0; # CONVERT TO A NUMBER (weird I know!)

  $matches = @results; # Will do just fine by itself!

> $resultnumber = 0;

Your algorithm is extremely inefficient, as you are compiling a regex 
for ever word in @searchword for every record in the datafile.  If this 
becomes a problem, see perlfaq6:  "How do I efficiently match many 
regular expressions at once?"

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


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

Date: 26 May 1999 16:51:57 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Pattern Matching -- Up a Certain Creek with no Paddle
Message-Id: <x7g14jeeqa.fsf@home.sysarch.com>

>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:

  LR> 14:22:52 +0100, Mug-O-Milk <webmaster@*nospam*mugomilk.freeserve.co.uk> 

  >> $record[$i] =~ s/\s{1,}/ /g;
  >> $record[$i] =~ s/^\s{1,}//;
  >> $record[$i] =~ s/\s{1,}$//;
  >> }

  LR>         s/^ //;
                  +
  LR>         s/ $//;
                 +

aren't you missing the + (which is what the {1,} is above)?

as people always say, when answering an faq, use the faq code!

:-)

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Wed, 26 May 1999 14:12:26 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Pattern Matching -- Up a Certain Creek with no Paddle
Message-Id: <MPG.11b603973d33d731989b05@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <x7g14jeeqa.fsf@home.sysarch.com> on 26 May 1999 16:51:57 -
0400, Uri Guttman <uri@sysarch.com> says...
> >>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
>   LR> 14:22:52 +0100, Mug-O-Milk <webmaster@*nospam*mugomilk.freeserve.co.uk> 
>   >> $record[$i] =~ s/\s{1,}/ /g;
>   >> $record[$i] =~ s/^\s{1,}//;
>   >> $record[$i] =~ s/\s{1,}$//;
>   >> }
> 
>   LR>         s/^ //;
>                   +
>   LR>         s/ $//;
>                  +
> 
> aren't you missing the + (which is what the {1,} is above)?
> 
> as people always say, when answering an faq, use the faq code!
> 
> :-)

Errr, no.  The '+' wouldn't do any harm, but it's not needed.  Look at 
the whole snippet, not those two lines.

    for (@record) {
        tr/ \r\t\f\b/ /s;
        s/^ //;
        s/ $//;
    }

Gotcha!  (On purpose. :-)

Heh, heh, heh.

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


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

Date: Wed, 26 May 1999 21:43:23 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Pattern Matching -- Up a Certain Creek with no Paddle
Message-Id: <7ihptm$ekj$1@nnrp1.deja.com>

In article <7ihj5o$35t$1@news8.svr.pol.co.uk>,
  "Mug-O-Milk" <webmaster@*nospam*mugomilk.freeserve.co.uk> wrote:
>
> #BEGIN MAIN SEARCH
> $matches = 0;
> open(DATA, $datafile);

Always, but *Always, no, ALWAYS check the result of open.
I think you know this.


> while ($record[0] = <DATA>) {
>   chomp($record[0]);
>
>   # SPLIT INPUT FROM DATAFILE
>   ($record[1], $record[2], $record[3], $record[4]) = split(/\|/,
> $record[0]);
>
>   # TIDY UP DATA FROM DATAFILE
>   for ($i=0; $i < @record; $i++) {
>     $record[$i] =~ s/\s{1,}/ /g;
>     $record[$i] =~ s/^\s{1,}//;
>     $record[$i] =~ s/\s{1,}$//;
>   }

Why are you wasting so much time on this?
You only ever use one of them, the one selected by $sel.


>   foreach $word (@searchword) {
>     if ($record[$sel] =~ /$word/i) {

To make the words match exactly on whole word boundaries, put \b
at the beginning and end of the pattern:

		=~ /\b$word\b/i

To only "anchor" to the beginning of words, just put a \b there:

		=~ /\b$word/i


>     $score = int($score + 0.5);
>     $score = " " x (3 - length($score)) . $score;
>     $results[$matches] = "$score | $record[0]";
>     $matches++;

Why bother incrementing $matches?  You're just going to count
the length of @results at the end anyway.  To add stuff to the
end of an array, use push.


> $matches = @results + 0; # CONVERT TO A NUMBER (weird I know!)

What's wierd is your little "trick".
If you think you need to do this, you don't know perl.

	$matches = @results;

works just fine.


Here's my version of this code snippet, which also is 'strict'-clean.
Hope you can stand the poetry.

while (<DATA>) {
  chomp;

  # SPLIT INPUT FROM DATAFILE
  my $record = (split /\|/)[$sel-1];

  # TIDY UP DATA FROM DATAFILE
  $record =~ s/\s+/ /g;
  $record =~ s/^ //;
  $record =~ s/ $//;

  # SEARCH FOR KEYWORDS
  my @matches = map { $record =~ /\b$_\b/i } ( @searchword ) ;

  # STORE MATCHING RECORDS ALONG WITH SCORES
  @matches and
    push @results, sprintf "%d | $_", (@matches * 100 / @searchword) +
0.5;
}

my $matches = @results;

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


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


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

Date: 26 May 1999 20:10:27 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: perl -w, "uninitialized" variables, and the Perl language spec
Message-Id: <7ihkfj$6l$1@fcnews.fc.hp.com>

John Siracusa (macintsh@cs.bu.edu) wrote:
: Andrew Allen <ada@fc.hp.com> wrote:
: >   $SIG{__WARN__}=sub{warn $_[0] unless $_[0]=~/uninit/}

: "It's a mad house!  A maaaaaaaaaaadddd house!!" :-)

Code like this is usually presented as a possibility, not a
recommendation. I remain dumbfounded, however, at your exclamatory
reference.

: > perhaps a "smart uninitialized" module which you
: > could do things like:

: >   use okay_uninit ($var1,@var2,%var3);
: >   no autovivify @twodimensionalstaticarray;

: Yeah, that's what perl needs: more pedantic run-time mother-may-I
: modules to slow script start-up times.  "use vars" anyone?  Bleh.

I seriously doubt "use vars" slows anything down by much:

  use strict;
  use vars map("\$$_",q{aaa}..q{zzz});
  eval join(";",map("\$$_",q{aaa}..q{zzz}));

takes about 3.5s on my HP C180 Visualize workstation, vs 1.3s for:

  eval join(";",map("\$$_",q{aaa}..q{zzz}));

or about .1ms/variable.

Andrew


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

Date: 26 May 1999 20:18:16 GMT
From: John Siracusa <macintsh@cs.bu.edu>
Subject: Re: perl -w, "uninitialized" variables, and the Perl language spec
Message-Id: <7ihku8$j84$3@news1.bu.edu>

Andrew Allen <ada@fc.hp.com> wrote:
> : "It's a mad house!  A maaaaaaaaaaadddd house!!" :-)

> I remain dumbfounded, however, at your exclamatory
> reference.

Planet of the Apes.

> about .1ms/variable.

It adds up! ;)

"I've measured out my life in milliseconds..."

(Okay, to be fair, that one's paraphrased ;)

-----------------+----------------------------------------
  John Siracusa  | If you only have a hammer, you tend to
 macintsh@bu.edu | see every problem as a nail. -- Maslow


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

Date: 26 May 1999 20:53:54 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: perl -w, "uninitialized" variables, and the Perl language spec
Message-Id: <7ihn12$6l$2@fcnews.fc.hp.com>

[posted and mailed]

In article <374c4dfd@cs.colorado.edu> you wrote:
: You didn't read the perltootc pod!

:     http://language.perl.com/misc/perltootc.html

Tom, 

here's some corrections/suggestions:

In "Translucent Attributes":

 ...unspawned children. Changes to one object will propagate enither...

(should be "neither")

Also, I think "sub color" of Vermin might be overly complicated:

:    sub color {
:        my $self  = shift;
:        my $class = ref($self) || $self;
:
:        # handle class invocation
:        unless (ref $self) {
:            $class->{color} = shift if @_;
:            return $class->{color}
:        }
:
:        # handle object invocation
:        $self->{color} = shift if @_;
:        if (defined $self->{color}) {  # not exists!
:            return $self->{color};
:        } else {
:            return $class->{color};
:        } 
:    } 

why not just drop the "handle class invocation" part. It's
unnecessary, as it will do the same thing as the "handle object
invocation" part (since $self eq $class in that case). Ditto for the
auto-accessor-generator below. (Unfortunately, this "simplification"
makes the routine non-parallel with the routine in "Translucency
Revisted")

Also:

:    sub has_attribute {
:        my($self, $attr)  = @_;
:        my $class = ref $self if $self;

Should this be "my $class=ref($self) || $self"?

In "Translucency Revisited", you seem to miss the obvious solution of
"Vermin::Noxious" using "%Vermin::Noxious::Noxious" as the class data
hash. Seems like _classobj should be able to do that.

Andrew



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

Date: 26 May 1999 21:36:28 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: Perl compiler...If or when
Message-Id: <eli$9905261732@qz.little-neck.ny.us>

In comp.lang.perl.misc, Ala Qumsieh  <aqumsieh@matrox.com> wrote:
> > perl is not yet a universal language, and I have people at 
> > work who have not installed perl on their PC's because
> > its too much work. We have no system administrator.
> Installing Perl is too much work? Who told you so? On Winblows, it is
> completely automated, and takes around 15 minutes. On *nix, it's

The ActiveState installer for Windows95 crashed during the install
for me. I wanted to run the test suite after that, but apparently it
was not installed (grumble, MacPerl has it, so there is at least
one binary distribution precedent). It passed 'Hello World' and it
runs a socket program that was the reason I installed it. Not an
install I've a lot of confidence in, however.

Elijah
------
just ranting


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

Date: 26 May 1999 21:21:24 GMT
From: gosar@bhavesh.ebay.sun.com (Bhavesh Gosar)
Subject: Perl Help needed
Message-Id: <7ihokk$4sp$1@ebaynews1.EBay.Sun.COM>

Hi,

I have a file with 384 Characters on each line...

In perl when I try to use the Unpack() with Template or split()....
It only recognizes 346 char and truncates the rest of the line...

Is there any limitation on the record length...?? Any workaround this problem...

Thanks,
Bhavesh Gosar...x39544




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

Date: Wed, 26 May 1999 22:09:54 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: Perl Help needed
Message-Id: <7ihpt9$a93$2@oak.prod.itd.earthlink.net>

[ courtesy cc sent by mail if address not munged ]
     
gosar@bhavesh.ebay.sun.com wrote:
>Hi,
>
>I have a file with 384 Characters on each line...
>
>In perl when I try to use the Unpack() with Template or split()....
>It only recognizes 346 char and truncates the rest of the line...
>
>Is there any limitation on the record length...?? Any workaround this
> problem...

No limits, either your file is not as long as you think it is or your 
code is tweaked.

Post the piece of your code that you think is generating the error.




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

Date: Wed, 26 May 1999 14:49:18 -0700
From: Bryan Bunch <brybunch@ix.netcom.com>
Subject: Perl Newbie Question
Message-Id: <374C6C5E.39ED@ix.netcom.com>

Greetings esteemed members of the Perl community!

	I'm a spanking brand new perl programmer (...read that as
"clueless"...), and have a quick question about perl and multithreading.

	I'm a C++ programmer by profession, and have written a program for both
UNIX and Windows platforms. I'd really like to provide a scripting front
end to allow easier configuration/modification of one particular part of
the program. My thought was to embed calls out to the script in my C++
code. At the moment, perl seems like the best choice (portable across
UNIX and Windows...unlike Visual Basic).

	However, my one concern right now is the thread safety of perl. The
program I've written is multithreaded, and the same perl script will get
called simultaneously from multiple running threads. Everything I've
read (i.e. Sriram Srinivasan's excellent book "Advanced Perl
Programming") seems to say that "multithread support is coming soon...".

	So my question is...can the latest version of Perl (I believe the
latest version I'm using is 5.0003) allow a single perl script to be
safely be executed from multiple threads in an embedded context...put
another way, is the perl interpreter itself spawing multiple threads for
each script execution, and saving all script execution information in
some kind of thread local storage? If the answer is no, then perl won't
work for me. If yes, then I'll happily transform myself into a perl
hacker!

	Thanks again!
	---- Bryan Bunch --- perl newbie.


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

Date: Wed, 26 May 1999 16:31:46 -0400
From: James Ahn <jahn@bluecloud.com>
Subject: perl syntax error
Message-Id: <374C5A15.64D784B5@bluecloud.com>

Perl folks,

I moved a CGI script I wrote in Perl from another server to my personal
account and when I did a 'perl -c filename' on it, I got syntax errors on this line:

sub OpenLookup {

          # open the file for reading
          open (LOOKUP, $lookup) || die "#2 Sorry, couldn't open $lookup";

          # read the lookup file into a 2 dimensional array
          while (<LOOKUP>) { 
HERE -->    push @theArray, [ split /,/ ];
          } 

 ...

This is the error msg:

syntax error in file sun_sign.cgi at line 53, next 2 tokens "push @theArray"
Search pattern not terminated in file sun_sign.cgi at line 53, next char ^?
syntax error in file sun_sign.cgi at line 59, next 2 tokens "]["

I'm fairly sure that the error on line 59 is due to the problems at line 53,
but don't understand what the problem is. As this script was running okay on
the other server I didn't expect syntax errors, just permission/config problems.

Can anyone help?

--Chris
chrisg@panix.com


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

Date: Wed, 26 May 1999 14:41:53 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: PERLFUNC: y/// - transliterate a string
Message-Id: <374C6AA1.59D9E13@mail.cor.epa.gov>

Tom Christiansen wrote:
> 
>      [courtesy cc of this posting mailed to cited author]
> 
> In comp.lang.perl.misc, David Cassell <cassell@mail.cor.epa.gov> writes:
> :s/transliterat/translat/;
> 
> Both Larry and I prefer it as currently written.

No prob.  You guys are authorities, while I'm merely a code
butcher.

But beware the fate of Orestes!  :-)

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


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

Date: Wed, 26 May 1999 14:00:31 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Please help ?
Message-Id: <MPG.11b600c7de234227989b04@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7ihbs7$3j9$1@nnrp1.deja.com> on Wed, 26 May 1999 17:43:35 
GMT, tvn007@my-deja.com <tvn007@my-deja.com> says...

<SNIP of data repeated below>

> I would like the ouput as follow:
> 
> DATA X Y Z A B C;
> 
> N100 xyz 10X011;
> N10  xyz X01000;
> N12  xyz 000001;

Read about the $/ ($INPUT_RECORD_SEPARATOR) variable in perlvar.

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

{ # Limit the scope of the change to $/.
  local $/ = ";\n";
  while (<DATA>) {
    s/\n\s+/$. == 1 && " "/e; # Because the header is different!
    print;
  }
}
__END__
DATA X Y Z
     A B C;

N100 xyz 10X
	 011;
N10  xyz X01
	 000;
N12  xyz 000
	 001;

> Thanks in advance for your help !

You're welcome.

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


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

Date: Wed, 26 May 1999 20:10:42 GMT
From: Dick Latshaw <latsharj@my-deja.com>
Subject: Re: removings " "s from strings
Message-Id: <7ihkg0$ae4$1@nnrp1.deja.com>

In article <374C3C52.7D842817@mail.cor.epa.gov>,
  David Cassell <cassell@mail.cor.epa.gov> wrote:
>
> [1] go to www.activestate.com
> [2] follow their surprisingly simple directions for
>     downloading a *real* version of Perl, complete with
>     documentation and everything
> [3] unzip it with something like WinZip [which is also free]

Even easier than that - it's a self extracting exe, so he can skip step
3.

> [4] double-click and let it run its InStallShield Wizard and
>     install itself for you.  Be sure to let it put its HTML
>     docs on your system, with a shortcut on your Start menu.

--
Regards,
Dick


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


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

Date: Wed, 26 May 1999 13:08:45 -0700
From: Jerome O'Neil <jeromeo@atrieva.com>
To: "(BXTC)" <bxtc@forfree.at>
Subject: Re: system command to string (DATE)
Message-Id: <374C54CD.6CFDA919@atrieva.com>

(BXTC) wrote:
> 
> To start let me tell you I am new to Perl.  This is what I need:
> I need to get the date from my system (linux) and put the output into a
> string.

Assuming you want human readable prettyness, the easiest thing to do is
call localtime in a scalar context.

> So, can anyone help me out and point me in the right direction? 

For all the exciting detail on localtime, time, and other time/date
manipulation function, read the perlfunc document that came with your
perl distribution.

> I mean I don't know what to look for, I've gone through
> perldoc for stuff I think should be related, but can't get it to work.

perldoc -f localtime
perldoc -q time

Good Luck!

-- 
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947 
The Atrieva Service: Safe and Easy Online Backup  http://www.atrieva.com


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

Date: Wed, 26 May 1999 16:35:39 -0500
From: Andrew Hamilton <hamiltaj@sgi.com>
Subject: using ~ with chdir
Message-Id: <374C692B.5256FB74@sgi.com>

I've tried this a couple of times, and each time it dies.

I'd like to be able to do chdir("~username/path/to/dir"), but perl
doesn't seem to like this.

I'm not able to do something like chdir("/home/username/path/to/dir")
because different people have their homes on different servers here.

I've searched around for about two hours trying to find some info on
this, but all I can ever find is that chdir will cd to the value of the
argument given.

Any help would be appreciated, and if I was looking in the wrong spot
and you know of some place that has the answer to my question, that
would be great as well

Thanks a lot.
Andrew Hamilton



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

Date: 26 May 1999 15:56:39 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: using ~ with chdir
Message-Id: <374c6e17@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    Andrew Hamilton <hamiltaj@sgi.com> writes:
:I'd like to be able to do chdir("~username/path/to/dir"), but perl
:doesn't seem to like this.

  How can I translate tildes (~) in a filename?

    Use the <> (glob()) operator, documented in the perlfunc manpage. This
    requires that you have a shell installed that groks tildes, meaning
    csh or tcsh or (some versions of) ksh, and thus may have portability
    problems. The Glob::KGlob module (available from CPAN) gives more
    portable glob functionality.

    Within Perl, you may use this directly:

            $filename =~ s{
              ^ ~             # find a leading tilde
              (               # save this in $1
                  [^/]        # a non-slash character
                        *     # repeated 0 or more times (0 means me)
              )
            }{
              $1
                  ? (getpwnam($1))[7]
                  : ( $ENV{HOME} || $ENV{LOGDIR} )
            }ex;

Then again, there's always 

    chdir <~joebob>;

but that has several problems, one of which is that it leaks.

    chdir ((<~joebob>)[0]);

won't, nor shall:

    @home = <~joebob>;
    chdir $home[0];

And the latter is more amenable to error checking.

Why don't people grep the FAQ?

--tom
-- 
    Randal said it would be tough to do in sed.  He didn't say he didn't
    understand sed.  Randal understands sed quite well.  Which is why he
    uses Perl.   :-)  -- Larry Wall in <7874@jpl-devvax.JPL.NASA.GOV>


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

Date: Wed, 26 May 1999 16:46:07 -0500
From: therzog@knotech.com (Tim Herzog)
Subject: workarounds for prototypes
Message-Id: <therzog-2605991646070001@therzog-host105.dsl.visi.com>


Coming from C/C++ backgrounds, I'm used to functions being prototyped and
I like it that way.

I have a perl program that defines a bunch of subroutines in a second file
(in the same directory) that I bring in with "require."  The problem is
that because require works at runtime, not compile time, the prototypes in
the second file aren't enforced by the perl compiler.

My workaround is to rename the second file "utils.pm", and then to this in
the main file:

push @INC, '.';
use utils;

That seems to work, at least on my box (RedHat Linux, perl 5.005)

I don't change the contents of utils.pm, don't declare it as a package or
export anything.  For my own reasons (chiefly laziness), I'd rather not
reconstruct this thing as a true package:  I want everything to reside in
global namespace.

My question is:  how dangerous and/or compatible is this with other (and
possibly future) versions of perl?  Am I committing a big no-no?  I do
need this code to be compatible with a wide variety of systems (using Perl
5 as a minimum requirement), but my "module" need only work with this
application.

Thanks,

Tim

-- 
Tim Herzog


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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 V8 Issue 5794
**************************************

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