[25082] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7332 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 28 14:10:48 2004

Date: Thu, 28 Oct 2004 11:10:10 -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           Thu, 28 Oct 2004     Volume: 10 Number: 7332

Today's topics:
        How to handle large variable <shashidhar.hv@in.bosch.com>
    Re: How to handle large variable <mritty@gmail.com>
    Re: How to handle large variable <do-not-use@invalid.net>
    Re: How to handle large variable <jwillmore@adelphia.net>
    Re: How to handle large variable <1usa@llenroc.ude.invalid>
    Re: How to handle large variable <lwt0301@bellsouth.net>
    Re: HOW TO replace ' but not ?' <whitey@newmail.net>
    Re: How's my logic? <whitey@newmail.net>
    Re: Is there a wholly Perl Database equivalent to say M (krakle)
        long lines <dont.spam.me@spamhate.com>
    Re: long lines <noreply@gunnar.cc>
    Re: perl to english <bradd+news@szonye.com>
    Re: removin \n from only part of a string (sroemerm)
    Re: removin \n from only part of a string <whitey@newmail.net>
    Re: removin \n from only part of a string <tadmc@augustmail.com>
    Re: removin \n from only part of a string <noreply@gunnar.cc>
    Re: removin \n from only part of a string <noreply@gunnar.cc>
    Re: Should I use BEGIN, CHECK, or INIT? <nobull@mail.com>
    Re: Should I use BEGIN, CHECK, or INIT? <nobull@mail.com>
    Re: Should I use BEGIN, CHECK, or INIT? <nobull@mail.com>
    Re: Verify a url form a perl script (joe)
    Re: What are these extra spaces in my registry? <nobull@mail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 28 Oct 2004 19:50:37 +0530
From: "Shashidhar Vajramatti" <shashidhar.hv@in.bosch.com>
Subject: How to handle large variable
Message-Id: <clqv7t$imb$1@ns2.fe.internet.bosch.com>

Hello,
        As listed below in the snippet of code, I am trying to handle a
file's contents by copying in to a single variable. It works fine for the
files of lesser size( few MegaBytes). But when the size of the file is more
than 16MB, it gives me an error message saying "System out of memory".

    But perl doesnot have any limits to the size of the variable. Then, what
can be the reason for this problem?

Following is the code which is used to handle the file contents through a
single variable using regular expressions.

#$file = join '',<IN>;

@file = <IN>;



Error Message: "System Out of Memory"








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

Date: Thu, 28 Oct 2004 14:33:17 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: How to handle large variable
Message-Id: <Nq7gd.4187$Xq3.477@trndny01>

"Shashidhar Vajramatti" <shashidhar.hv@in.bosch.com> wrote in message
news:clqv7t$imb$1@ns2.fe.internet.bosch.com...
> Hello,
>         As listed below in the snippet of code, I am trying to handle
a
> file's contents by copying in to a single variable. It works fine for
the
> files of lesser size( few MegaBytes). But when the size of the file is
more
> than 16MB, it gives me an error message saying "System out of memory".
>
>     But perl doesnot have any limits to the size of the variable.
Then, what
> can be the reason for this problem?

Exactly what the error message says: your system is out of memory.
Perl's only limitations (memory-wise) are your systems limitations.
You're trying to store an absurd amount of data in active memory.

What makes you believe you have a need to do this?  Perhaps if you tell
us you're actual goal, rather than your proposed solution to your goal,
we can help you find a better way.

> Following is the code which is used to handle the file contents
through a
> single variable using regular expressions.
>
> #$file = join '',<IN>;
>
> @file = <IN>;
>

There are no regular expressions in that snippet.  Show us a *short but
complete* program that demonstrates what you're trying to do.

Paul Lalli




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

Date: 28 Oct 2004 16:36:07 +0200
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: How to handle large variable
Message-Id: <yzdekji3o6g.fsf@invalid.net>


"Shashidhar Vajramatti" <shashidhar.hv@in.bosch.com> writes:
>         As listed below in the snippet of code, I am trying to handle a
> file's contents by copying in to a single variable. It works fine for the
> files of lesser size( few MegaBytes). But when the size of the file is more
> than 16MB, it gives me an error message saying "System out of memory".
> 
>     But perl doesnot have any limits to the size of the variable. Then, what
> can be the reason for this problem?
> 
> Following is the code which is used to handle the file contents through a
> single variable using regular expressions.
> 
> #$file = join '',<IN>;
> 
> @file = <IN>;
> 
> Error Message: "System Out of Memory"

For what it's worth, I tried reading in a 9 MB file using this method,
and my perl dumped core with "out of memory" and produced a core dump
of 66 MB. The data need a lot more memory when contained in a Perl data
structure than it does on disk. Exactly how much depends on the system.

I think that even if you have enough swap space to handle all your big
files, doing it this way is a bad idea. Handling the files one line
at a time keeps the perl process small, and therefore faster (due to
less paging).


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

Date: Thu, 28 Oct 2004 10:36:51 -0400
From: James Willmore <jwillmore@adelphia.net>
Subject: Re: How to handle large variable
Message-Id: <7dudnb5NpqFwnhzcRVn-gw@adelphia.com>

Shashidhar Vajramatti wrote:

>         As listed below in the snippet of code, I am trying to handle a
> file's contents by copying in to a single variable. It works fine for the
> files of lesser size( few MegaBytes). But when the size of the file is more
> than 16MB, it gives me an error message saying "System out of memory".
> 
>     But perl doesnot have any limits to the size of the variable. Then, what
> can be the reason for this problem?

Physical and "virtual" (like swap space) memory has run out.  This is 
the reason why most in this newsgroup say to read a file a line at a 
time.  If you have no way of knowing how big a file will be *before* you 
read the file, then you should stick with reading the file a line at a time.

> Following is the code which is used to handle the file contents through a
> single variable using regular expressions.
> 
> #$file = join '',<IN>;
> 
> @file = <IN>;
> 
> 
> 
> Error Message: "System Out of Memory"

Both methods you have outlined above will fail if you try to read a file 
that is greater than your available memory.  I'm not 100% sure if you 
can use File::Slurp to do whatever it is you're trying to do.

What are you trying to do that you feel the need to read the entire file 
into memory?

Jim


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

Date: 28 Oct 2004 14:56:39 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: How to handle large variable
Message-Id: <Xns95906F54F83CBasu1cornelledu@132.236.56.8>

"Shashidhar Vajramatti" <shashidhar.hv@in.bosch.com> wrote in
news:clqv7t$imb$1@ns2.fe.internet.bosch.com: 

> Following is the code which is used to handle the file contents
> through a single variable using regular expressions.
> 
> #$file = join '',<IN>;
> 
> @file = <IN>;

I am surprised why no one has pointed out that this a bad, bad way to 
slurp a file. File::Slurp is an excellent module:

http://search.cpan.org/~uri/File-Slurp-9999.06/lib/File/Slurp.pm

One can also do:

{
   local $/;
   $file = <IN>;
}

Reading the lines of a file into an array and then joining those lines 
ought to effectively double the memory requirement.

-- 
A. Sinan Unur
1usa@llenroc.ude.invalid 
(remove '.invalid' and reverse each component for email address)



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

Date: Thu, 28 Oct 2004 13:52:38 -0400
From: Laura <lwt0301@bellsouth.net>
Subject: Re: How to handle large variable
Message-Id: <10o2clc8npqm1d4@news.supernews.com>

A. Sinan Unur wrote:

> "Shashidhar Vajramatti" <shashidhar.hv@in.bosch.com> wrote in
> news:clqv7t$imb$1@ns2.fe.internet.bosch.com:
> 
>> Following is the code which is used to handle the file contents
>> through a single variable using regular expressions.
>> 
>> #$file = join '',<IN>;
>> 
>> @file = <IN>;
> 
> I am surprised why no one has pointed out that this a bad, bad way to
> slurp a file. File::Slurp is an excellent module:

What is so great about this File::Slurp module anyway?  Does it deal with
files on a byte level using buffers appropriately?  How is it that the
built in way of doing it is less efficient?  If File::Slurp is so great,
why is it not one of the modules included with Perl?

The problem with reading line by line is that you have to read ahead through
the file to see where the lines start and end if you want random access or
you are stuck going sequentially.  I propose that a user should be able to
page through a file with random access ability, loading a specified sized
chunk at a time.  You could also have the chunk auto-shrink or expand to
the nearest line(s).  Or, you could create an index of lines saved to the
same or a separate file so future accesses of lines will not take so long.

> 
> http://search.cpan.org/~uri/File-Slurp-9999.06/lib/File/Slurp.pm
> 
> One can also do:
> 
> {
>    local $/;
>    $file = <IN>;
> }
> 
> Reading the lines of a file into an array and then joining those lines
> ought to effectively double the memory requirement.
> 



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

Date: Thu, 28 Oct 2004 09:30:49 -0500
From: Whitey Johnson <whitey@newmail.net>
Subject: Re: HOW TO replace ' but not ?'
Message-Id: <pan.2004.10.28.14.30.49.432686@newmail.net>

On Wed, 27 Oct 2004 17:45:44 +0000, Paul Lalli muttered incoherently:

> "Whitey Johnson" <whitey@newmail.net> wrote in message
> news:pan.2004.10.27.17.34.09.442818@newmail.net...
<snip>
>> I read Tad's post and was wondering if there was a case where this
>> wouldn't work?
>>
> 
> Yes.  Read my post in this thread.
> 
> Paul Lalli

Thanks. I don't remember negative lookbehind assertions in the Llama book
and it seems I am a couple of chapters away from them in the Camel book.


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

Date: Thu, 28 Oct 2004 09:44:41 -0500
From: Whitey Johnson <whitey@newmail.net>
Subject: Re: How's my logic?
Message-Id: <pan.2004.10.28.14.44.40.694065@newmail.net>

On Wed, 27 Oct 2004 15:55:00 -0400, wana muttered incoherently:

> Here is a piece of code from a simple program I wrote to do some FTPing.  I
> was wondering if the form of my statement is acceptable with respect to the
> use of 'and' and 'or'.  I did it, hoping for the best, and it seems to
> work.  I am always shaky on rules of precedence and usually use lots of
> ()'s to make sure I get it right, but I am trying to wean myself off of
> them.
> 
> if ($user and $pass)
> {
>         $ftp->login($user, $pass)
>         and print "successfully logged on to $server as $user\n"
>         or print "problem logging on to $server as $user\n";
> }
> 
> 
> Thanks!

I haven't tried anything with ftp yet but could you use an 'or die' here
so that you don't have to wait for the rest of the program to execute if
you can't log in?

$ftp->login($user, $pass) or die "Couldn't log in: $!\n;
print "logged into $server successfully\n";
 ...rest of prog.


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

Date: 28 Oct 2004 10:04:42 -0700
From: krakle@visto.com (krakle)
Subject: Re: Is there a wholly Perl Database equivalent to say MySQL?
Message-Id: <237aaff8.0410280904.382a8f20@posting.google.com>

zzapper <david@tvisnospam.co.uk> wrote in message news:<lki1o0d8uditjfpsbc0583o6g5t4cqm5io@4ax.com>...
> Hi,
> I find with horror that I have to do a "Membership" project without access to MYSQL. Is there a
> wholly Perl Mini-Database Module/Application you would care to recommend. It would just require
> standard database facilities  ie search,insert,update,remove
> 
> All ideas (desperately) welcome

As a programmer you should sit down with your client or boss during
consultation and say "What are you fucking nuts?".

Any flat file database is going to do some linear style searching. So
as the database grows larger by the day performance rapidly decreases
then soon or later (more sooner than you think) you are faced with
having to upgrade to an actualy database such as mySQL. So why don't
you save yourself time, energy and effort and explain to your client
or boss that for performance, security and reliability reasons an
actual database is a must.

Odds are mySQL is on his machine at your disposal. If not, surely it
can be installed. I just can't believe you considered using flat
files.


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

Date: Thu, 28 Oct 2004 11:25:39 -0400
From: "Xenos" <dont.spam.me@spamhate.com>
Subject: long lines
Message-Id: <clr31s$9sd6@cui1.lmms.lmco.com>

Hi.  Is there a way to continue very long reg. ex. lines on mutliple lines?
I tried using a backslash at the end of line which works in other languages,
but Perl seemed to treat the escaped newline as part of the expression.  I
have some very complex reg. ex. that span many columns that I would like to
break up across multiple lines for readability.  Is there a way to do this?


Thanks,

DrX




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

Date: Thu, 28 Oct 2004 17:44:36 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: long lines
Message-Id: <2ucilpF277iccU2@uni-berlin.de>

Xenos wrote:
> Hi.  Is there a way to continue very long reg. ex. lines on mutliple
> lines? I tried using a backslash at the end of line which works in
> other languages, but Perl seemed to treat the escaped newline as part
> of the expression.  I have some very complex reg. ex. that span many
> columns that I would like to break up across multiple lines for
> readability.  Is there a way to do this?

That's what the /x modifier is for.

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


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

Date: Thu, 28 Oct 2004 18:02:22 GMT
From: "Bradd W. Szonye" <bradd+news@szonye.com>
Subject: Re: perl to english
Message-Id: <slrnco2d1e.rfg.bradd+news@szonye.com>

Tim Hammerquist <tim@vegeta.ath.cx> wrote:
> John Bokma <postmaster@castleamber.com> wrote:
>>  Uhm, isn't Perl not already English enough? 
> 
> You'd think so, but to hear pythonistas tell it, you'd think we were
> programming in Asgard.

I suppose that's better than programming in Goa'uld.
-- 
Bradd W. Szonye
http://www.szonye.com/bradd


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

Date: 28 Oct 2004 07:16:00 -0700
From: roemerman@gmail.com (sroemerm)
Subject: Re: removin \n from only part of a string
Message-Id: <e32a40f9.0410280616.40c8d34f@posting.google.com>

Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message news:<2uai68F28uim5U1@uni-berlin.de>...
> sroemerm wrote:
> > I have a rather large string wiht all kinds of valid \n(s) but I have
> > some that I want to get rid of.
> > 
> > In the following example I want to get rid of only the new lines in
> > between < and >
> > 
> > my $string = "I like this\n but <I dont like\n the\n ones\n in here>"
> > I want the previous string to look like this
> > "I like this\n but <I dont like the ones in here>"
> > 
> > I've tried a couple things but the bottom line is that I'm not good at
> > expression parsing.   please help.
> 
>      $string =~ s/(<[^>]+>)/ ( my $tmp = $1 ) =~ s!\n!!g; $tmp /eg;

That works!  Thanks,  if you have time could you break that down and
explain what is going on?


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

Date: Thu, 28 Oct 2004 10:09:13 -0500
From: Whitey Johnson <whitey@newmail.net>
Subject: Re: removin \n from only part of a string
Message-Id: <pan.2004.10.28.15.09.13.471508@newmail.net>

On Wed, 27 Oct 2004 14:02:30 -0700, sroemerm muttered incoherently:

> I have a rather large string wiht all kinds of valid \n(s) but I have
> some that I want to get rid of.
> 
> In the following example I want to get rid of only the new lines in
> between < and >
> 
> my $string = "I like this\n but <I dont like\n the\n ones\n in here>"
> I want the previous string to look like this
> "I like this\n but <I dont like the ones in here>"
> 
> I've tried a couple things but the bottom line is that I'm not good at
> expression parsing.   please help.

how about this one:
while ($string =~ /<.*\n/) {
        $string =~ s/(<.*)\n/$1/;
}



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

Date: Thu, 28 Oct 2004 10:29:16 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: removin \n from only part of a string
Message-Id: <slrnco242c.tqi.tadmc@magna.augustmail.com>

sroemerm <roemerman@gmail.com> wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message news:<2uai68F28uim5U1@uni-berlin.de>...
>> sroemerm wrote:

>> > I want to get rid of only the new lines in
>> > between < and >


>> 
>>      $string =~ s/(<[^>]+>)/ ( my $tmp = $1 ) =~ s!\n!!g; $tmp /eg;
> 
> That works!  Thanks,  if you have time could you break that down and
> explain what is going on?


Untested, but should be executable same as above:

     $string =~ s/(           # start remembering characters
                     <        # open angle bracket
                     [^>]+    # any chars that are not a closing angle bracket
                     >        # close angle bracket
                  )
                 / ( my $tmp = $1 ) =~ s!\n!!g; # the copy-and-modify idiom
                   $tmp   # evaluated last so this is the code's return value
                 /egx;

The "copy-and-modify idiom" makes a copy and then modifies the copy,
leaving the original intact. Roughly equivalent to:

   my $tmp = $1;
   $tmp =~ s!\n!!g;

(needed here because $1 is read-only, we're not allowed to modify it.)

s///e changes the meaning of the replacement part. It is no longer a
string, now it is Perl code to evaluate. Whatever the code evaluates
to is used as the replacement string.


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


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

Date: Thu, 28 Oct 2004 17:30:21 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: removin \n from only part of a string
Message-Id: <2uchqnF27evp6U1@uni-berlin.de>

sroemerm wrote:
> Gunnar Hjalmarsson wrote:
>> sroemerm wrote:
>>> I want to get rid of only the new lines in between < and >
>> 
>>     $string =~ s/(<[^>]+>)/ ( my $tmp = $1 ) =~ s!\n!!g; $tmp /eg;
> 
> That works!  Thanks,  if you have time could you break that down and
> explain what is going on?

Well, I used the s/// operator, which is explained in "perldoc perlop".
The pattern is replaced with the return value from the expression to the
right.

Try to figure things out yourself by studying the mentioned part of the
docs, and I'll be happy to answer possible *specific* questions you may
have.

One observation I make right now is that it would have been a better
choice to exchange

     s!\n!!g

for

     tr!\n!!d

They do the same thing, but the latter is probably more efficient. (The
tr/// operator is also described in "perldoc perlop", right after s///.)

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


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

Date: Thu, 28 Oct 2004 17:40:17 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: removin \n from only part of a string
Message-Id: <2ucidlF277iccU1@uni-berlin.de>

Whitey Johnson wrote:
> 
> how about this one:
> while ($string =~ /<.*\n/) {
>         $string =~ s/(<.*)\n/$1/;
> }

Fails for the same reason as Tore's solution (and can be fixed in a 
similar way, i.e. using [^>] instead of .).

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


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

Date: Thu, 28 Oct 2004 18:01:36 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Should I use BEGIN, CHECK, or INIT?
Message-Id: <clr8cs$hjr$1@sun3.bham.ac.uk>



Douglas Hunter wrote:

> Peter Hickman wrote:
> 
>> I would not put it in the CHECK block in case there were any side 
>> effects of calling it such as opening database connections, files or 
>> the like. As, I believe, that CHECK is called when you do...
>>
>> perl -c Module.pm
>>
>> where as BEGIN is not.
>>
> 
> dug@slurp:~/scratch$ cat A.pm
> package A;
> 
> BEGIN { warn "begin" }
> CHECK { warn "check" }
> INIT  { warn "init"  }
> END   { warn "end"   }
> 
> 1;

For more complete view of things...

bam@wcl-l:~/tmp> cat A1.pm
package A1;
sub import { warn "import" };
BEGIN { warn "begin" }
CHECK { warn "check" }
INIT  { warn "init"  }
END   { warn "end"   }
warn "body";
1;

bam@wcl-l:~/tmp> cat A2.pm
package A2;
sub import { warn "import" };
BEGIN { warn "begin" }
CHECK { warn "check" }
INIT  { warn "init"  }
END   { warn "end"   }
warn "body";
1;

bam@wcl-l:~/tmp> perl -ce 'use A1; use A1; use A2;'
begin at A1.pm line 3.
body at A1.pm line 7.
import at A1.pm line 2.
import at A1.pm line 2.
begin at A2.pm line 3.
body at A2.pm line 7.
import at A2.pm line 2.
check at A2.pm line 4.
check at A1.pm line 4.
-e syntax OK

bam@wcl-l:~/tmp> perl -e 'use A1; use A1; use A2;'
begin at A1.pm line 3.
body at A1.pm line 7.
import at A1.pm line 2.
import at A1.pm line 2.
begin at A2.pm line 3.
body at A2.pm line 7.
import at A2.pm line 2.
check at A2.pm line 4.
check at A1.pm line 4.
init at A1.pm line 5.
init at A2.pm line 5.
end at A2.pm line 6.
end at A1.pm line 6.

bam@wcl-l:~/tmp> perl -e 'require A1; require A1; require A2;'
begin at A1.pm line 3.
body at A1.pm line 7.
begin at A2.pm line 3.
body at A2.pm line 7.
end at A2.pm line 6.
end at A1.pm line 6.

My view is that initialisaton code that must be run once and once only 
when the module is loaded and which doesn't connect to any external 
resource is best called in the module body unless there's a specific 
reason to put it elsewhere.

>  > I think, can anyone confirm this. I am only on my first cup to tea.
> 
> Whereas I have the luxury of being well into my second cup of coffee 
> {grin}.

And I'm dangerously close to an overdose.



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

Date: Thu, 28 Oct 2004 18:21:05 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Should I use BEGIN, CHECK, or INIT?
Message-Id: <clr9hd$ia4$3@sun3.bham.ac.uk>



Anno Siegel wrote:

> J. Romano <jl_post@hotmail.com> wrote in comp.lang.perl.misc:
> 
>>Greetings,
>>
>>   I have a couple of questions and I would like to know the opinions
>>of the Perl community.
>>
>>   I while ago, I wrote a Perl module which is now practically
>>finished.  Its exact contents aren't important for my questions,
>>except for the fact that it is a package and its functions are called
>>like:
>>
>>   use MyPackage;
>>   MyPackage::init();
>>   MyPackage::f1();
>>   MyPackage::f2($var1, $var2);
> 
> 
> [...]
> 
> 
>>   And my second question:  If it is a good idea to automatically call
>>the init() function for the programmer, should I:
>>
>>   a) put the init() statement in a BEGIN block
>>   b) put the init() statement in a CHECK block
>>   c) put the init() statement in an INIT block
>>   d) put the init() statement as the last statement executed
>>      in the module
>>     or
>>   e) it's not a good idea, so just let the programmer who uses
>>      my module call it in his/her own code
> 
> 
> I have little to add to Tassilo's thorough discussion of the issue,
> except still another alternative:
> 
>      f) rename the init() function as import() (or call it from
>         the import() function)
> 
> That (import()) will be called after the last executable statement
> of your module, but before "use" returns to the caller, so it is
> basically equivalent to d).  The difference is that the user has
> the choice to suppress the call to import() and call it on their
> own.
> 
> 
>>   The only difference I see between BEGIN, CHECK, and INIT (besides
>>the facts that BEGIN statments happen before CHECK statements which
>>happen before INIT statements and that CHECK statements happen in
> 
> 
> Another difference is that BEGIN and CHECK are executed when the
> module in question is loaded.  INIT (and END) are collected and
> not executed before all compile-time activity is done, so if more
> modules are loaded, INIT only runs after that has happened.
> 
> Anno



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

Date: Thu, 28 Oct 2004 18:22:50 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Should I use BEGIN, CHECK, or INIT?
Message-Id: <clr9kl$ia4$4@sun3.bham.ac.uk>



Brian McCauley wrote:

> 
> 
> Anno Siegel wrote:

[snip most of Anno's message ]

>> I have little to add to Tassilo's thorough discussion of the issue,
>> except still another alternative:
>>
>>      f) rename the init() function as import() (or call it from
>>         the import() function)
>>
>> That (import()) will be called after the last executable statement
>> of your module, but before "use" returns to the caller, so it is
>> basically equivalent to d).  The difference is that the user has
>> the choice to suppress the call to import() and call it on their
>> own.

import() is called each time the module use use()d.  It is therefore 
inappropriate for initialisation that should happen once regardless of 
how many times the module is used.



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

Date: 28 Oct 2004 09:57:04 -0700
From: joez3@yahoo.com (joe)
Subject: Re: Verify a url form a perl script
Message-Id: <5619c20c.0410280857.604be7ca@posting.google.com>

Douglas Hunter <dug@plusthree.com> wrote in message news:<clo0or$nkd$0@pita.alt.net>...
> joe wrote:
> > I have been asked to write a perl script that will deploy a web page
> > to one of our servers, I was able to do this. But now I want to be
> > able to make sure that web page comes up and that we can navagate
> > around the pages. Is there some built in functions that will let me do
> > this? Can someone point me in the right direction to get started.
> 
> WWW::Mechanize is available from the CPAN and is very useful for this 
> type of work.
> 
> > Thanks,
> > Zim
> 
> -- Douglas Hunter
I got WWW::Mechanize from CPAN but I can't find a readme for it. So I
am not sure how to install it on my system. I tried the perl
makefile.pl, make, but it failed saying it couldn't find some other
modules. Does anyone have a complete list of what else needs to be
installed so that I can install this?
Thanks,
Zim
zzzz


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

Date: Thu, 28 Oct 2004 18:16:51 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: What are these extra spaces in my registry?
Message-Id: <clr99f$ia4$1@sun3.bham.ac.uk>

A. Sinan Unur wrote:

> joez3@yahoo.com (joe) wrote in 
> news:5619c20c.0410271424.6bc3f80a@posting.google.com:
> 
>>The problem I have is that the registry file looks like there are
>>space between
>>each char in it. So I maybe looking for:
>>LOCAL_MACHINE_SOFTWARE
>>The file contains:
>>L O C C L _ M A C H I N E _ S O F T W A R E

> My gues, under the circumstances, is that there is a 0 byte between each 
> ASCII character because the native character set of Win2K is 16 bits wide 
> (I do not think it is UTF-16, if such a thing exists).

Er, no.  On recent Windows the native character set is Unicode (which is 
wider than 16 bits) and the native encoding is UTF-16.  UTF-16 exists is 
  two flavours BE or LE and I can't recall which Win32 uses but it 
doesn't matter because Perl will autodetect.

>>So my match does not work, also I don't thing the blank spaces are
>>just extra spaces. Because I added spaces to $testValue and it still
>>didn't match. Does anyone have any idea what this extra char is? And
>>how I can get ride of it? 
> 
> 
> I don't think I know _the_ right way of dealing with that.

I know _a_ right way (in Perl 5.8.x where x may need to be >0, I'm not 
sure):

   open my $fh, '<:encoding(utf16)', 'somefile.reg' or die $!;



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

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


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