[22555] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4776 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 28 11:06:43 2003

Date: Fri, 28 Mar 2003 08:05:11 -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           Fri, 28 Mar 2003     Volume: 10 Number: 4776

Today's topics:
    Re: Binary Distribution of Perl <ericw@nospam.ku.edu>
    Re: Building Perl 5.6.1 on AIX 5.1 <h.m.brand@hccnet.nl>
    Re: CGI.pm or roll-your-own? <tore@aursand.no>
    Re: CGI.pm or roll-your-own? <noreply@gunnar.cc>
    Re: CGI.pm or roll-your-own? <dha@panix.com>
    Re: CGI.pm or roll-your-own? <noreply@gunnar.cc>
    Re: doubts on \n ctcgag@hotmail.com
    Re: how do you correctly accomplish $$var_name? <barryk2@SPAM-KILLER.mts.net>
    Re: How to determine file creation time <tore@aursand.no>
        Implementing Matt Sergeants Proxy Objects (Alex Gutteridge)
    Re: Implementing Matt Sergeants Proxy Objects <ubl@schaffhausen.de>
    Re: including subfunctions from another file <barryk2@SPAM-KILLER.mts.net>
        make error loading module via 'cpan' <none@none.com>
        MIME Entity is looking for dumpskeleto.al (Matthias Jaekle)
    Re: MIME Entity is looking for dumpskeleto.al <nobull@mail.com>
    Re: namespace with do "filename" (David Efflandt)
    Re: namespace with do "filename" <ericw@nospam.ku.edu>
    Re: pattern matching (Tad McClellan)
    Re: pattern matching <somewhere@nowhere.com>
    Re: pattern matching <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: pattern matching (Helgi Briem)
    Re: pattern matching <jurgenex@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 28 Mar 2003 14:54:46 GMT
From: Eric Wilhelm <ericw@nospam.ku.edu>
Subject: Re: Binary Distribution of Perl
Message-Id: <pan.2003.03.28.08.52.07.566205.1661@nospam.ku.edu>

On Fri, 28 Mar 2003 05:04:46 -0600, soudamini sreepada wrote:

> Hi,
> 
> We are installing Perl 6.5.1 Build 631 version on Suse Linux 7.0, OS/390
> box. The binary distribution for the above specification is not
> available. We built the source code and installed it. I will be glad if
> any one let me know if there is any automated tool available to create a
> binary distribution out of it.
> 
> Thanks.

rpm-build can be used to create rpms, but you will have to write a
specfile (see the rpm how-to)

checkinstall will create an installed rpm when you do 

	checkinstall -R make install

but I don't think that this would be suitable for installation, it is
mostly intended for tracking programs installed from source.  Try it,
maybe it will work for you, or at least help you write a specfile.

--Eric


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

Date: Fri, 28 Mar 2003 16:06:55 +0100
From: "H. Merijn Brand" <h.m.brand@hccnet.nl>
To: comp.lang.perl.misc
Subject: Re: Building Perl 5.6.1 on AIX 5.1
Message-Id: <Xns934CA3EF8BE0CMerijn@192.0.1.90>

gena_st@rocketmail.com (Gena Storhotz) wrote in 
news:2ccfc5af.0303251319.a9909a@posting.google.com:

> I posted a lengthy message on this subject in the comp.unix.aix
> section, but, as I've posted questions about this on several other
> forums without luck, I thought I should include a post here for
> completeness.
> 
> I am trying to run Perl 5.6.1 on AIX 5.1.  The binaries I've
> downloaded were built with cc, so I can't install modules that require
> a compiler.  I've tried building Perl 5.6.1 with GCC 2.9 and 3.1 and
> have multiple problems during Configure, and "make" fails.
> 
> I'm looking for someone who has experience with doing this to give me
> advice on how to proceed, or maybe a link to an on-line guide for
> this.  Any information would be greatly appreciated.  Thanks!

try 5.8.0 with gcc-3.1
should build out of the box

5.6.1 does not build with gcc-2.x (unless you know why not)

-- 
H.Merijn Brand    Amsterdam Perl Mongers (http://www.amsterdam.pm.org/)
using perl-5.6.1, 5.8.0 & 633 on HP-UX 10.20 & 11.00, AIX 4.2, AIX 4.3,
     WinNT 4, Win2K pro & WinCE 2.11 often with Tk800.024 &/| DBD-Unify
ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/id/H/HM/HMBRAND/


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

Date: Fri, 28 Mar 2003 14:53:51 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <pan.2003.03.27.16.44.09.77736@aursand.no>

On Thu, 27 Mar 2003 09:24:56 +0000, Helgi Briem wrote:
> They pick up some P of S code from Ma**'s Sc***t A**chive or somewhere,
> can't get it to work, ask  how and then get all defensive when someone
> tells them to do themselves a favour and use the CGI module.

Yeah.  Thinking of it, and actually no flame intended, that Matt guy has
caused more problems than he'll ever be able to solve. :-/


-- 
Tore Aursand


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

Date: Fri, 28 Mar 2003 15:20:58 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <b61mnp$sqcm$1@ID-184292.news.dfncis.de>

Randal L. Schwartz wrote:
> One example. I'll permit *one* example in a CGI book that does it "by
> hand", just to show how much stuff has to be done, and has to be
> remembered.  And the next example better be how to do the same exact
> thing with CGI.pm, including the other things it's getting right
> (entities, multi-select form elements, POST/GET being interchangable,
> correct interpretation of content-encoding, using both ";" and "&" as
> delimiters, preventing DOS attacks by limiting the incoming data,
> portability to mod_perl Apache::Registry when the time comes, etc
> etc).
> 
> Drilling down with the by-hand code is like showing how to multiply by
> doing repeated additions and bitshifting.  Sure, it's interesting, but
> IT IS NOT PRODUCTIVE IN THE LONG RUN.  Nor is it how *real* programs
> are written.

I think you forget one thing, Randal. Some of the *knowledge* you gain 
by playing with "by-hand code" is not just interesting, it may also be 
useful.

Sure, it's possible to write a guestbook script, or some other simple 
form application, using CGI.pm, without knowing anything about what's 
happening "behind the scenes". But if you want to do something 
slightly beyond that, it's good to know *something* ...  I'm thinking 
of things like passing info from one script to another via a HTTP 
request, or archiving a mailing list. Those are tasks that I, even if 
I'm a beginner, have had a need to accomplish, and I have to say that 
it would have been rather tricky without a clue about the distinction 
between POST and GET, for instance.

Without arguing against the use of CGI.pm, I find the discussion about 
it far too polarized.

/ Gunnar

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



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

Date: Fri, 28 Mar 2003 14:59:49 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <slrnb88or4.fg0.dha@panix2.panix.com>

In article <b61mnp$sqcm$1@ID-184292.news.dfncis.de>, Gunnar Hjalmarsson wrote:

> Without arguing against the use of CGI.pm, I find the discussion about 
> it far too polarized.

I'm not sure it's polarized enough, actually.

The way I see it, it's realy simple - If you are just trying stuff out
in order to learn, hand rolled CGI code may be valuable.  If you're
writing code that's actually going to be *used*, you are almost
certainly better off with CGI.pm.  And the only reason that I say
"almost" is because there *are* people out there who understand CGI
sufficiently to write hand-rolled code to do it.  Nevertheless, those
people never bring up this question (and probably use CGI.pm anyway :-).

Really, if you don't know the answer to the subject of this thread
already, you probably are not up on CGI enough to write a replacement
for CGI.pm. And, equally important, CGI.pm has been used and tested
heavily for many years, while your code hasn't. Again, if it's a
learning exercise, that's one thing. If, however, you're writing code
that is actually going to be used by people, you should either really
know what you're doing or use code written by people who do.

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Just Install Perl.      - Chris Nandor


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

Date: Fri, 28 Mar 2003 16:13:16 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <b61pq7$t9vl$1@ID-184292.news.dfncis.de>

David H. Adler wrote:
> In article <b61mnp$sqcm$1@ID-184292.news.dfncis.de>, Gunnar Hjalmarsson wrote:
>>Without arguing against the use of CGI.pm, I find the discussion about 
>>it far too polarized.
> 
> I'm not sure it's polarized enough, actually.
> [snip]
> If, however, you're writing code
> that is actually going to be used by people, you should either really
> know what you're doing or use code written by people who do.

The latest CGI thing I wrote without using CGI.pm is a CGI module:
     http://www.cpan.org/modules/by-authors/id/G/GU/GUNNAR/

It's a trivial module, and I believe that the code is good enough for 
its purpose. Nevertheless, please feel free to criticize it, and let 
me know if I know what I'm doing. Maybe, if you would find a security 
hole or something, you'd shut my mouth on this topic. Maybe. ;-)

/ Gunnar

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



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

Date: 28 Mar 2003 15:31:23 GMT
From: ctcgag@hotmail.com
Subject: Re: doubts on \n
Message-Id: <20030328103123.675$Od@newsreader.com>

Benjamin Goldberg <goldbb2@earthlink.net> wrote:
> ctcgag@hotmail.com wrote:
> >
> > toddrw69@excite.com (trwww) wrote:
> [snip]
> > > there is no \015 in the string
> >
> > On Windows
> >
> > > because the OS stripped it out for you
> > > ( unless FH has been binmode()ed ).
> >
> > On linux, the \015 isn't stripped out.
>
> What happens, on linux, when you do:
>
>    binmode( FH, ":crlf" );

They're still there.

>
> ?
>
> (This question assumes that perl is compiled with perlio enabled)

    useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef

So I guess it wasn't.

If I convince someone to recompile perl with perlio, will crlf then
tolerate \015\012 at line endings, or will it demand them (i.e. not
recognize a lone \012 as a line ending)?

Thanks,

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Fri, 28 Mar 2003 08:21:48 -0600
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: how do you correctly accomplish $$var_name?
Message-Id: <MPG.18ee1674d6a82d8e989774@news.mts.net>

[This followup was posted to comp.lang.perl.misc]

In article <9b2bc55c.0303272025.3c3e7ee7@posting.google.com>, Hammy 
(ericschultz@wisc.edu) says...
> I remember doing this at one point but I've forgotten. I'm trying to
> figure out how to accomplish $$var_name correctly. (in other words if
> $var_name="name" then you'd get $name)I know if you do this, it can
> cause problems and there's a better way to accomplish the same thing.
> Thanks for any help you can provide.
> 
> Eric
> ericschultz@wisc.edu
> 

$name = "hello world";
$var_name = "name";
print "$$var_name\n";

-- 
---------

Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com


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

Date: Fri, 28 Mar 2003 14:53:51 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: How to determine file creation time
Message-Id: <pan.2003.03.27.16.50.14.344616@aursand.no>

On Thu, 27 Mar 2003 07:58:20 -0800, Steve wrote:
> What I would like to do is only do the getstore() function if the file
> located at c:\localpath\file.gif was created or modified more than 15
> minutes ago, for example.

perldoc -f stat

  my $modified = ( stat($filename) )[9]; # Number of seconds since epoch


-- 
Tore Aursand


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

Date: 28 Mar 2003 03:15:07 -0800
From: alexg@ebi.ac.uk (Alex Gutteridge)
Subject: Implementing Matt Sergeants Proxy Objects
Message-Id: <4eb07169.0303280315.70d638b7@posting.google.com>

Hi,

I'm trying to write a set of classes for representing a tree-like
structure, and have run up against the old problem of circular
references in Perl. I've got it working using the weaken() fuction,
but I'd like to use the Proxy Object strategy outlined by Matt
Sergeant here

http://www.perl.com/pub/a/2002/08/07/proxyobject.html?page=1

I can't get it to work though. I have three different classes
(structure,model,chain) - structure contains a ref to one or more
models which contain refs to one or more chains. Chains have refs to
their parent models and models to their parent structures (hence the
circularity). I've copied and pasted Matt's base class and implemented
the structure, model and chain classes as he describes (I think). But
none of it is garbage collected correctly.

Here's my code:

use StructureProxy::StructureBase;
use StructureProxy::Structure;
use StructureProxy::Model;
use StructureProxy::Chain;
use Devel::Peek;
use strict;

for (1..1){
  #Create structure,model and chain object
  my $struct = StructureProxy::Structure->new();
  my $model  = StructureProxy::Model->new();
  my $chain  = StructureProxy::Chain->new();
  #Link them all together: structure <-> model <-> chain
  $struct->model($model);
  $model->structure($struct);
  $model->chain($chain);
  $chain->model($model);
  Dump($struct,10);
  warn("Leaving scope\n");
}
warn("Scope left\n");

Nothing gets cleaned up until the script ends. The Dump of $struct
shows (I think) that $struct has a refcount of one (and so should be
DESTROYed), but it's not. The Dump of $struct looks like this (with my
comments):

SV = RV(0x8115ad0) at 0x8103734      #Proxy object?
  REFCNT = 1                         #So should be DESTROYED when
leaving scope?
  FLAGS = (PADBUSY,PADMY,ROK)
  RV = 0x81039a4
  SV = PVMG(0x8124660) at 0x81039a4  #Here's the the real structure
    REFCNT = 2                       #with two ref counts
    FLAGS = (PADBUSY,PADMY,OBJECT,ROK)
    IV = 135280376
    NV = 135280376
    RV = 0x81036f8
    SV = PVHV(0x8143778) at 0x81036f8
      REFCNT = 1
      FLAGS = (OBJECT,SHAREKEYS)
      IV = 1
      NV = 0
      STASH = 0x8135c20 "StructureProxy::StructureImpl"
      ARRAY = 0x816b958  (0:7, 1:1)
      hash quality = 150.0%
      KEYS = 1
      FILL = 1
      MAX = 7
      RITER = -1
      EITER = 0x0
      Elt "models" HASH = 0x6861a57
      SV = RV(0x8115b00) at 0x8168d10         #structure contains a
model
        REFCNT = 1
        FLAGS = (ROK)
        RV = 0x8168b18
        SV = PVMG(0x8124680) at 0x8168b18     # heres the model
          REFCNT = 3
          FLAGS = (PADBUSY,PADMY,OBJECT,ROK)
          IV = 135695152
          NV = 135695152
          RV = 0x8168b30
          SV = PVHV(0x81437a8) at 0x8168b30
            REFCNT = 1
            FLAGS = (OBJECT,SHAREKEYS)
            IV = 2
            NV = 0
            STASH = 0x8105e10   "StructureProxy::ModelImpl"
            ARRAY = 0x8169c30  (0:6, 1:2)
            hash quality = 150.0%
            KEYS = 2
            FILL = 2
            MAX = 7
            RITER = -1
            EITER = 0x0
            Elt "chain" HASH = 0x773fd42
            SV = RV(0x8115b10) at 0x8163d24   #model contains a chain
              REFCNT = 1
              FLAGS = (ROK)
              RV = 0x8168b48
              SV = PVMG(0x81246a0) at 0x8168b48  #heres the chain
                REFCNT = 2
                FLAGS = (PADBUSY,PADMY,OBJECT,ROK)
                IV = 135695200
                NV = 135695200
                RV = 0x8168b60
                SV = PVHV(0x81437d8) at 0x8168b60
                  REFCNT = 1
                  FLAGS = (OBJECT,SHAREKEYS)
                  IV = 1
                  NV = 0
                  STASH = 0x8163818     "StructureProxy::ChainImpl"
                  ARRAY = 0x81699d0  (0:7, 1:1)
                  hash quality = 150.0%
                  KEYS = 1
                  FILL = 1
                  MAX = 7
                  RITER = -1
                  EITER = 0x0
                  Elt "model" HASH = 0x8329bef
                  SV = RV(0x8115b18) at 0x8163e8c # chain points back
to model
                    REFCNT = 1
                    FLAGS = (ROK)
                    RV = 0x8168b18
                    SV = PVMG(0x8124680) at 0x8168b18
                      REFCNT = 3
                      FLAGS = (PADBUSY,PADMY,OBJECT,ROK)
                      IV = 135695152
                      NV = 135695152
                      RV = 0x8168b30
            Elt "structure" HASH = 0xc761a70d
            SV = RV(0x8115b08) at 0x8163ba4  # model points back to
structure
              REFCNT = 1
              FLAGS = (ROK)
              RV = 0x81039a4
              SV = PVMG(0x8124660) at 0x81039a4
                REFCNT = 2
                FLAGS = (PADBUSY,PADMY,OBJECT,ROK)
                IV = 135280376
                NV = 135280376
                RV = 0x81036f8
                SV = PVHV(0x8143778) at 0x81036f8
                  REFCNT = 1
                  FLAGS = (OBJECT,SHAREKEYS)
                  IV = 1
                  NV = 0
                  STASH = 0x8135c20    
"StructureProxy::StructureImpl"
                  ARRAY = 0x816b958  (0:7, 1:1)
                  hash quality = 150.0%
                  KEYS = 1
                  FILL = 1
                  MAX = 7
                  RITER = 7
                  EITER = 0x81668dc

Can anyone shed any light on why the proxy object isn't being cleaned
up - is my understanding of the Dump incorrect? I can post the code
for each of the classes  if need be. The output of the script is as
follows (I've set the base class to report each time it proxies a
method, and each DESTROY warns when it is called):

Proxying model
Proxying structure
Proxying chain
Proxying model
Leaving scope
Scope left
Proxying DESTROY
Calling Chain::DESTROY at /homes/alexg/perl/StructureProxy/Chain.pm
line 31 during global destruction.
Calling Chain::DESTROY at /homes/alexg/perl/StructureProxy/Chain.pm
line 31 during global destruction.
Proxying DESTROY
Calling Model::DESTROY at /homes/alexg/perl/StructureProxy/Model.pm
line 33 during global destruction.
Calling Model::DESTROY at /homes/alexg/perl/StructureProxy/Model.pm
line 33 during global destruction.
Proxying DESTROY
Calling Structure::DESTROY
Calling Structure::DESTROY


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

Date: Fri, 28 Mar 2003 13:22:17 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Implementing Matt Sergeants Proxy Objects
Message-Id: <b61hvp$fot$1@news.dtag.de>

Alex Gutteridge wrote:

> Here's my code:
> 
> use StructureProxy::StructureBase;
> use StructureProxy::Structure;
> use StructureProxy::Model;
> use StructureProxy::Chain;
> use Devel::Peek;
> use strict;
> 
> for (1..1){
>   #Create structure,model and chain object
>   my $struct = StructureProxy::Structure->new();
>   my $model  = StructureProxy::Model->new();
>   my $chain  = StructureProxy::Chain->new();
>   #Link them all together: structure <-> model <-> chain
>   $struct->model($model);
>   $model->structure($struct);
>   $model->chain($chain);
>   $chain->model($model);
>   Dump($struct,10);
>   warn("Leaving scope\n");
> }
> warn("Scope left\n");

I guess most likely there is a mistake in your Proxy Code, but you don't 
show it here, so I can't tell.

My understanding is that a single Proxy Class should be enough, if you 
create the concrete objects outside the Proxy class and pass them in at 
instance creation time.

Bye,
->malte


-- 
srand 108641088; print chr int rand 256 for qw<J A P H>



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

Date: Fri, 28 Mar 2003 08:11:34 -0600
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: including subfunctions from another file
Message-Id: <MPG.18ee1413ab828d20989772@news.mts.net>

[This followup was posted to comp.lang.perl.misc]

In article <slrnb865fq.d8h.lance-news@buddha.hofflund.net>, Lance 
Hoffmeyer (lance-news@augustmail.com) says...
> 
> Hello all,
> 
> I have one file called main.pl and another file called test.pl
> How can I use the functions in test.pl while running main.pl?
> 
> 
> test.pl
> test{
> print "This is only a test \n";
> }
> 
> main.pl
> use strict;
> use warnings;
> "" How do I call test.pl ? ""
> call("test.pl");
> include("test.pl");
> ?????
> 
> test();

### main.pl ###
use  strict;
use warnings;
require test.pl

&test;  # call function from test.pl


NOTE :  The *last* thing in any file that is "require"d
        *must* be a true expression. For example the last line of
        test.pl could simply be

        1;  # return true for require


-- 
---------

Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com


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

Date: Fri, 28 Mar 2003 15:42:00 +0000
From: Garry Heaton <none@none.com>
Subject: make error loading module via 'cpan'
Message-Id: <bYZga.2521$yF3.268011@stones.force9.net>

I've just tried loading a module with:

[root@localhost]# cpan Image::Magick

 ... but it chokes at the end with:

make: **** [Magick.o] Error 2
/usr/bin/make -- NOT OK

What the .....?

Garry Heaton




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

Date: 28 Mar 2003 04:49:35 -0800
From: foo.bar@jaekle.net (Matthias Jaekle)
Subject: MIME Entity is looking for dumpskeleto.al
Message-Id: <e6a23a7a.0303280449.5341fe63@posting.google.com>

Hi,

I would like to use MIME::Entity. And MIME::Entity seems to search for
dumpskeleto.al

But on my computer, there is no file called so. If just installed
MIME::Entity from CPAN. There are subroutines called dumpskeleton in
MIME::Entity.

But I also do not have a file called dumpskeleton.al

I get the following error message:
Can't locate auto/MIME/Entity/dumpskeleto.al in @INC (...)

Could somebody explain this error message and tell me how to search
for a solution.

Many thanks

Matthias Jaekle


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

Date: 28 Mar 2003 13:53:01 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: MIME Entity is looking for dumpskeleto.al
Message-Id: <u93cl7vbr6.fsf@wcl-l.bham.ac.uk>

foo.bar@jaekle.net (Matthias Jaekle) writes:

> But on my computer, there is no file called so. If just installed
> MIME::Entity from CPAN.

Are you sure you installed it?

Are you sure you didn't just unpack it and try to move the files into
place by hand?

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 28 Mar 2003 14:11:06 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: namespace with do "filename"
Message-Id: <slrnb88lvp.kat.efflandt@typhoon.xnet.com>

On Fri, 28 Mar 2003 07:00:16 GMT, Eric Wilhelm <ericw@nospam.ku.edu> wrote:
> I have a while loop which loads a data structure.  It has gotten somewhat
> long due to the conditionals and minor operations which have been added,
> but it needs to be used in several programs (single-purpose prototypish
> scripts).
> 
> I would like to keep it in one place for maintenance, consistency, etc.
> But it doesn't seem like it would lend itself to being a module.  All of
> the variables being read and loaded are global, so I thought I could just
> save it to a file like /usr/local/bin/dataloader.pl and call it into the main
> scripts with do like so:
> 
> # setup per-script items here ($filename="such and such")
> 
> # the while loop used to be here
> do "/usr/local/bin/dataloader.pl"
> 
> # continue
> 
> This works fine, but I'm wondering if it is going to lead me into trouble
> later.  Comments?

If you put dataloader.pl within one of the @INC paths you could do the
same thing using: require "dataloader.pl";

But then you may need to remember to preserve and/or relocate it if
upgrading to a different Perl version.

perldoc -f require

-- 
David Efflandt - All spam ignored  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Fri, 28 Mar 2003 14:43:31 GMT
From: Eric Wilhelm <ericw@nospam.ku.edu>
Subject: Re: namespace with do "filename"
Message-Id: <pan.2003.03.28.08.40.51.938575.1661@nospam.ku.edu>

On Fri, 28 Mar 2003 08:11:06 -0600, David Efflandt wrote:


> If you put dataloader.pl within one of the @INC paths you could do the
> same thing using: require "dataloader.pl";
> 
> But then you may need to remember to preserve and/or relocate it if
> upgrading to a different Perl version.
> 
> perldoc -f require
> 
> 
But the loop uses variables which are setup in the beginning of the
script, such as $inputfile, $addr, etc.  So, the require has to go in the
middle of the script and the dataloader.pl has to have a return(1) at the
end.

Thanks, for the tip, but I think the readability of "do thing" is a little
better here, since it is a call to action.

However, I do have some config files which are like: 
$var = "1529";
$hash = ( "key" => [ "thing1", "thing2" ] );

and in this case, require sounds much better, since they are not so much
an action as a requirement.  I have been using do for them, but I think I
will make those into requires (except the return requirement seems odd 
since there isn't really a reason to return anything).  

--Eric


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

Date: Fri, 28 Mar 2003 05:49:56 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: pattern matching
Message-Id: <slrnb88dn4.2sa.tadmc@magna.augustmail.com>

Philip Lees <pjlees@ics.forthcomingevents.gr> wrote:
> On Thu, 27 Mar 2003 23:58:21 -0500, istink <istink@real.bad.com>
> wrote:
> 
>>I'm learning pattern matching.
>>Is there a better way to do this. say I want to convert spaces to
>>underscore.


Yes, there is a better way to do it (that does not use pattern
matching at all).


>>$this=$orig;
>>$this=~s/ /_/g;
>>
>>how would I put those two lines together?
> 
> ( $this=$orig ) =~s/ /_/g;


   ( $this=$orig ) =~ tr/ /_/;


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


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

Date: Fri, 28 Mar 2003 14:19:53 -0000
From: "Bigus" <somewhere@nowhere.com>
Subject: Re: pattern matching
Message-Id: <b61lma$l12@newton.cc.rl.ac.uk>

Tad McClellan wrote:
> Philip Lees <pjlees@ics.forthcomingevents.gr> wrote:
>> On Thu, 27 Mar 2003 23:58:21 -0500, istink <istink@real.bad.com>
>> wrote:
>>
>>> I'm learning pattern matching.
>>> Is there a better way to do this. say I want to convert spaces to
>>> underscore.
>
>
> Yes, there is a better way to do it (that does not use pattern
> matching at all).
>
>
>>> $this=$orig;
>>> $this=~s/ /_/g;
>>>
>>> how would I put those two lines together?
>>
>> ( $this=$orig ) =~s/ /_/g;
>
>
>    ( $this=$orig ) =~ tr/ /_/;

So, 'tr' is just like 's' except it replaces every occurence of the pattern?
Is it more processor efficient aswell?

Bigus






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

Date: Fri, 28 Mar 2003 14:22:14 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: pattern matching
Message-Id: <Xns934C9B7DC366elhber1lidotechnet@62.89.127.66>

Bigus wrote:

> Tad McClellan wrote:
>> Philip Lees <pjlees@ics.forthcomingevents.gr> wrote:
>>> On Thu, 27 Mar 2003 23:58:21 -0500, istink <istink@real.bad.com>
>>> wrote:
>>>
>>>> I'm learning pattern matching.
>>>> Is there a better way to do this. say I want to convert spaces to
>>>> underscore.
>>
>>
>> Yes, there is a better way to do it (that does not use pattern
>> matching at all).
>>
>>
>>>> $this=$orig;
>>>> $this=~s/ /_/g;
>>>>
>>>> how would I put those two lines together?
>>>
>>> ( $this=$orig ) =~s/ /_/g;
>>
>>
>>    ( $this=$orig ) =~ tr/ /_/;
> 
> So, 'tr' is just like 's' except it replaces every occurence of the
> pattern? Is it more processor efficient aswell?


Why don't you read the docs?


-- 
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



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

Date: Fri, 28 Mar 2003 14:52:17 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: pattern matching
Message-Id: <3e845ff0.4244403799@news.cis.dfn.de>

On Fri, 28 Mar 2003 14:22:14 +0000 (UTC), "Bernard El-Hagin"
<bernard.el-hagin@DODGE_THISlido-tech.net> wrote:

>> So, 'tr' is just like 's' except it replaces every occurence of the
>> pattern? Is it more processor efficient aswell?
>
>Why don't you read the docs?

As big a fan as I am of the Perl documentation, this
is a pet peeve.  

'perldoc -f tr' gives me only:

   "tr///   The transliteration operator. Same as "y///". 
   See the perlop manpage."

As if anybody except Abigail knows what y/// is. ;-)

Now, the perlop page is pretty big, 31 pages or so,
with one hell of a lot of sections and no convenient
way to search for tr or isolate the tr section (20 A4
pages down).

This could be improved but I don't know how.
-- 
Regards, Helgi Briem
helgi DOT briem AT decode DOT is


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

Date: Fri, 28 Mar 2003 16:01:52 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: pattern matching
Message-Id: <Ql_ga.154$gp1.87@nwrddc02.gnilink.net>

Bigus wrote:
> So, 'tr' is just like 's' except it replaces every occurence of the
> pattern? Is it more processor efficient aswell?

No, 'tr' and 's' are in no way just like each other expect the syntax
appears to be similar.
RTFM

jue




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

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.  

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


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