[29510] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 754 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 14 21:10:05 2007

Date: Tue, 14 Aug 2007 18:09:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 14 Aug 2007     Volume: 11 Number: 754

Today's topics:
        Air conditioners for cars <knjaz0@gmail.com>
    Re: Air conditioners for cars <mart_in_medina@ya___.es>
    Re: conditional regular expressions <bill@ts1000.us>
        Configuring CGI timeouts <harini.gopi@gmail.com>
    Re: FAQ 6.16 How do I efficiently match many regular ex <allergic-to-spam@no-spam-allowed.org>
    Re: FAQ 6.16 How do I efficiently match many regular ex <peter@makholm.net>
    Re: FAQ 6.16 How do I efficiently match many regular ex <noreply@gunnar.cc>
    Re: FAQ 6.16 How do I efficiently match many regular ex <noreply@gunnar.cc>
    Re: Feedback form using cgi script <noreply@gunnar.cc>
        Get shell command return value in Perl program. <whdanj@gmail.com>
    Re: Get shell command return value in Perl program. <simon.chao@gmail.com>
    Re: Get shell command return value in Perl program. <see.sig@rochester.rr.com>
    Re: limiting the amount of resources used by perl <bart@nijlen.com>
    Re: limiting the amount of resources used by perl (Jens Thoms Toerring)
        Matching paired arrays into hash <brian.pat.kelly@googlemail.com>
    Re: pass by reference <savagebeaste@yahoo.com>
    Re: PERL Skipping a Call to a Sub. <framness@athenet.net>
        problems with LWP & HTTP <mail@bymouth.com>
    Re: problems with LWP & HTTP <see.sig@rochester.rr.com>
        Require versus just including the script <bill@ts1000.us>
    Re: Require versus just including the script <ts@dionic.net>
    Re: Require versus just including the script <simon.chao@fmr.com>
    Re: Require versus just including the script <tadmc@seesig.invalid>
        Tuned cars  airconditi@gmail.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 14 Aug 2007 14:47:19 -0700
From:  knjaz <knjaz0@gmail.com>
Subject: Air conditioners for cars
Message-Id: <1187128039.558754.198810@19g2000hsx.googlegroups.com>

Everything you need to know about car air conditioners...

http://car-air-conditioning.blogspot.com/



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

Date: Wed, 15 Aug 2007 00:06:03 +0200
From: Martin Griffith <mart_in_medina@ya___.es>
Subject: Re: Air conditioners for cars
Message-Id: <3p94c3ttgfh00hlsg5dh03lulltdgp8ntl@4ax.com>

On Tue, 14 Aug 2007 14:47:19 -0700, in comp.arch.embedded knjaz
<knjaz0@gmail.com> wrote:

>Everything you need to know about car air conditioners...
>
>http://car-air-conditioning.blogspot.com/
Do you do air conditioners for newsgroups?

You could make a fortune


Martin


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

Date: Tue, 14 Aug 2007 11:29:42 -0700
From:  Bill H <bill@ts1000.us>
Subject: Re: conditional regular expressions
Message-Id: <1187116182.515406.162280@b79g2000hse.googlegroups.com>

On Aug 14, 10:24 am, Mirco Wahab <wa...@chemie.uni-halle.de> wrote:
> Morfys wrote:
> >> I could understand this intended
> >> to match a string like
>
> >>     "open(X,X,X), 3"
> >> or
> >>     "open(X,X), 2"
>
> > that's what I meant. ;)
>
> OK, then there are some solutions available,
> my first trial would be something like:
>
> ...
> my @strings = (
>   "open(X,X,X), 1",
>   "open(X,X,X), 3",
>   "open(X,X,X), 31",
>   "open(X,X), 2",
>   "open(X,X), 23",
>   "open(X,X), 32" );
>
> my $n;
> no strict 'refs';
> my $rg = qr{\(
>                (\w?)[,)]?
>                (\w?)[,)]?
>                (\w?)[,)]?
>                (\w?)[,)]?
>               ,\s+
>               (??{ scalar(grep ${$_} ,1..@+) })
>               $
>             }x;
>
> print "\n$_" for grep /$rg/, @strings
> ...
>
> which is still simple and will work up to four
> "entities". To make a more comprehensive version -
> is left to you ;-)
>
> The "Trick" is to check the capture groups (\w)
> for 'trueness' (in grep) and take the 'number'
> of positively grepped items as the content
> (will be "2" or "3") of the dynamic regex
> part (??{ ... }).
>
> Regards
>
> M.

I know this may not be the most elegant way of doing it, but, using
the examples given couldn't you just do this:

my @strings = (
  "open(X,X,X), 1",
  "open(X,X,X), 3",
  "open(X,X,X), 31",
  "open(X,X), 2",
  "open(X,X), 23",
  "open(X,X), 32" );

foreach $temp (@strings)
{
@dbf=split(/\,/,$temp);
$numpart[@numpart] = $dbf[@dbf - 1];
}

And @numpart would hold all the decimal parts.

Bill H



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

Date: Tue, 14 Aug 2007 20:22:51 -0000
From:  "harini.gopi@gmail.com" <harini.gopi@gmail.com>
Subject: Configuring CGI timeouts
Message-Id: <1187122971.344083.282780@19g2000hsx.googlegroups.com>

Hi,

I have a CGI script wrapped as an exe running on IIS 6.0.  It needs to
parse a  31MB file located on a NFS and redirect the output to another
CGI script for plotting. It works fine when the file size (that needs
to be parsed) is smaller but for larger files it just ends abruptly
without further processing. I understand that this could be because
the connection timeout for CGI scripts on IIS 6.0 is set to 300 s. But
there is no GUI in the IIS properties to edit the same. Can someone
guide me to edit the metabase file (IIS 6.0) for increasing the
connection timeout ?Also is this the right approach? Would there be an
alternate way to prevent the timeout from happening without having to
modify the IIS setting?
I should also add that the script executes fine when it is  not
converted to an exe (conversion done via perl2exe) i.e when it remains
a stand alone ".pl" program. Does the wrapping into an exe cause any
other overhead that it forces a timeout?

Any reply would be appreciated.

Thanks,
Harini



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

Date: Tue, 14 Aug 2007 21:31:09 +0200 (CEST)
From: Jim Cochrane <allergic-to-spam@no-spam-allowed.org>
Subject: Re: FAQ 6.16 How do I efficiently match many regular expressions at once?
Message-Id: <slrnfc40ns.95e.allergic-to-spam@no-spam-allowed.org>

On 2007-08-14, PerlFAQ Server <brian@stonehenge.com> wrote:
> This is an excerpt from the latest version perlfaq6.pod, which
> ...
>
> 6.16: How do I efficiently match many regular expressions at once?
>
> ...
>
>             @patterns = map { qr/\b$_\b/i } qw( foo bar baz );
>
>             LINE: while( <> )
>                     {
>                     foreach $pattern ( @patterns )
>                             {
>                             print if /\b$pattern\b/i;

# Aren't the '\b's redundant here, or am I missing something?  If so,
# does this slow processing down slightly?

>                             next LINE;
>                             }
>                     }
>


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

Date: Tue, 14 Aug 2007 20:16:37 +0000
From: Peter Makholm <peter@makholm.net>
Subject: Re: FAQ 6.16 How do I efficiently match many regular expressions at once?
Message-Id: <87k5rxg9cq.fsf@hacking.dk>

Gunnar Hjalmarsson <noreply@gunnar.cc> writes:

>>>             @patterns = map { qr/\b$_\b/i } qw( foo bar baz );
>>>
>>>             LINE: while( <> )
>>>                     {
>>>                     foreach $pattern ( @patterns )
>>>                             {
>>>                             print if /\b$pattern\b/i;
>>
>> # Aren't the '\b's redundant here, or am I missing something?
>
> Unless you mean they should match words such as 'foolish' and
> 'barrister', you are missing something.

No, the \b's seem to get added twice. Once in the map statement and
once at the actual match statement. This should be redundant.

//Makholm


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

Date: Tue, 14 Aug 2007 22:01:30 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: FAQ 6.16 How do I efficiently match many regular expressions at once?
Message-Id: <5ieg0uF3oqkq4U1@mid.individual.net>

Jim Cochrane wrote:
> On 2007-08-14, PerlFAQ Server <brian@stonehenge.com> wrote:
>> This is an excerpt from the latest version perlfaq6.pod, which
>> ...
>>
>> 6.16: How do I efficiently match many regular expressions at once?
>>
>> ...
>>
>>             @patterns = map { qr/\b$_\b/i } qw( foo bar baz );
>>
>>             LINE: while( <> )
>>                     {
>>                     foreach $pattern ( @patterns )
>>                             {
>>                             print if /\b$pattern\b/i;
> 
> # Aren't the '\b's redundant here, or am I missing something?

Unless you mean they should match words such as 'foolish' and 
'barrister', you are missing something.

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


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

Date: Tue, 14 Aug 2007 22:25:32 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: FAQ 6.16 How do I efficiently match many regular expressions at once?
Message-Id: <5iehe0F3oam42U1@mid.individual.net>

Peter Makholm wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
> 
>>>>             @patterns = map { qr/\b$_\b/i } qw( foo bar baz );
>>>>
>>>>             LINE: while( <> )
>>>>                     {
>>>>                     foreach $pattern ( @patterns )
>>>>                             {
>>>>                             print if /\b$pattern\b/i;
>>> # Aren't the '\b's redundant here, or am I missing something?
>> Unless you mean they should match words such as 'foolish' and
>> 'barrister', you are missing something.
> 
> No, the \b's seem to get added twice. Once in the map statement and
> once at the actual match statement. This should be redundant.

Ouch! For some reason, I didn't notice them being added in map().

Sorry for the confusion.

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


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

Date: Tue, 14 Aug 2007 22:18:26 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Feedback form using cgi script
Message-Id: <5ieh0mF3ofe8fU1@mid.individual.net>

LaMoRt wrote:
> I will try out the solution u all give and tested it.

Whatever you do, don't put the script on a publicly available server. It 
can easily be abused to send spam to multiple recipients, even if you 
adopt the changes Paul and other suggested.

You may want to try the CPAN module CGI::ContactForm for a safer solution.

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


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

Date: Tue, 14 Aug 2007 21:58:43 -0000
From:  Dan <whdanj@gmail.com>
Subject: Get shell command return value in Perl program.
Message-Id: <1187128723.531820.267600@r34g2000hsd.googlegroups.com>

Hi all, I have a Perl script which includes a shell command, I want to
get the return result from this shell command, but when I check the $?
value, it is not correct, can anyone tell me how I can get the return
value?

my perl code:

  opendir(DIR, "/log") || die ("Can not open log directory");
  foreach $direntry (readdir(DIR))
  {
      if ($direntry =~ /2007\d{4}/)
      {
         $ja_request = system("grep -i 'INDEX' $BASE/$direntry/
FILE.log | wc -l");
      }
  }

Basically, I want to search the "INDEX" string, and count the number
of occurrence in file.LOG file. But the
$ra_request always is 0.

Can anyone help about this, thanks a lot!



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

Date: Tue, 14 Aug 2007 22:14:33 -0000
From:  it_says_BALLS_on_your_forehead <simon.chao@gmail.com>
Subject: Re: Get shell command return value in Perl program.
Message-Id: <1187129673.513532.195960@g4g2000hsf.googlegroups.com>

On Aug 14, 5:58 pm, Dan <whd...@gmail.com> wrote:
> Hi all, I have a Perl script which includes a shell command, I want to
> get the return result from this shell command, but when I check the $?
> value, it is not correct, can anyone tell me how I can get the return
> value?
>
> my perl code:
>
>   opendir(DIR, "/log") || die ("Can not open log directory");
>   foreach $direntry (readdir(DIR))
>   {
>       if ($direntry =~ /2007\d{4}/)
>       {
>          $ja_request = system("grep -i 'INDEX' $BASE/$direntry/
> FILE.log | wc -l");
>       }
>   }
>
> Basically, I want to search the "INDEX" string, and count the number
> of occurrence in file.LOG file. But the
> $ra_request always is 0.
>
> Can anyone help about this, thanks a lot!

Why use Perl for this? Why not just loop through it via your shell?
Anyway, if you want the output of a command that you 'shelled out',
just use the backtick operator instead of system().



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

Date: Tue, 14 Aug 2007 18:25:35 -0400
From: Bob Walton <see.sig@rochester.rr.com>
Subject: Re: Get shell command return value in Perl program.
Message-Id: <46c22bde$0$28798$4c368faf@roadrunner.com>

Dan wrote:
> Hi all, I have a Perl script which includes a shell command, I want to
> get the return result from this shell command, but when I check the $?
> value, it is not correct, can anyone tell me how I can get the return
> value?
> 
> my perl code:
> 
>   opendir(DIR, "/log") || die ("Can not open log directory");
>   foreach $direntry (readdir(DIR))
>   {
>       if ($direntry =~ /2007\d{4}/)
>       {
>          $ja_request = system("grep -i 'INDEX' $BASE/$direntry/
> FILE.log | wc -l");
>       }
>   }
> 
> Basically, I want to search the "INDEX" string, and count the number
> of occurrence in file.LOG file. But the
> $ra_request always is 0.
 ...

wc -l does not return the number of lines, it prints it to standard 
output.  You probably want to use qx() (the "backtick" operator) in 
order to obtain that standard output.  Maybe something like:

   $ja_request=`grep -i 'INDEX' $BASE/$direntry/FILE.log|wc -l`;

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


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

Date: Tue, 14 Aug 2007 11:51:15 -0700
From:  Bart Van der Donck <bart@nijlen.com>
Subject: Re: limiting the amount of resources used by perl
Message-Id: <1187117475.874431.8310@19g2000hsx.googlegroups.com>

Nospam wrote:

> Is there  way to limit the amount of resources/ram/cpu used by
> a perl script? so that the script still runs, but does not exceed
> certain limits?

Under unix, you might be interested in the nice-command (see "man
nice"). Personally I use it only for cronjobs.

--
 Bart

"It is necessary for technical reasons that these nuclear warheads are
positioned with the TOP at the BOTTOM and with the BOTTOM at the TOP.
In order that there may be no doubt as to which is the TOP and which
is the BOTTOM, it shall be seen that the BOTTOM of each nuclear
warhead has been labeled with the word TOP."
(Instructions issued by the British Admiralty, 1950's)



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

Date: 14 Aug 2007 20:18:03 GMT
From: jt@toerring.de (Jens Thoms Toerring)
Subject: Re: limiting the amount of resources used by perl
Message-Id: <5iegvrF3p8ldqU2@mid.uni-berlin.de>

Bart Van der Donck <bart@nijlen.com> wrote:
> Nospam wrote:
> > Is there  way to limit the amount of resources/ram/cpu used by
> > a perl script? so that the script still runs, but does not exceed
> > certain limits?

> Under unix, you might be interested in the nice-command (see "man
> nice"). Personally I use it only for cronjobs.

If the OP is using Unix he might also be interested in the
ulimit or limit (depending on the shell he's using) command.
But since he seems to be posting from a Windows machine this
as well could be completely uninteresting for him...

                              Regards, Jens
-- 
  \   Jens Thoms Toerring  ___      jt@toerring.de
   \__________________________      http://toerring.de


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

Date: Tue, 14 Aug 2007 16:28:57 -0700
From:  kelticeye <brian.pat.kelly@googlemail.com>
Subject: Matching paired arrays into hash
Message-Id: <1187134137.880225.216740@o61g2000hsh.googlegroups.com>

Hi, this is my first post to this group.

 I was wondering if there is an efficient method in perl for joining
two (properly ordered) arrays of equal length (@arrayA and @arrayB)
into a hash(%hash) so that $hash{$arrayA[i]} = $arrayB[i].

I need to do this as the first list is part of an incremental query to
a webform, and if the response is as expected (split up with a regex),
this should be proportional to the query and ordered in the same way
as the query.

Presently I do this through a loop, however this is ugly, creating
iterating variables and I feel I am missing a trick (BTW this does
work):-

    my %HresHash;
    if (scalar(@residuelist) == scalar(@fullH)){
        for (my $i = 0; $i < scalar(@fullH) ; $i++){
            my $reskey = "res".$fullH[$i];    # this is done as I want
to add it to a global hash later
            $HresHash{$reskey}= $residuelist[$i];
        }
    }

I have looked through the faqs, this group and google for an easy
answer or function, but please let me know if I am wasting your time
as I will appreciate being pointed in the right direction!



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

Date: Tue, 14 Aug 2007 12:53:45 -0700
From: "Clenna Lumina" <savagebeaste@yahoo.com>
Subject: Re: pass by reference
Message-Id: <5ieficF3ob56aU1@mid.individual.net>

Billy Patton wrote:
> Clenna Lumina wrote:
>> Billy Patton wrote:
>>> anno4000@radom.zrz.tu-berlin.de wrote:
>>>> Billy Patton  <bpatton@ti.com> wrote in comp.lang.perl.misc:
>>>>> Larry wrote:
>>>>>> The following code snippet shows how I do "pass by reference" in
>>>>>> Perl.  It works fine, but I'm wondering... is there a less
>>>>>> verbose way to do this?
>>>> [...]
>>>>
>>>>> Do you really want side effects ?
>>>>> Passing by reference does this.
>>>>> Guess this is too simple to make that decision.
>>>>>
>>>>> sub squareMe($) {
>>>>>    my ($arg) = @_;
>>>>>    $arg *= $arg;
>>>>> }
>>>>>
>>>>> my $n=7;
>>>>> $n = squareMe $n;  # no side effects
>>>>> I hate it when my variables get changed somewhere else and I have
>>>>> to track it down for debugging!
>>>> That raises the question why you are using the mutator "*=" at all.
>>>> It doesn't do anything useful.
>>>>
>>>>     sub square_me {
>>>>         my $arg = shift;
>>>>         $arg*$arg;
>>>>     }
>>>>
>>>> would be exactly equivalent, as would be
>>>>
>>>>     sub square_me { $_[0]*$_[0] }
>>>>
>>>> Anno
>>> The beauty of perl "Always more than one way to skin a cat" :)
>>
>> Just how many ways do you need to skin a cat :-P yeeesh
>>
>> (Seriously though, it's one the things I really love about Perl)
>>
>>
> Depends on the cat and your skinning tool :)

Very true.

P.S. Please stay away from my cat.

-- 
CL 




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

Date: Tue, 14 Aug 2007 16:11:16 -0700
From:  framness <framness@athenet.net>
Subject: Re: PERL Skipping a Call to a Sub.
Message-Id: <1187133076.940291.81640@19g2000hsx.googlegroups.com>

On Aug 14, 11:45 am, Paul Lalli <mri...@gmail.com> wrote:
> On Aug 14, 11:52 am, anno4...@radom.zrz.tu-berlin.de wrote:
>
> > framness  <framn...@athenet.net> wrote in comp.lang.perl.misc:
> > > On Aug 14, 8:33 am, anno4...@radom.zrz.tu-berlin.de wrote:
> > > > Are you running under "warnings"?
> > > no I am not running with warnings. How would do that with
> > > a cgi?
>
> > It works in a CGI script like in any other.  Put "use
> > warnings" early in the code.
>
> I'm wagging my finger at both Sherm and Anno, who gave a technically
> correct answer to this question, while (I'm assuming) knowing that
> that's really not what the OP meant.
>
> To the OP: After enabling warnings in your code as both Sherm and Anno
> said, you will need to either:
> (1) Look in your web server's error log.  That is where the warnings
> will go, because that is where STDERR has been redirected.
> (2) add the following lines to your script, and then view the source
> of the output, as they will cause warnings to be printed as HTML
> comments (and thus not actually seen by the browser):
> use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
> #whatever setup you need before printing the header...
> print header();
> warningsToBrowser(1);
>
> You need to not "turn on" warningsToBrowser until after you've printed
> the header, so as to not interphere with the HTTP response status
> line.  Perl will queue up any warnings that are generated, and then
> print them all as HTML comments once you've turned on this feature
> with the warningsToBrowser(1) line.
>
> Paul Lalli

The problem was: I had sometime ago creaeted a stub function with the
name LogAttack. I had forgotten of the stub function and created
another function and this time created it with the relevant code. PERL
was trying to execute the stub function. When you informed me PERL &
Apache place those warnings into the appropriate HTTPD error log I
tracked them down and noted the appropriate warnings. That and a
couple of other tweaks helped get it working.

Thanks
Mark



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

Date: Tue, 14 Aug 2007 15:08:40 -0700
From:  stephenc <mail@bymouth.com>
Subject: problems with LWP & HTTP
Message-Id: <1187129320.398125.284940@m37g2000prh.googlegroups.com>

Hi

I am trying to log into a secur site using this:

use LWP;
use Crypt::SSLeay;
use HTTP::Request::Common qw(POST);

my $ua = new LWP::UserAgent;




my $req = POST 'https://www.secure.********.com.au/Cardlink/
LoginServlet',
	[	'UserID' => '*********',
		'Password' => '********',
		'Submit' => 'Submit'
	];

print $req->as_string;
my $res = $ua->request($req)
print $response->content();

When I run it at the prompt it hangs after printing print $req-
>as_string;

I'm a bit out of my depth.  Anyone know how i can get this to return
the page I am lloking for?



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

Date: Tue, 14 Aug 2007 19:03:21 -0400
From: Bob Walton <see.sig@rochester.rr.com>
Subject: Re: problems with LWP & HTTP
Message-Id: <46c234b5$0$11014$4c368faf@roadrunner.com>

stephenc wrote:
 ...
> I am trying to log into a secur site using this:
> 
> use LWP;
> use Crypt::SSLeay;
> use HTTP::Request::Common qw(POST);
> 
> my $ua = new LWP::UserAgent;
> 
> 
> 
> 
> my $req = POST 'https://www.secure.********.com.au/Cardlink/
> LoginServlet',
> 	[	'UserID' => '*********',
> 		'Password' => '********',
> 		'Submit' => 'Submit'
> 	];
> 
> print $req->as_string;
> my $res = $ua->request($req)
> print $response->content();
> 
> When I run it at the prompt it hangs after printing print $req-
>> as_string;
 ...

When I try it, your code doesn't even compile.  Please try again, being 
sure to copy/paste your code rather than typing it in.

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


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

Date: Tue, 14 Aug 2007 11:14:41 -0700
From:  Bill H <bill@ts1000.us>
Subject: Require versus just including the script
Message-Id: <1187115281.638880.247980@o61g2000hsh.googlegroups.com>

Are there any upsides / downsides of putting commonly used routines in
a seperate module and "require"ing it in different programs versus
just putting the routines in the program other than the smaller
program size and ease of editting? Does using a module slow down
program execution?

Bill H



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

Date: Tue, 14 Aug 2007 20:10:52 +0100
From: Tim Southerwood <ts@dionic.net>
Subject: Re: Require versus just including the script
Message-Id: <46c1fe21$0$640$5a6aecb4@news.aaisp.net.uk>

Bill H coughed up some electrons that declared:

> Are there any upsides / downsides of putting commonly used routines in
> a seperate module and "require"ing it in different programs versus
> just putting the routines in the program other than the smaller
> program size and ease of editting? Does using a module slow down
> program execution?
> 
> Bill H

It's fine. In fact it's generally a "good idea". You'll get a few more
stat() calls and one more open() call for each module, but if you strace
perl, you see that pales into relative insignificance compared to all the
other stat()s and open()s it needs to do anyway just to get loaded.

If I've had a big project I might have a dozen modules, each handling a
logical group of functionality. For a one off, I've just lobbed the
routines into 3 .pl files, lightly grouped by functionality, just to make
the main program a bit smaller and more readable.

In both cases it's a winner for sanity, in the former, not doing so would
have been totally insane.

Cheers

Tim 


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

Date: Tue, 14 Aug 2007 19:10:45 -0000
From:  it_says_BALLS_on_your forehead <simon.chao@fmr.com>
Subject: Re: Require versus just including the script
Message-Id: <1187118645.304736.67980@k79g2000hse.googlegroups.com>

On Aug 14, 2:14 pm, Bill H <b...@ts1000.us> wrote:
> Are there any upsides / downsides of putting commonly used routines in
> a seperate module and "require"ing it in different programs versus
> just putting the routines in the program other than the smaller
> program size and ease of editting? Does using a module slow down
> program execution?

Upside 1: you obviate the need to copy/paste or rewrite routines in
scripts that need them
Upside 2: if you need to fix/enhance a routine, you only need to do it
once
Upside 3: smaller overall code base (more maintainable/manageable)

also, consider using 'use' rather than require--it includes the code
at compile time instead of run-time like 'require'. (actually, use is
the equivalent of wrapping a require in a BEGIN block.)




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

Date: Tue, 14 Aug 2007 19:54:03 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Require versus just including the script
Message-Id: <slrnfc4jlb.eb9.tadmc@tadmc30.sbcglobal.net>

it_says_BALLS_on_your forehead <simon.chao@fmr.com> wrote:

> (actually, use is
> the equivalent of wrapping a require in a BEGIN block.)


actually, use is the equivalent of wrapping a require and
an import in a BEGIN block.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Tue, 14 Aug 2007 14:54:07 -0700
From:  airconditi@gmail.com
Subject: Tuned cars
Message-Id: <1187128447.828727.142180@g4g2000hsf.googlegroups.com>

Cool cars, tuning & styling, here you can find many tuned cars with
tons of pictures!!!!!!!

http://tuning-styling.blogspot.com/



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

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 V11 Issue 754
**************************************


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