[29275] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 519 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 15 14:11:08 2007

Date: Fri, 15 Jun 2007 11:09:17 -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           Fri, 15 Jun 2007     Volume: 11 Number: 519

Today's topics:
    Re: Best error handling mechanism? <bik.mido@tiscalinet.it>
    Re: Depending on perl version <purlgurl@purlgurl.net>
        I think I want to use of mmap and perlio <Mark.Seger@hp.com>
    Re: I think I want to use of mmap and perlio <Mark.Seger@hp.com>
    Re: Massive Memory Structures  ruu@cwcom.net
    Re: Need help reading two-dimentional array from a file <baxter.brad@gmail.com>
    Re: Passing literal with reference? <peter@makholm.net>
    Re: Perl Bug???  krakle@visto.com
    Re: Perl Bug??? <bart.lateur@pandora.be>
    Re: perl vs C for CGI <hjp-usenet2@hjp.at>
    Re: regex question <abigail@abigail.be>
    Re: Strange results of "global match". xhoster@gmail.com
        Survey and article on why people contribute to document <andyo@oreilly.com>
    Re: urgent:reading 2 files into 2 different $ variables <anton.vandersteen@chello.nl>
    Re: Which Perl 5 OO extension can be seen as "standard" <jgibson@mail.arc.nasa.gov>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 15 Jun 2007 18:11:20 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Best error handling mechanism?
Message-Id: <c4e573943j7apejgrtlk74p7cn2mp9dmfk@4ax.com>

On Mon, 4 Jun 2007 20:13:12 -0500, Rob Hoelz <hoelz@wisc.edu> wrote:

>clear conclusion yet:  What form of error handling is best in Perl?

The best way is not to make errors at all. Corporate policies should
always include a clause to that effect.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Fri, 15 Jun 2007 06:37:11 -0700
From: Purl Gurl <purlgurl@purlgurl.net>
Subject: Re: Depending on perl version
Message-Id: <jICdncdPy4eWC-_bnZ2dnUVZ_tCtnZ2d@giganews.com>

anno4000 wrote:

> Purl Gurl wrote:

> [...]

>> Interesting a lib path will display in printing @INC but is not valid
>> for a "use" statement unless wrapped in a BEGIN {} block.

> That's easy to explain.  "use()" happens at compile time while an
> unadorned "push @INC, 'something'" happens later, at run time.  So
> "use" doesn't see the effect of "push ...", even if "push ..." appears
> in the file before "use".  Wrapping a "BEGIN" block around "push ..."
> forces it to happen at compile time (that's the meaning of "BEGIN"),
> thus it's in time for "use".

> Printing "@INC" also happens at run time (unless you wrap it in
> a BEGIN block too, try it), so the effect of "push ..." will be
> visible.

Yes, this one boogered my mind for a period of time.

I know better than to discount what Joe writes without first
exhaustive testing to either prove or disprove his statement.

Having my test module within the same directory from which I
was executing my test script, guaranteed my module would work
with a use statement; no need to add this directory path.
In short, I was adding a directory path already included
in perl core dot " . " element in @INC at compile time.
I assumed the " . " inclusion to be simply a reference to
the executed script location, $0 , rather than a use lib
path inclusion, as well.

My presumption is perl core loads into memory a set of "use"
variables, perhaps just like environment variables, which are
invisible as "use" variables unless specifically printed by
some method, other than printing @INC as I did.

Those path variables are visible in printing @INC but are not
the same "lib usage" variables loaded into memory. This print
display of lib paths in @INC although not actual "use" lib
paths is odd. Not so much a bug but rather odd behavior; I
expect the printed @INC elements to also be "use" elements.

-- 
Purl Gurl
--
"Then again what can you expect from a fat-assed, champagne swilling,
  half-breed just off the Rez?"
   - Joe Kline


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

Date: Fri, 15 Jun 2007 10:33:36 -0400
From: Mark Seger <Mark.Seger@hp.com>
Subject: I think I want to use of mmap and perlio
Message-Id: <f4u807$ele$1@usenet01.boi.hp.com>

I'm trying to find an easy way to hog a large chunk of memory, about 
4GB, thereby reducing the amount available to the rest of the system for 
caches.  I know I could do this by physically removing some dimms, but 
the machine is too far away!  8-)

Anyhow I thought a nifty way to do this might be by using the mmap 
perlio layer.  I first created a large file by specifying:

open FILE, '>:mmap', '/tmp/mmap.dat' or die;

and wrote a 1GB worth of data to it.  Then I opened it with:

open FILE, '<:mmap', '/tmp/mmap.dat' or die;

and did $record=<FILE> and sure enough, my mmap'd memory in 
/proc/meminfo went up.  However, as soon as the read finished the memory 
was released and I want to hang onto it.  Then I just tried playing 
around with sysread on the file handle but not matter what I specified 
for record size or offset it always read 7 bytes.  Clearly I don't 
understand the semantics of how this works and couldn't get any more 
details in the documentation.

So the question is, it is possible to open my mmap file, perform some 
operation on it and hold onto the memory?  My intent would then be to do 
a long sleep.

In addition to trying to figure out how mmap works because it does seem 
to be useful, I also wonder if anyone can suggest a better way to grab 
some memory and if not, so be it.

-mark


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

Date: Fri, 15 Jun 2007 12:12:31 -0400
From: Mark Seger <Mark.Seger@hp.com>
To: Mark Seger <Mark.Seger@hp.com>
Subject: Re: I think I want to use of mmap and perlio
Message-Id: <4672BA6F.7040906@hp.com>

> In addition to trying to figure out how mmap works because it does seem 
> to be useful, I also wonder if anyone can suggest a better way to grab 
> some memory and if not, so be it.

If anyone cares, all I had to do was append mem=4g to the kernel line in 
my boot loader.   duh!
-mark



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

Date: Fri, 15 Jun 2007 11:09:05 -0700
From:  ruu@cwcom.net
Subject: Re: Massive Memory Structures
Message-Id: <1181930945.169202.130560@g4g2000hsf.googlegroups.com>

No-one knows?  Not even a "if you have to use more than 4G of memory,
you don't know what you are doing" reply?

Dave



On Jun 13, 4:44 pm, r...@cwcom.net wrote:
> OK - I was under the impression that perl running on a 64 bit OS,
> compiled for said 64 bit OS would be able to handle data structures in
> memory greater than 4G in size.  I've tried this with a couple of OS's
> (Solaris on sparc, Solaris on x86_64) with both packaged and compiled
> versions of perl with identical results - as soon as I hit 4G with my
> script, I get an out of memory error and the script dies.
>
> I'm pretty sure I don't have a ulimit issue, since more or less
> everything is unlimited, and other programs run by the same user can
> access over 4G of ram quite happily.
>
> Two questions:
>
> 1) Is it possible to access a structure over 4G with perl running on
> Solaris?
> 2) If so, what options do I need to compile in to make this happen.
>
> Dave




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

Date: Fri, 15 Jun 2007 13:17:56 -0000
From:  Brad Baxter <baxter.brad@gmail.com>
Subject: Re: Need help reading two-dimentional array from a file
Message-Id: <1181913476.363255.264290@w5g2000hsg.googlegroups.com>

On Jun 14, 3:00 pm, Paul Lalli <mri...@gmail.com> wrote:
> On Jun 14, 2:39 pm, DanchikPU <danc...@gmail.com> wrote:
> > I am attempting to read in two-dimentional array from a file,
> > but my data is being treated as a flat array.
>
> > The data file looks something like this:
>
> > (['abcd','qwerty','L','1234'],
> > ['abce','qwerty','L','1234'],
> > ['abcf','qwerty','L','1234'],
> > ['abcg','qwerty','L','1234']);
>
> > In the code, I am doing to standart
>
> >          open(DATA, "foo.txt")
> >          @foo=<DATA>
> >          close(DATA);
>
[snip]
> 2)
> #!/usr/bin/perl
> use strict;
> use warnings;
> my @foo = eval do { local $/; <DATA>} ;

And, for completeness:

use strict;
use warnings;
my @foo = do "foo.txt";

> Please take EXTREME CAUTION with method #2.  If you're not 100% sure
> you know exactly what the contents of that file are, you're opening
> yourself up to a massive security hole.  That method will execute ANY
> perl code found in the file.  Including code that might contain, for
> example:
> system("rm -rf /");

Same caveat applies.

--
Brad



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

Date: Fri, 15 Jun 2007 13:15:04 +0000
From: Peter Makholm <peter@makholm.net>
Subject: Re: Passing literal with reference?
Message-Id: <87odjh5pgn.fsf@makholm.net>

Mirco Wahab <wahab-mail@gmx.net> writes:

> What if the "scalar" is, say 316,21 MB in size?
> Would you still send it down to subroutines 'as it is'?

Yes, I think so.

From 'perldoc perlsub':

   Any arguments passed in show up in the array @_.  Therefore, if you
   called a function with two arguments, those would be stored in $_[0]
   and $_[1].  The array @_ is a local array, but its elements are aliases
   for the actual scalar parameters.  In particular, if an element $_[0]
   is updated, the corresponding argument is updated (or an error occurs
   if it is not updatable).

So Perl actually uses call-by-reference already. Of course the
standard idioms copies the values to new variables. 

//Makholm



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

Date: Fri, 15 Jun 2007 08:15:21 -0700
From:  krakle@visto.com
Subject: Re: Perl Bug???
Message-Id: <1181920521.765573.129920@m36g2000hse.googlegroups.com>

On Jun 15, 7:32 am, Paul Lalli <mri...@gmail.com> wrote:
> On Jun 15, 3:38 am, kra...@visto.com wrote:
>
>
>
>
>
> > On Jun 14, 3:45 pm, Paul Lalli <mri...@gmail.com> wrote:
> > > On Jun 14, 4:21 pm, kra...@visto.com wrote:
> > > > On Jun 13, 2:11 pm, Paul Lalli <mri...@gmail.com> wrote:
> > > > > Whenever you find yourself wanting to type something
> > > > > like that, you should really count to 10 and ask
> > > > > yourself what's more likely - that there's a new and
> > > > > undiscovered bug in the language that's been used
> > > > > worldwide for 20 years that you just happened to find,
> > > > > or that you either did something wrong or don't
> > > > > understand the results you're seeing.
>
> > > > There's bugs in every Perl release. Your message implies
> > > > that the language hasn't changed or evolved since 1987.
> > > I implied nothing of the sort.  Read my message again.
>
> > Maybe you should.
> > "that there's a new and undiscovered bug in the language that's
> > been used worldwide for 20 years that you just happened to
> > find". The same version hasn't been used worldwide for 20
> > years. So obviously it's VERY possible to stumble upon NEW bugs
> > that didn't even exist before the previous release (with in a
> > year).
>
> POSSIBLE, yes.  LIKELY, for a newbie to Perl?  No.
>
> > > > A better point is... it's less than likely that someone who
> > > > isn't Perl savvy enough to 'use strict' will find a bug
> > > > with the language.
>
> > > That is exactly what my message said.  Read my message again.
> > Maybe you should read it. You didn't write that buddy.
>
> Are you dense or just a troll?  I honestly can't tell.

By your lack of manners I'm just going to assume you have poor social
skills.

>  I asked
> whether it's more likely that there's a new bug THAT THE OP JUST
> HAPPENED TO FIND or that the OP made a mistake.  I did not ANYWHERE
> say it was unlikely there was a bug in Perl.

By your 20 year example you imply (perhaps not intentionally) that
it's unlikely to find a bug in Perl because it's been around for 20
years. I only pointed out there has been several releases with in that
time span all having their own bugs unique to the previous versions...
It's an evolving languaging.. Bugs are expected Paul.

>
> Regardless, I'm done with you.  You're not worth any further wastes of
> my time.
>

Perhaps lack of Social Skills AND Manners. I'm just going to HOPE you
are young and in time your moody attitude will improve.



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

Date: Fri, 15 Jun 2007 17:25:00 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Perl Bug???
Message-Id: <5ni573lu2aaqkr77i2qfu35jo55idsmtn5@4ax.com>

Paul Lalli wrote:

>> So obviously it's VERY possible to stumble upon NEW bugs
>> that didn't even exist before the previous release (with in a
>> year).
>
>POSSIBLE, yes.  LIKELY, for a newbie to Perl?  No.

Uh, why not?

Whenever my 2 year old is at the keyboard of my computer, he almost
immediately succeeds in making it do stuff I didn't know it could do
(like putting my computer in standby mode), just by hitting a few
unexpected keys.

Newbies are *very likely* to find bugs old users never stumble upon,
just because they do things old user never would do.

-- 
	Bart.


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

Date: Fri, 15 Jun 2007 15:18:47 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: perl vs C for CGI
Message-Id: <slrnf754dn.v0s.hjp-usenet2@zeno.hjp.at>

On 2007-06-14 17:11, Michele Dondi <bik.mido@tiscalinet.it> wrote:
> On Wed, 13 Jun 2007 14:35:50 +0200, "Peter J. Holzer"
><hjp-usenet2@hjp.at> wrote:
>>If you don't convert the *script* (as opposed to print statements within
>>the script), apache probably can't even start the script because the
>>linux kernel will try to invoke "/usr/bin/perl\r" which doesn't exist.
>
> BTW: I've always wondered... how 'bout HERE docs? Are they portable
> across platforms or is the line ending deemed to be that of the
> script.

To my surprise they are portable at least between Unix and Windows. Perl
seems to automatically detect the line endings and convert them to
\x{0A} at compile time. A string written as a here document always
contains simple "\n" characters as line endings regardless of whether
the source file contained CRLFs or LF and whether it's executed on
Windows or Unix.

	hp

-- 
   _  | Peter J. Holzer    | I know I'd be respectful of a pirate 
|_|_) | Sysadmin WSR       | with an emu on his shoulder.
| |   | hjp@hjp.at         |
__/   | http://www.hjp.at/ |	-- Sam in "Freefall"


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

Date: 15 Jun 2007 13:28:36 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: regex question
Message-Id: <slrnf754u2.9b1.abigail@alexandra.abigail.be>

                                              _
Tad McClellan (tadmc@seesig.invalid) wrote on VXXXVI September MCMXCIII
in <URL:news:slrnf73t5f.1p3.tadmc@tadmc30.sbcglobal.net>:
""  a <a@mail.com> wrote:
""  
"" > str = c:/dir0/dir1/file.txt
"" > str =~ /c:\/(.*)/
""  
""  
""  Scalar variables in Perl start with a dollar character.

Yeah, but he might have:

    sub str:lvalue {$str}

and then he only needs to fix the quoting and semi-colon issues. ;-)



Abigail
-- 
A perl rose:  perl -e '@}>-`-,-`-%-'


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

Date: 15 Jun 2007 16:03:00 GMT
From: xhoster@gmail.com
Subject: Re: Strange results of "global match".
Message-Id: <20070615120304.333$7e@newsreader.com>

Krivenok Dmitry <krivenok.dmitry@gmail.com> wrote:
> Hello guys!
>
> Can anyone explain me the following results:

perldoc perlop can:

               In scalar context, each execution of "m//g" finds
               the next match, returning true if it matches, and
               false if there is no further match.  The position
               after the last match can be read or set using the
               pos() function; see "pos" in perlfunc.   A failed
               match normally resets the search position to the
               beginning of the string, but you can avoid that by
               adding the "/c" modifier

Xho

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


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

Date: Fri, 15 Jun 2007 07:08:10 -0700
From:  andyo <andyo@oreilly.com>
Subject: Survey and article on why people contribute to documentation
Message-Id: <1181916490.214693.110550@i13g2000prf.googlegroups.com>

Several months ago I asked people on this group to answer a survey
about why they contribute to the list and to other free documentation.
Your response seems to have been strong, because a lot of respondents
mentioned Perl. This really helped the survey--thanks. I hope you
enjoy reading my analysis of the survey:

http://www.onlamp.com/pub/a/onlamp/2007/06/14/why-do-people-write-free-document\ation-results-of-a-survey.html

I'm also interested in comments.



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

Date: Fri, 15 Jun 2007 10:35:40 -0700
From:  "anton.vandersteen@chello.nl" <anton.vandersteen@chello.nl>
Subject: Re: urgent:reading 2 files into 2 different $ variables
Message-Id: <1181928940.040233.78480@n2g2000hse.googlegroups.com>

On Jun 15, 12:03 am, "Mumia W." <paduille.4061.mumia.w
+nos...@earthlink.net> wrote:
> On 06/04/2007 12:00 PM, geot wrote:
>
> > hi Bob
>
> > thank you vey much for the information, pls do  excuse me for not
> > giving more details.
> > i will try to explain more clearly. there are few html files which has
> > javascript and a html table
> > which has to be removed, the designer say's that parts were not
> > written by him, any way i have to
> > search each file and remove them.
> > [...]
>
> Try to keep better control of your webserver :-)
>
> This should help remove some of the rouge elements:
>
>      use strict;
>      use warnings;
>      use File::Slurp;
>      use File::Find;
>
>      my $jscript = read_file('data/jscript.txt');
>      my $table = read_file('data/table.txt');
>
>      my @htfiles;
>      my $wanted = sub {
>          no warnings 'once';
>          if (/(\.html?|\.cfm)$/i) {
>              push @htfiles, $File::Find::name;
>          }
>      };
>      find($wanted, 'data');
>
>      foreach my $file (@htfiles) {
>          my $changed = 0;
>          my $html = read_file($file);
>          $html =~ s/\Q$jscript\E// && $changed++;
>          $html =~ s/\Q$table\E// && $changed++;
>          if ($changed) {
>              write_file("$file.2", $html);
>              print "Wrote changed file: $file.2\n";
>          }
>      }

Hello,

You should use Tie::File

A complete file is put in an array.

With the following link you can find more information:
http://perldoc.perl.org/Tie/File.html

Have fun



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

Date: Fri, 15 Jun 2007 09:56:33 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Which Perl 5 OO extension can be seen as "standard" (defacto, quasi)?
Message-Id: <150620070956332677%jgibson@mail.arc.nasa.gov>

In article <1181910002.327137.71560@q66g2000hsg.googlegroups.com>,
Ilias Lazaridis <ilias@lazaridis.com> wrote:

> I like the very fundamental OO support of Perl 5.

OO support was added in Perl 5. It didn't exist in Perl 4. That is not
my definition of "fundamental". Perhaps you mean "primitive" :)

> 
> constructs like "separated data/method inheritance", AUTOLOAD, give me
> the freedom to implement things as I like: very generic, general and
> dynamic.
> 
> But as I don't like to "develope away from standard ways to do
> things", I've tried to find out which is the OO extension to use with
> perl 5.

You don't need an "OO extension" to do OO programming in Perl. It is
now built into the language.

> 
> I've found this very compact one:
> 
> http://www.netalive.org/swsu/archives/2004/09/reformed_perl_t.html
> 
> but have immediately the problem that "self" is used instead of
> "$self" and that it seems that the code adds overhead at execution
> time.
> 
> Then I've seen Perl6::Bundle which bring Perl 6 stuff to Perl 5
> 
> http://www.linux-magazine.com/issue/49/Perl_6_Preview.pdf
> 
> but I don't know two things:
> 
>  * how stable are those implementations?

The reform.pm module looks very stable. It was uploaded to CPAN in Sep,
2004 and not updated since.

>  * how many perl developer do actually use them?

Can't tell you. I don't.

>  * can I pick just the OO stuff out of the bundle, or are ther
> dependencies?

There are 27 modules in the Bundle::Perl6. You can try installing
individual modules and see if they work.

>  * Is there any document which suggests which modules to use for new
> projects?

Everybody has their own favorites. Usenet groups comp.lang.perl.misc
and comp.lang.perl.modules are good places to get opinions on a
particular Perl module. We could use a good rating system for CPAN
modules.

> 
> Any suggestions / comments are welcome.

I think using any extensions to the language is generally a mistake
unless you really know what you are doing. You are dependent upon the
module writer, and many modules on CPAN do not have a pedigree. Obscure
modules do not get the tempering of wide-spread use and the resulting
bug fixes that the basic language and popular modules get. You are also
learning to use a language that is not quite Perl. If the module
changes or doesn't get updated, you can find yourself trapped with
obsolete technology.

My suggestion is to stick with the basic Perl OO constructs while
learning the language. Once you are experienced, you may find a module
that makes expressing yourself easier. However, it is important to have
a good feel for what is going on underneath before you do that.

See 'perldoc perlboot' for a Perl OO tutorial.

-- 
Jim Gibson

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.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 519
**************************************


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