[25519] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7763 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 9 18:10:46 2005

Date: Wed, 9 Feb 2005 15:10:36 -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           Wed, 9 Feb 2005     Volume: 10 Number: 7763

Today's topics:
    Re: one more IP addr regexp <abigail@abigail.nl>
    Re: one more IP addr regexp <matternc@comcast.net>
    Re: one more IP addr regexp (Anno Siegel)
    Re: Perl debugger has wrong initial entry point and lin <glex_nospam@qwest.invalid>
    Re: Q: Why does this match not work? <tadmc@augustmail.com>
    Re: regex help <phaylon@dunkelheit.at>
    Re: regex help <postmaster@castleamber.com>
    Re: regex help <rasto@gmx.at>
    Re: regex help <rasto@gmx.at>
    Re: Regexp::Common question related to URI query <abigail@abigail.nl>
    Re: should be simple..but eh  Can you help (Anno Siegel)
        string and pattern problem <tajana@removeingko.com>
    Re: string and pattern problem <abigail@abigail.nl>
    Re: The Problem with Perl xhoster@gmail.com
    Re: The Problem with Perl (Anno Siegel)
    Re: The Problem with Perl <tadmc@augustmail.com>
    Re: The Problem with Perl <abigail@abigail.nl>
    Re: The Problem with Perl <ebohlman@omsdev.com>
    Re: The Problem with Perl <cwilbur@mithril.chromatico.net>
    Re: The Problem with Perl <ebohlman@omsdev.com>
    Re: The Problem with Perl <nospam-abuse@ilyaz.org>
        Using a module when not installed. <jazeker_b_nospamlalala@yahoo.co.uk>
    Re: Using a module when not installed. <jgibson@mail.arc.nasa.gov>
    Re: Using a module when not installed. (Anno Siegel)
    Re: Using a module when not installed. <jazeker_b_nospamlalala@yahoo.co.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 09 Feb 2005 21:38:05 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: one more IP addr regexp
Message-Id: <slrnd0l0lt.g2.abigail@alexandra.abigail.nl>

Big and Blue (No_4@dsl.pipex.com) wrote on MMMMCLXXX September MCMXCIII
in <URL:news:ceqdnbnKkNeb_ZTfRVnysg@pipex.net>:
''  
''      Try telnet'ing to them.  You'll see they all (try to) connect to 
''  34.34.34.34.


So, "localhost" is a valid IP address as well?



Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


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

Date: Wed, 09 Feb 2005 16:55:30 -0500
From: Chris Mattern <matternc@comcast.net>
Subject: Re: one more IP addr regexp
Message-Id: <jfednbNTudRPG5ffRVn-3g@comcast.com>

Abigail wrote:

> Big and Blue (No_4@dsl.pipex.com) wrote on MMMMCLXXX September MCMXCIII
> in <URL:news:ceqdnbnKkNeb_ZTfRVnysg@pipex.net>:
> ''
> ''      Try telnet'ing to them.  You'll see they all (try to) connect to
> ''  34.34.34.34.
> 
> 
> So, "localhost" is a valid IP address as well?
> 
> 
No, because it doesn't work if the process can't do name resolution.
The numbers B&B gave will (in most implementation of telnet, at least).

-- 
             Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"


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

Date: 9 Feb 2005 22:46:34 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: one more IP addr regexp
Message-Id: <cue3sa$85o$1@mamenchi.zrz.TU-Berlin.DE>

Gunnar Hjalmarsson  <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
> Chris Mattern wrote:
> > Gunnar Hjalmarsson wrote:
> >> Tintin wrote:
> >>> Would be useful if it matched valid IP addresses.
> >>>
> >>> 1.1.1.1.1 is not a valid IP address.
> >>
> >> It doesn't match that either.
> >>
> >>     my $re =
> >>qr/\b((\d|1{0,1}\d{2}|2[01234]\d|25[012345])\.){3}(\d|1{0,1}\d{2}|[01234]\d|25[012345])\b/;
> >>     my $ip = '1.1.1.1.1';
> >>     print "$1\n" if $ip =~ /($re)/;
> >>
> >> Outputs:
> >> 1.1.1.1
> > 
> > You want to try to edit more or less randomly things that aren't valid
> > IPs so that they'll be valid IPs?
> 
> Didn't say that. All I said was that it doesn't match '1.1.1.1.1'. :)

It should match the first valid IP address it meets.  So far it's up
to specification as a regex.  I haven't looked closely at it, it's much
too uninviting.  A regex isn't a good tool to check numeric ranges,
and it shows.  You don't see what checks what, so it's hard to tell
if it's correct.

If this must be done, write a simple regex that matches anything that
vaguely looks like an IP addr. /[.\d]+/ might do, but you could get more
sophisticated, still keeping the regex simple.  Then have a water-proof
checker that decides if a string is really valid.  Write that based on
split and numeric comparisons, so it's easy to see what checks are done
where.  Combine the two as needed to efficiently extract any number of IP
addresses from any amount of text.

Or use an industrial strength regex from Regex::Common.

Anno


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

Date: Wed, 09 Feb 2005 14:23:52 -0600
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: Perl debugger has wrong initial entry point and line numbers
Message-Id: <sjuOd.19$BT1.5359@news.uswest.net>


> Unquoted string "null" may clash with future reserved word at junk.perl
> line 70.
> Useless use of a constant in void context.

> How can I get the debugger to start at the first executable line and
> accurately reflect the source code
> line numbers?

>     } else {
>        null; # is a comment

Fix the syntax error and you'll be able to debug your code.


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

Date: Wed, 9 Feb 2005 14:55:19 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Q: Why does this match not work?
Message-Id: <slrnd0ku5n.4i6.tadmc@magna.augustmail.com>

jake1138 <cooljake@gmail.com> wrote:

>     while(<FILE>) {
>       chop;


That was how we removed newlines 8 years ago.

Where have you been?   :-)


The modern way to remove newlines is:

   perldoc -f chomp


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


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

Date: Wed, 09 Feb 2005 20:05:49 +0100
From: phaylon <phaylon@dunkelheit.at>
Subject: Re: regex help
Message-Id: <pan.2005.02.09.19.05.48.348177@dunkelheit.at>

Rainer Collet wrote:

> but the negated char-class [^<\/a>] is wrong, because if there is any of
> the characters of the class in the link-text is does not match. so it must
> be replaced by an expression that means: match 17 chars or more, if there
> is no "</a>" included in them.

Have a look at 'perldoc -q greedy'.

hth,phay

-- 
http://www.dunkelheit.at/
thou shallst fear...



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

Date: 9 Feb 2005 19:54:39 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: regex help
Message-Id: <Xns95F88D813B0B2castleamber@130.133.1.4>

Rainer Collet wrote:

> hi!
> 
> i need a regex that matches all link-texts in html that are longer
> than 17 characters. i started with

Use HTML::TreeBuilder for example and:

my @elements = $root->look_down(
    _tag => 'a',
    sub { length( $_[0]->as_text ) > 17 }
};

(untested)

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: Wed, 09 Feb 2005 21:01:03 +0100
From: Rasto Levrinc <rasto@gmx.at>
Subject: Re: regex help
Message-Id: <420a6ade$0$12126$3b214f66@tunews.univie.ac.at>

Rainer Collet wrote:
> hi!
> 
> i need a regex that matches all link-texts in html that are longer
> than 17 characters. i started with
> 
> /<a.*?href=.*?>[^<\/a>]{18,}<\/a>/i
> 
> has anybody an idea?
> 

You should do it with HTML::TreeBuilder or something, but if it is an
exercise, I came up with this solution:

my @res = /<a\s+href=.*?>((?:.(?!<\/a>)){16,}.)<\/a>/ig;

(It doesn't matter that {16,} is greedy)

Rasto

-- 

Rasto Levrinc
http://sourceforge.net/projects/rlocate/


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

Date: Wed, 09 Feb 2005 21:09:13 +0100
From: Rasto Levrinc <rasto@gmx.at>
Subject: Re: regex help
Message-Id: <420a6cc8$0$12126$3b214f66@tunews.univie.ac.at>

Rasto Levrinc wrote:
> Rainer Collet wrote:
> 
>> hi!
>>
>> i need a regex that matches all link-texts in html that are longer
>> than 17 characters. i started with
>>
>> /<a.*?href=.*?>[^<\/a>]{18,}<\/a>/i
>>
>> has anybody an idea?
>>
> 
> You should do it with HTML::TreeBuilder or something, but if it is an
> exercise, I came up with this solution:
> 
> my @res = /<a\s+href=.*?>((?:.(?!<\/a>)){16,}.)<\/a>/ig;
> 

Correction:

@res = $str=~/<a\s+href=[^>]*>((?:.(?!<\/a>)){16,}.)<\/a>/ig;

> Rasto
> 


-- 

Rasto Levrinc
http://sourceforge.net/projects/rlocate/


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

Date: 09 Feb 2005 21:42:23 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Regexp::Common question related to URI query
Message-Id: <slrnd0l0tv.g2.abigail@alexandra.abigail.nl>

news.socket.net (info4l@info-for-life.com) wrote on MMMMCLXXX September
MCMXCIII in <URL:news:110ka9pppjh6i83@corp.supernews.com>:
-:  I'm using:
-:  
-:  use Regexp::Common qw /!delimited/;
-:  
-:  and then trying to figure out how to modify this line:
-:  
-:  $line =~ s!$RE{URI}{HTTP}{-keep}!<a href="$1">$1</a>!g;
-:  
-:  such that it will convert any line that contains a valid URL
-:  to a hyperlinked URL, i.e.
-:  
-:  http://www.mysite.com    becomes:   <a
-:  href="http://www.mysite.com">http://www.mysite.com</a>
-:  
-:  Currently, this line of code works, but not if  $line contains a query after
-:  the URL, i.e.
-:  
-:  http://www.mysite.com?ref=1234
-:  
-:  which is erroneously being replaced as:
-:  
-: <a href="http://www.mysite.com">http://www.mysite.com</a>?ref=1234

No. That's correct.

http://www.mysite.com?ref=1234 is not a valid URI. If you want a query,
you *need* a slash.

  $_ = "http://www.mysite.com/?ref=1234";
  s!$RE{URI}{HTTP}{-keep}!<a href="$1">$1</a>!;
  print;
  __END__
  <a href="http://www.mysite.com/?ref=1234">http://www.mysite.com/?ref=1234</a>



Abigail
-- 
$_ = "\x3C\x3C\x45\x4F\x54";
print if s/<<EOT/<<EOT/e;
Just another Perl Hacker
EOT


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

Date: 9 Feb 2005 22:07:31 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: should be simple..but eh  Can you help
Message-Id: <cue1j3$5tc$1@mamenchi.zrz.TU-Berlin.DE>

Bernard El-Hagin <bernard.el-haginDODGE_THIS@lido-tech.net> wrote in comp.lang.perl.misc:

> Can something be minor *and* important? ;-)

Ask a kid.

Anno


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

Date: Wed, 9 Feb 2005 23:09:39 -0800
From: "Tajana" <tajana@removeingko.com>
Subject: string and pattern problem
Message-Id: <420a8a29$1@news.s5.net>

1.) How to extract telephone number from string.
Form for telephone number is XXX/XXXX-XXX or XXX/XXX-XXX or XX/XXXX-XXX, so
I have problem with different number format.X is for numeric
                                                        3    /     4     - 3
or   3     / 3     -    3     or   2  /    4      -    3 number character
Eg. Phone numbers:
091/5444-333
098/255-555
042/255-555
01/6555-333

There is possible that string have more than one phone number.

2.) How to check position of pattern in some string
Eg.
$pattern ="my";
$string= "my dog is my pet";

Answer is: 0 , and 10

Perl programming it's very interesting, but some problem is too hard for me!
Please help me!

Thanks
Tajana




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

Date: 09 Feb 2005 22:19:47 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: string and pattern problem
Message-Id: <slrnd0l343.g2.abigail@alexandra.abigail.nl>

Tajana (tajana@removeingko.com) wrote on MMMMCLXXXI September MCMXCIII in
<URL:news:420a8a29$1@news.s5.net>:
@@  1.) How to extract telephone number from string.
@@  Form for telephone number is XXX/XXXX-XXX or XXX/XXX-XXX or XX/XXXX-XXX, so
@@  I have problem with different number format.X is for numeric
@@                                                          3    /     4     - 3
@@  or   3     / 3     -    3     or   2  /    4      -    3 number character
@@  Eg. Phone numbers:
@@  091/5444-333
@@  098/255-555
@@  042/255-555
@@  01/6555-333

    m![0-9]{2}(?:[0-9]/[0-9]?|/[0-9])[0-9]{3}-[0-9]{3}!g;

@@  There is possible that string have more than one phone number.
@@  
@@  2.) How to check position of pattern in some string
@@  Eg.
@@  $pattern ="my";
@@  $string= "my dog is my pet";
@@  
@@  Answer is: 0 , and 10

    printf "Found '%s' on position %d\n" => $1, $- [0]
            while $string =~ /($pattern)/g;

Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


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

Date: 09 Feb 2005 19:05:32 GMT
From: xhoster@gmail.com
Subject: Re: The Problem with Perl
Message-Id: <20050209140532.889$EN@newsreader.com>

William Goedicke <goedicke@brandeis.edu> wrote:

>
> My best understanding of what they think the problem is that Perl is
> "context sensitive".  That is it behaves differently when data
> changes,

Well duh.  What good would a program be that didn't?

> if lists slip in where scalars were intended the results may
> be wildly different than expected.  This wouldn't be true in strongly
> typed languages like C or lisp.

I don't think it is generally true in Perl, either.  It is the code,
not the data, that determines list or scalar context.

> Do others have knowledge of such (and possibly other) criticisms and,
> what do you think we should do to avoid the associated pitfalls.

Pay attention to what you are coding!

The biggest problem I run into in Perl is its time and memory usage in
certain areas.  After that, most of the problems are political.  Vendors
and consultants don't talk up Perl because it doesn't help them sell stuff.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: 9 Feb 2005 19:24:26 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: The Problem with Perl
Message-Id: <cudo1a$1vj$1@mamenchi.zrz.TU-Berlin.DE>

William Goedicke  <goedicke@brandeis.edu> wrote in comp.lang.perl.misc:

[Perl as a programming language]

> My best understanding of what they think the problem is that Perl is
> "context sensitive".



In what sense?  "Context sensitive" is a term that applies to grammars
(and, by extension, to parsers).

Perl can't be parsed as a context-free grammar?  You bet it can't.  Neither
can Fortran, or, AFAIK, C.  I don't know about C for sure, but I'd be
surprised.  This property of a grammar has little to do with the practical
usability of the programming language.

Perl also has the concept of (list/scalar/void-) context pertaining to
various parts of the source, but describing this as being "context
sensitive" is abuse of terminology.

> That is it behaves differently when data
> changes,

So?  C and Lisp programs don't do that?

> if lists slip in where scalars were intended the results may
> be wildly different than expected.  This wouldn't be true in strongly
> typed languages like C or lisp.

Lisp is a typed language?  I never noticed.

This critique of Perl contains so many ill-conceived notions, it is hard
to take it serious.

Anno


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

Date: Wed, 9 Feb 2005 14:51:22 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: The Problem with Perl
Message-Id: <slrnd0ktua.4i6.tadmc@magna.augustmail.com>

William Goedicke <goedicke@brandeis.edu> wrote:
>>>>>> "Sinan" == A Sinan Unur <1usa@llenroc.ude.invalid> writes:


>    Sinan> perldoc -q compare
> 
> I was hoping for considerably more depth than the perldoc answer,
> semantic theory sort of stuff.


Like why Larry designed Perl the way he did?

    http://www.wall.org/~larry/natural.html


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


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

Date: 09 Feb 2005 21:15:58 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: The Problem with Perl
Message-Id: <slrnd0kvce.g2.abigail@alexandra.abigail.nl>

William Goedicke (goedicke@brandeis.edu) wrote on MMMMCLXXX September
MCMXCIII in <URL:news:m3d5vauipd.fsf@goedsole.com>:
??  
??  The point of this message is that I'd like to open a discussion that
??  identifies exactly what it is about Perl as a language that offends
??  the literati of programming and, respecting that there may be some
??  valid points there, how we can code to avoid the problems these issues
??  may lead to.

A reaction, in the hope your posting isn't a troll.

If you want to know what it is that offends "the literati of programming",
you should inform yourself at the "the literati of programming". All we
could do here is guess what they find objective, which isn't constructive
at all. 

I don't care at all what other people find objective. They are probably
right. I like Perl. And that's more than enough. I can understand people
not liking Perl - and I think that for the majority of the people,
including the majority of the people now using Perl, Perl is the wrong
choice.

But so be it. 


Abigail
-- 
perl -wle 'print "Prime" if (0 x shift) !~ m 0^\0?$|^(\0\0+?)\1+$0'


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

Date: 9 Feb 2005 21:33:25 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: The Problem with Perl
Message-Id: <Xns95F89F89E6BBCebohlmanomsdevcom@130.133.1.4>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in
news:cudo1a$1vj$1@mamenchi.zrz.TU-Berlin.DE: 

> Perl can't be parsed as a context-free grammar?  You bet it can't. 
> Neither can Fortran, or, AFAIK, C.  I don't know about C for sure, but
> I'd be surprised.  This property of a grammar has little to do with

It can't.  C requires that functions be called with the same number of 
parameters they're declared with, and that can't be expressed in a CFG.


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

Date: Wed, 09 Feb 2005 21:39:22 GMT
From: Charlton Wilbur <cwilbur@mithril.chromatico.net>
Subject: Re: The Problem with Perl
Message-Id: <871xbpzaa1.fsf@mithril.chromatico.net>

>>>>> "WG" == William Goedicke <goedicke@brandeis.edu> writes:

>>>>> "Charlton" == Charlton Wilbur <cwilbur@mithril.chromatico.net> writes:

    Charlton> Stop worrying about what other people think.

    WG> You misunderstood.  I'm not worrying; I'm learning.

Well, if you want to learn, ask the people who disparage Perl why they
do so.  Odds are you'll find, if you can dig below the surface, that
it's most likely based on inaccurate information, experience with a
disastrous Perl project, or adherence to some orthodox One True Way to
Program.

Perl does have weaknesses.  In particular, it is flexible enough that
in the hands of poor programmers it can be disastrous for large
products.  This is an intentionally chosen tradeoff, however: if the
language enforces a certain discipline on its programmers, then
programmers who are capable of imposing different discipline on
themselves find the language frustrating to use (though programmers
who would otherwise have no discipline benefit greatly).  A bad
programmer using Perl can create more disasters for other people to
clean up than a bad programmer using just about any other language,
because Perl is so flexible and forgiving -- and I've left jobs before
because I knew that if I stayed I'd get to deal with cleaning up Perl
messes; but I don't ascribe that to the language, but to the
programmer using it.  

Perl is also not aesthetically pure.  It's not a purely functional
language, it's not a purely object-oriented language; it's not a
purely minimalist close-to-the-machine language.  It has aspects of
all of them, though.  It wasn't designed from the start with a single
vision; it grew in bits and pieces.  This lack of purity -- hybrid
vigor, one might say -- is one of its greatest strengths, because
there are many ways to solve any particular problem.  But when you
compare it to the purebred Scheme and Eiffel and Smalltalk --
languages that academics are likely to have used disproportionately
more than the hoi polloi -- it looks like a mongrel.  

All that said, if you want to understand why your colleages disparage
Perl, ask them.  Odds are that the people who disparage Perl, aside
from the odd troll, are not hanging out in comp.lang.perl.misc just
waiting for an opportunity to explain themselves.

Charlton



-- 
cwilbur at chromatico dot net
cwilbur at mac dot com


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

Date: 9 Feb 2005 22:12:03 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: The Problem with Perl
Message-Id: <Xns95F8A61723822ebohlmanomsdevcom@130.133.1.4>

Charlton Wilbur <cwilbur@mithril.chromatico.net> wrote in
news:871xbpzaa1.fsf@mithril.chromatico.net: 

> Perl does have weaknesses.  In particular, it is flexible enough that
> in the hands of poor programmers it can be disastrous for large
> products.  This is an intentionally chosen tradeoff, however: if the
> language enforces a certain discipline on its programmers, then
> programmers who are capable of imposing different discipline on
> themselves find the language frustrating to use (though programmers
> who would otherwise have no discipline benefit greatly).  A bad

This is a really important point.  Perl shouldn't be thought of as an 
"undisciplined language"; it should be thought of as a "bring your own 
discipline (BYOD) language."  Larry's philosophy is that programming 
discipline is a human issue, not a technical one, and therefore needs to be 
enforced by human (social) means, not through technical characteristics of 
tools.


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

Date: Wed, 9 Feb 2005 22:41:25 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: The Problem with Perl
Message-Id: <cue3il$6p7$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Charlton Wilbur 
<cwilbur@mithril.chromatico.net>], who wrote in article <871xbpzaa1.fsf@mithril.chromatico.net>:

> Perl does have weaknesses.  In particular, it is flexible enough that
> in the hands of poor programmers it can be disastrous for large
> products.  This is an intentionally chosen tradeoff, however

There is very little "intentionally chosen" in Perl; design-wise Perl
is a hodge-podge of backward-compatibility hacks and incremental
development mess.  (It still has some advantages over competition in
other respects - but only for some people; people who cann't fight
their vomit reflex are not in a reasonable state for good coding.)

Compare with what you write below:

> all of them, though.  It wasn't designed from the start with a single
> vision; it grew in bits and pieces.

Hope this helps.
Ilya


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

Date: Wed, 09 Feb 2005 19:59:56 GMT
From: Jazeker <jazeker_b_nospamlalala@yahoo.co.uk>
Subject: Using a module when not installed.
Message-Id: <0ZtOd.7681$Ml6.562190@phobos.telenet-ops.be>

Well... using is the wrong word, and the right one too.

I have a script that can work with the GD module, but not necessarily 
has to (It's just better to use it).  However, when my code says :

use GD;

The script won't run.  Is there a way to tell Perl to execute the 'use' 
statement only conditionally ?  I tried to put it in an unused sub, but 
to no avail (logical it seems as it's being translated by the 'precompiler')

thx for any inputs,
Jaz
-- 
print <<EOF;
   Just a noobish Perl hacker
EOF


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

Date: Wed, 09 Feb 2005 12:54:13 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Using a module when not installed.
Message-Id: <090220051254138121%jgibson@mail.arc.nasa.gov>

In article <0ZtOd.7681$Ml6.562190@phobos.telenet-ops.be>, Jazeker
<jazeker_b_nospamlalala@yahoo.co.uk> wrote:

> Well... using is the wrong word, and the right one too.
> 
> I have a script that can work with the GD module, but not necessarily 
> has to (It's just better to use it).  However, when my code says :
> 
> use GD;
> 
> The script won't run.  Is there a way to tell Perl to execute the 'use' 
> statement only conditionally ?  I tried to put it in an unused sub, but 
> to no avail (logical it seems as it's being translated by the 'precompiler')

Use the 'require' statement, which is executed at runtime. The 'use'
statement is always executed at compile-time, as if it were enclosed in
a BEGIN block.

Try reading 

   perldoc -f use
   perldoc -f require


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


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

Date: 9 Feb 2005 21:03:51 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Using a module when not installed.
Message-Id: <cudtrn$52j$1@mamenchi.zrz.TU-Berlin.DE>

Jazeker  <jazeker_b_nospamlalala@yahoo.co.uk> wrote in comp.lang.perl.misc:
> Well... using is the wrong word, and the right one too.
> 
> I have a script that can work with the GD module, but not necessarily 
> has to (It's just better to use it).  However, when my code says :
> 
> use GD;
> 
> The script won't run.  Is there a way to tell Perl to execute the 'use' 
> statement only conditionally ?  I tried to put it in an unused sub, but 
> to no avail (logical it seems as it's being translated by the 'precompiler')

"At compile time" is the term.  The Perl interpreter has two phases,
the other is run time.

Here is one way:  Replace

    use MayBe qw( fie foe);

with

    BEGIN { eval { require MayBe } and MayBe->import( qw( fie foe)) }

This should have the same effect as "use ..." if MayBe.pm exists in
@INC, and no effect but no complaint either if it doesn't.

Anno


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

Date: Wed, 09 Feb 2005 22:58:38 GMT
From: Jazeker <jazeker_b_nospamlalala@yahoo.co.uk>
Subject: Re: Using a module when not installed.
Message-Id: <yAwOd.7854$bk3.461856@phobos.telenet-ops.be>

Anno Siegel wrote:

> "At compile time" is the term.  The Perl interpreter has two phases,
> the other is run time.
> 
> Here is one way:  Replace
> 
>     use MayBe qw( fie foe);
> 
> with
> 
>     BEGIN { eval { require MayBe } and MayBe->import( qw( fie foe)) }
> 
> This should have the same effect as "use ..." if MayBe.pm exists in
> @INC, and no effect but no complaint either if it doesn't.
> 
> Anno

I will look up the things you both have referred me directly or 
indirectly to.  Thanks a lot !

-- 
print <<EOF;
   Just a noobish Perl hacker
EOF


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 7763
***************************************


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