[22495] in Perl-Users-Digest
Perl-Users Digest, Issue: 4716 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 16 14:05:44 2003
Date: Sun, 16 Mar 2003 11:05:07 -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 Sun, 16 Mar 2003 Volume: 10 Number: 4716
Today's topics:
Re: [Probably] a stupid question about REGEX (Mark Healey)
Re: file parse into hash and writing output with certai <tassilo.parseval@rwth-aachen.de>
Re: FILEHANDLE and search and replace question <mstep@t-online.de>
Re: frames without files ? <s.patterson@freeuk.com>
Function to get key.. (coun)
Re: Function to get key.. <spam@thecouch.homeip.net>
Re: how to create NULL character in perl <xiamen2@hotmail.com>
Re: how to create NULL character in perl (Jay Tilton)
How to obtain screen width and height?? <ebohatch@aeibassoc.com>
Re: How to obtain screen width and height?? <tore@aursand.no>
Re: I want to: include 'right.php' <tore@aursand.no>
Re: it's true but can I say so ? (Anno Siegel)
Like to Discuss Weather?-Come Join! Heres our Newslette <admins@weatherforums.com>
Re: my $x = 100 for 1..3 why is $x undef <bernie@fantasyfarm.com>
Re: my $x = 100 for 1..3 why is $x undef (Anno Siegel)
Out of memory (Ritesh Shah)
Re: Out of memory <noreply@gunnar.cc>
Re: Out of memory <spam@thecouch.homeip.net>
Re: Question: What's the proper way to retrieve last mo <linkseer@yahoo.com>
Re: socket question <goldbb2@earthlink.net>
Re: socket question <tassilo.parseval@rwth-aachen.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Mar 2003 00:32:19 -0600
From: die@spammer.die (Mark Healey)
Subject: Re: [Probably] a stupid question about REGEX
Message-Id: <VP2SpNyJrzMZ-pn2-Xrrsm7dFvPC4@adsl-63-207-135-60.dsl.sndg02.pacbell.net>
On Sun, 16 Mar 2003 04:11:41 UTC, Uri Guttman <uri@stemsystems.com>
wrote:
> >>>>> "MH" == Mark Healey <die@spammer.die> writes:
>
> MH> On Sat, 15 Mar 2003 21:29:51 UTC, Uri Guttman <uri@stemsystems.com>
> MH> wrote:
>
> MH> The problem is that I always get a false. I think it has something to
> MH> do with the way I'm formating the regexp.
>
> MH> When I have $_ in there I think it is being interperated as an end of
> MH> line followed by an underscore.
>
> i still haven't seen any real data with real results and real code that
> is just the regexes. if you are getting false where you don't think you
> should be that is a regex issue. the outer code is meaningless then.
Do you know why? It's because I'm a moron. I urlencoded the search
terms earlier and forgot to undo it for the check.
Thanks for everyones patients.
Dopey me!
------------------------------
Date: 16 Mar 2003 07:48:40 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: file parse into hash and writing output with certain format to new file
Message-Id: <b51a8o$1ej$1@nets3.rz.RWTH-Aachen.DE>
Also sprach david:
> This is what I have now. I have found that running this under 'use
> strict;' and with -w causes errors if I do not define the variables at
> the start of the program. Maybe they dont need to be defined at the
> beginning? Is there something im missing here?
You have to declare your variables in the scope (or block) where you are
using them. A my()ed variable declared in a block exists only for this
block and is automatically destroyed when leaving it.
> One last thing - where I have the print NEWOUT statements, Is it
> possible to define a syntax like:
> print <<MYOUT;
> User= $ser
> Number = $fields[1]
> MYOUT
>
> where I currently have my 'print NEWOUT' statements? I am currently
> getting an error "Cant find stirng terminator "MYOUT" anywhere before
> EOF at test.pl line 20."
Possibly some ill positioned whitespaces or so. The trailing string
terminator of here-docs must not be preceeded nor followed by
whitespaces. That means that your indenting gets screwed, but that might
be tolerable if you have an editor with decent syntax-highlighting. So
you can write:
while (...) {
...
if (...) {
print NEWOUT <<MYOUT;
User = $ser
Number = $fields[1]
MYOUT
}
...
}
There's also a FAQ dealing with here-documents. See
perldoc -q '<<HERE'
> Again, thanks for your help. It has been very useful.
>
> #!/usr/bin/perl -w
> use strict;
>
> my %records;
> my (@ser, @seperate, @fields);
> my $ser;
You still have far too many variables declared here. Both @fields and
$ser are only used within the while-block. Actually, when you declare
these two variables again in this block, you create two new variables
that don't have anything to do with the variables you declared above.
They have the same name but they are still different. Change to:
my (%records, @separate, @ser); # don't know what @ser is for, though
> open (FILE, "<import0.dat") || die "Couldn't open file; $!\n";
> open (OUT, ">output.dat") || die "Couldn't create file; $!\n";
> open (NEWOUT, ">newout.dat") || die "Couldn't create; $!\n";
>
> while ( <FILE> ) {
> my @fields = split ( /,/ );
> if ( $fields[7] =~ m{^\$\$S\/N:(\w+)} ) {
> my $ser = '$$' . $1 . '$$';
> ( $fields[1], $ser ) = ( $ser, $fields[1] );
> push (@seperate, join (',', @fields));
> $records{$ser} = $fields[1];
> print NEWOUT "User = $ser\n";
> print NEWOUT "Number = $fields[1]\n";
> }
>
> }
>
> #while ( ($key,$value ) = each %records ) {
> # print OUT "$key --> $value\n"
> #}
If you decide to activate these lines later, you have to declare $key
and $value. Restrict their scope to the while-block that way:
while (my ($key, $value) = each %records) {
print OUT "$key --> $value\n";
}
> print OUT "@seperate\n";
And now you see why you have to declare %records and @separate before
the while-loop. These two variables have to be accessible both in the
loop and after it. Declare variables in the top-most scope you are going
to use them in.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Sun, 16 Mar 2003 08:26:27 +0100
From: Marek Stepanek <mstep@t-online.de>
Subject: Re: FILEHANDLE and search and replace question
Message-Id: <BA99E5B3.4FEE%mstep@t-online.de>
On 16.03.2003 4:34 Uhr, in article 3E73F0C2.254FDF34@earthlink.net,
"Benjamin Goldberg" <goldbb2@earthlink.net> wrote:
>
> snip
Thank you, having taken pains to answer my newbie provocation. At the
beginning you have many childish questions, where you gurus only laugh at.
In this thread are many valuable hints and tips, which I will follow the
next days. Could somebody have a look to may second question, hope this one
is not a faq too : "Find&Replace only in a certain scope" ...
Thank you again for this great welcome to this group
marek
______________________________________________________________________
___PODIUM_INTERNATIONAL_//_the_embassy_for_talented_young_musicians___
_______Marek_Stepanek__mstep_[at]_PodiumInternational_[dot]_de________
__________________http://www.PodiumInternational.de___________________
______________________________________________________________________
------------------------------
Date: 16 Mar 2003 13:36:12 GMT
From: Stephen Patterson <s.patterson@freeuk.com>
Subject: Re: frames without files ?
Message-Id: <slrnb78ve9.2j9.s.patterson@bloodnok.localdomain>
On 15 Mar 2003 08:40:34 GMT, Stephen Patterson wrote:
> On Fri, 14 Mar 2003 20:56:33 -0500, Mina Naguib wrote:
>>> Now I want to enhance the Perl so that it adds a table of contents
>>> frame. Because of SECURITY I'd rather not write any files.
>>>
>>> When it was just the one page being written back, it was simple, as
>>> I just put in "print" lines in Perl to write HTML code back to the
>>> browser.
>>>
>>> But if I want my Perl to generate a frameset page pointing at two other
>>> pages (the table of contents and the body), is there a way I can do this
>>> without writing auxiliary disk files ?
>
> I've done this once before in pure server-side (perl) CGI, I can't
> remember how though except that it took a lot of working out.
>
> *wanders off to RTFM*
>
> There's a -target option you can pass to each start_html()
> invocation, and in the CGI module docs, there's a whole section on
> working with frames. See perldoc CGI for info.
My brain's just come back, so this is how I worked it out before. I
had a re-entrant cgi script with one sub to generate the framset, each
src for the frameset referring back to the script with different
parameters to invoke each of the frame page generating subroutines,
each using the -target option in start_html() to get the page on the
right frame.
--
Stephen Patterson http://www.lexx.uklinux.net http://patter.mine.nu
steve@SPAM.lexx.uklinux.net remove SPAM to reply
Linux Counter No: 142831 GPG Public key: 252B8B37
Last one down the pub's an MCSE
------------------------------
Date: 16 Mar 2003 08:14:22 -0800
From: francois@coun.fr.st (coun)
Subject: Function to get key..
Message-Id: <73daf06b.0303160814.4e565bd9@posting.google.com>
Hi,
I would like to know how to program in perl a function that wait till
the user press any key (able or not to get the correspondant key)
without showing the letter pressed ?
Thanks
Coun
------------------------------
Date: Sun, 16 Mar 2003 11:39:01 -0500
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: Function to get key..
Message-Id: <FM1da.311$8q2.27656@weber.videotron.net>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
coun wrote:
> Hi,
>
> I would like to know how to program in perl a function that wait till
> the user press any key (able or not to get the correspondant key)
> without showing the letter pressed ?
See perldoc -q password
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE+dKileS99pGMif6wRAmIBAKCRJxdWMI08p6vjveXXb0wmoaJmkQCeK3Hv
s/pMdx/kM+c/VIbBB03U7D0=
=BwgO
-----END PGP SIGNATURE-----
------------------------------
Date: Sun, 16 Mar 2003 20:31:23 +0800
From: "news.pacific.net.sg" <xiamen2@hotmail.com>
Subject: Re: how to create NULL character in perl
Message-Id: <b51qks$opd$1@nobel.pacific.net.sg>
The code doesn't work for me:(
What I'm trying to do , is to generate a null delimited string. Any
suggestion?
Thx, GF
"Jay Tilton" <tiltonj@erols.com> wrote in message
news:3e734943.29368087@news.erols.com...
> "news.pacific.net.sg" <xiamen2@hotmail.com> wrote:
>
> : I'm trying to get a NULL character in perl.
> :
> : my $null = Win32::OLE::Variant->new(VT_NULL,undef);
> :
> : This doesn't work
>
> That works fine for me. Whatever's wrong with it is not obvious.
>
> : and cause me memory error,
>
> What does that mean? Is an error message being generated by perl or
> by the OS?
>
------------------------------
Date: Sun, 16 Mar 2003 15:35:55 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: how to create NULL character in perl
Message-Id: <3e74916d.8512030@news.erols.com>
"news.pacific.net.sg" <xiamen2@hotmail.com> wrote:
: "Jay Tilton" <tiltonj@erols.com> wrote in message
: news:3e734943.29368087@news.erols.com...
: > "news.pacific.net.sg" <xiamen2@hotmail.com> wrote:
: >
: > : I'm trying to get a NULL character in perl.
: > :
: > : my $null = Win32::OLE::Variant->new(VT_NULL,undef);
: > :
: > : This doesn't work
: >
: > That works fine for me. Whatever's wrong with it is not obvious.
: >
: > : and cause me memory error,
: >
: > What does that mean? Is an error message being generated by perl or
: > by the OS?
:
: The code doesn't work for me:(
Yah, you said that already. Repetition is not clarification.
: What I'm trying to do , is to generate a null delimited string.
I think there are conceptual flaws here.
A NULL value under OLE is only useful under OLE, and it's got nothing
to do with string delimiting.
You might mean null-terminated instead of null-delimited.
"\x00" might be what you're looking for in a null character.
Why do you need to do this anyway? It sounds like an XY problem.
: Any suggestion?
1) Read the clpm posting guidelines at
http://mail.augustmail.com/~tadmc/clpmisc.shtml .
The subsections titled "Use an effective followup style" and "Beware
of saying 'doesn't work'" deserve your attention.
2) Explain what "it doesn't work" means. Does perl die with compiler
errors? Runtime errors? Core dump? Does the computer sprout legs
and kick your dog?
3) Explain the underlying problem that you think will be solved by
having a null character. There may be better solutions available.
------------------------------
Date: 16 Mar 2003 12:59:16 -0500
From: Emil <ebohatch@aeibassoc.com>
Subject: How to obtain screen width and height??
Message-Id: <Xns93407B097D63Debohatcheibassoccom@209.242.64.100>
I am suffering from scripters block lately.
I need to have the available screen width and height passed back to my
Perl module.
But I am stumped how to do it, I assume I will need use Javascript??
Any suggestions??
------------------------------
Date: Sun, 16 Mar 2003 20:03:28 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: How to obtain screen width and height??
Message-Id: <pan.2003.03.16.18.57.45.478500@aursand.no>
On Sun, 16 Mar 2003 12:59:16 -0500, Emil wrote:
> But I am stumped how to do it, I assume I will need use Javascript??
Yes. And this is comp.lang.perl.misc.
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Sun, 16 Mar 2003 17:17:59 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: I want to: include 'right.php'
Message-Id: <pan.2003.03.15.17.03.31.515152@aursand.no>
On Sat, 15 Mar 2003 06:03:19 -0800, Francesco Moi wrote:
> I've got some pages made with PHP. On those pages, I repeat
> the same structure, with a menu bar on the right.
Maybe you don't want to solve this specific problem the same way as you
'have to' solve it in PHP?
Let's solve your problem separating code from HTML (ie. presentation)
totally. I would have - for example - used HTML::Template;
#!/usr/bin/perl
#
use strict;
use warnings;
use HTML::Template;
## Create the Template object
my $Template = HTML::Template->new(filename => 'structure.thtml');
## Output
print "Content-type: text/html\n\n";
print $Template->output();
This will actually do, as long as you tell HTML::Template to include the
necessary file(s) in 'structure.thtml';
<html>
<head>
<title><TMPL_VAR NAME=TITLE></title>
</head>
<body>
<table width="100%">
<tr>
<td width="20%"><TMPL_INCLUDE NAME="left.thtml"></td>
<td width="80%"><TMPL_INCLUDE NAME="right.thtml"></td>
</tr>
</table>
</body>
</html>
Or something like this. You can experiment as much as you like, and
perhaps take a look at the other template modules out there (which are
able to include other files).
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: 16 Mar 2003 16:01:18 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: it's true but can I say so ?
Message-Id: <b5274e$ghv$1@mamenchi.zrz.TU-Berlin.DE>
Benjamin Goldberg <goldbb2@earthlink.net> wrote in comp.lang.perl.misc:
> Consider the following code:
>
> BEGIN {
> package Boolean;
> sub new {
> my $class = shift;
> my $self = shift() ? 1 : !1;
> bless \$self, $class;
> }
> sub neg { ref($_[0])->new(!${$_[0]}) }
> sub bool { ${$_[0]} }
> use overload
> (map { $_ => \&neg } qw(! ~ neg)),
> (map { $_ => \&bool } qw(bool +0 "")),
> (map { $_ => eval sprintf q[sub {
> my $other = $_[1] ? 1 : !1;
> ref($_[0])->new( ${$_[0]} %s $other );
> }], $_ } qw(| & ^ == eq != ne)),
> # anything else?
> ;
> }
> use constant true => Boolean->new(1);
> use constant false => Boolean->new(0);
>
> Does anyone see any flaws in this design? The goal of course is to be
> able to write:
> if( $foo == true ) { .... }
> And have it enter the { .... } if $foo is any value perl considers true.
Well, lessee. The crux is comparison by eq and ==, which are
different from boolean equivalence. That is caught by overloading,
and overloading will happen when one of the operands is one of the
constants "true" or "false". Looks solid to me.
Anno
------------------------------
Date: Sun, 16 Mar 2003 07:46:02 GMT
From: "WeatherForums" <admins@weatherforums.com>
Subject: Like to Discuss Weather?-Come Join! Heres our Newsletter for Sunday!
Message-Id: <_YVca.82863$b8.10933606@news4.srv.hcvlny.cv.net>
<center><font size="5"><a href="http://www.weatherforums.com">WeatherForums</a><br>
<br><font size="5">Come Join and Discuss weather with us!!</font>
<br>
Newsletter For Sunday, March 16 2003<br>
</font><font size="3"></center>
<br>
<b>
....Cool High Pressure dominates New England Sunday...<br>
After coolish morning lows in the 20's and 30's for most of the NorthEast the area will rise into the 40's and 50's under fair skies. With easterly winds, coastal sections of Massachusetts will only see highs near 40. Interior locations, as well as much of the northern mid-atlantic should rise to near or above 50. Partly cloudy Conditions should prevail overnight. This should be.....
<center>
<font size="4" color="red"> To View the rest of this newsletter-please subscribe to it at weatherforums.com!!-->Better yet-become a member!-we have a very nice range of PROFESSIONAL,and novice meteorolgists!!</center></font>
--
Posted by News Bulk Poster
Unregistered version
------------------------------
Date: Sun, 16 Mar 2003 07:37:12 -0500
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: my $x = 100 for 1..3 why is $x undef
Message-Id: <9C27FD43C334D18B.58F3B0171233AAC9.A5CB005FAE51AD2B@lp.airnews.net>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
} Bernie Cosell <bernie@fantasyfarm.com> wrote in comp.lang.perl.misc:
} > Abigail <abigail@abigail.nl> wrote:
} > I thought that was pretty cool [especially since it is a mile cleaner and
} > simpler (at least from the outside..:o)) than the 'official' way of getting
} > a local-static-variable]...
}
} What do you consider the "official" way of creating a static variable?
}
} Since we have closures, we can declare a lexical outside the sub and use
} it inside. To make it private, enclose the whole thing in a bare block.
} So the standard implementation would be
}
} {
} my $x = 0;
} sub a {
} print "\$x is $x\n";
} $x = shift;
} }
} }
} a( $_) for 1 .. 3;
}
} If it matters that $x is only set at run time, prefix the block with
} "BEGIN".
}
} How much cleaner can it get get?
How about foregoing all the extra braces and the need for BEGIN [which
could conflict with other things] and do as other languages allow:
sub a
{ static $x = 4 ;
print "\$x is $x\n";
$x = shift ;
}
note that the *intent* of the construct is perfectly clear, whereas
'closures' are *hardly* the most common or intuitive feature of Perl [NB:
don't argue with *ME* about them: I understand and use closures all the
time... it is just that for a simple static variable, a semantic concept
that other languages have and seems simple and intuitive, why not just
*HAVE* such at thing, especially since if you used the C preprocessor
stuff, yo could define "define static x my x if 0" or something like that
and it'd almost work..
} I think the closure solution is far superior. It extends trivially to
} more than one routine sharing a set of variables. This makes the whole
} construct something like a classless anonymous object, if an object is
} a set of data together with a set of routines that operate on the data.
Well, people's MMV on this. "static variables" are common, simple and
useful constructs. Closures are more complicated and less clear [since
they can be used for other things and with other intentions, other than
*just* providing a simple static variable].
As for your comment about "Perl already has too many operators" -- that
doesn't seem to slow down *adding* things... it only serves as a convenient
"wave of the hand" dismissal -- a somewhat highhanded way to even as Perl
continues to add more stuff... If the argument was "don't add anything new
to perl that is something that can be done some other way", well: why
bother having added 'for' as a statement modifier? and a dozen/score/more
other similar things... I think that 'new features' should be discussed on
their merits, rather than just dismissed because "perl already has too many
features"...
/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
bernie@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
------------------------------
Date: 16 Mar 2003 15:14:31 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: my $x = 100 for 1..3 why is $x undef
Message-Id: <b524cn$fu6$1@mamenchi.zrz.TU-Berlin.DE>
Bernie Cosell <bernie@fantasyfarm.com> wrote in comp.lang.perl.misc:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
>
> } Bernie Cosell <bernie@fantasyfarm.com> wrote in comp.lang.perl.misc:
> } > Abigail <abigail@abigail.nl> wrote:
>
> } > I thought that was pretty cool [especially since it is a mile cleaner and
> } > simpler (at least from the outside..:o)) than the 'official' way of getting
> } > a local-static-variable]...
> }
> } What do you consider the "official" way of creating a static variable?
> }
> } Since we have closures, we can declare a lexical outside the sub and use
> } it inside. To make it private, enclose the whole thing in a bare block.
> } So the standard implementation would be
> }
> } {
> } my $x = 0;
> } sub a {
> } print "\$x is $x\n";
> } $x = shift;
> } }
> } }
> } a( $_) for 1 .. 3;
> }
> } If it matters that $x is only set at run time, prefix the block with
> } "BEGIN".
> }
> } How much cleaner can it get get?
>
> How about foregoing all the extra braces and the need for BEGIN [which
> could conflict with other things] and do as other languages allow:
> sub a
> { static $x = 4 ;
> print "\$x is $x\n";
> $x = shift ;
> }
> note that the *intent* of the construct is perfectly clear, whereas
> 'closures' are *hardly* the most common or intuitive feature of Perl [NB:
> don't argue with *ME* about them: I understand and use closures all the
> time...
The method is: To make a variable survive sub calls, declare it outside
of the sub, but use it within. That is a straight application of Perl's
scoping rules. Your sub technically becomes a closure, but you don't
have to know that to apply the method.
Closures are only difficult when you generate them at run time.
> it is just that for a simple static variable, a semantic concept
> that other languages have and seems simple and intuitive, why not just
> *HAVE* such at thing, especially since if you used the C preprocessor
> stuff, yo could define "define static x my x if 0" or something like that
> and it'd almost work..
Just because it's easy to implement is not a good reason to implement it.
This figures large in the aethiology and prophylaxis of feeping creaturism.
> } I think the closure solution is far superior. It extends trivially to
> } more than one routine sharing a set of variables. This makes the whole
> } construct something like a classless anonymous object, if an object is
> } a set of data together with a set of routines that operate on the data.
>
> Well, people's MMV on this. "static variables" are common, simple and
> useful constructs. Closures are more complicated and less clear [since
> they can be used for other things and with other intentions, other than
> *just* providing a simple static variable].
As I said, closures don't really enter the picture. Just scoping.
> As for your comment about "Perl already has too many operators" -- that
That was not my what I said. Perl has too many declaration-like operators
which already interact in ways that are hard to keep straight: my, our,
local, use vars, use strict... any more?
> doesn't seem to slow down *adding* things... it only serves as a convenient
> "wave of the hand" dismissal -- a somewhat highhanded way to even as Perl
> continues to add more stuff... If the argument was "don't add anything new
> to perl that is something that can be done some other way", well: why
> bother having added 'for' as a statement modifier? and a dozen/score/more
> other similar things... I think that 'new features' should be discussed on
> their merits, rather than just dismissed because "perl already has too many
> features"...
I'm not against adding features, I'm against adding features lightly in an
area that is already messy. If the issue about the behavior of "my" under
statement modifiers can be resolved in general, we could talk about
replacing the (legal, but obscure) idiom "my $x if 0" with the equivalent
"static $x".
If it can't be resolved, I'm for leaving things as is.
Anno
------------------------------
Date: 16 Mar 2003 03:10:31 -0800
From: ritesh_shah2000@yahoo.com (Ritesh Shah)
Subject: Out of memory
Message-Id: <243164f.0303160310.4dd834ae@posting.google.com>
Hi,
I have 1GB RAM on my computer. When I try to parse a file of size
more than 1GB with my perl script I get "Out of memory" message. Is
there a way to get around the problem without adding extra hardware?
Thanks in advance,
Ritesh
------------------------------
Date: Sun, 16 Mar 2003 12:13:56 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Out of memory
Message-Id: <b51mng$247nsm$1@ID-184292.news.dfncis.de>
Ritesh Shah wrote:
> I have 1GB RAM on my computer. When I try to parse a file of size
> more than 1GB with my perl script I get "Out of memory" message. Is
> there a way to get around the problem without adding extra hardware?
By using a 'while' loop like this:
open FH, 'myfile';
while (<FH>) {
# parse code
}
close FH;
and thus examining one line at a time, I think you prevent the whole
file contents from being loaded into the memory.
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sun, 16 Mar 2003 11:22:30 -0500
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: Out of memory
Message-Id: <dx1da.263$8q2.26218@weber.videotron.net>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Ritesh Shah wrote:
> Hi,
> I have 1GB RAM on my computer. When I try to parse a file of size
> more than 1GB with my perl script I get "Out of memory" message. Is
> there a way to get around the problem without adding extra hardware?
Yes, by not reading the entire file into memory at the same time.
Parse the file in smaller chunks, such as every line, every kilobyte etc...
If it is a *must* to have the entire file in memory, increase your swap
file/partition size.
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE+dKTJeS99pGMif6wRAh0NAKCghXznEFjfMwzMQ4XEbxWvFqhK/gCfSGc0
enXXTgbu/C3hYo5eW2VxLQM=
=LasP
-----END PGP SIGNATURE-----
------------------------------
Date: Sun, 16 Mar 2003 07:28:50 GMT
From: LinkSeer <linkseer@yahoo.com>
Subject: Re: Question: What's the proper way to retrieve last mod dates for all files in a directory?
Message-Id: <sp987vgiscubb6ukvt6uu85l3ip22b7ib6@4ax.com>
On Sat, 15 Mar 2003 16:26:18 -0600, Tony Curtis
<tony_curtis32@yahoo.com> wrote:
>>> On Sat, 15 Mar 2003 22:22:59 GMT,
>>> LinkSeer <linkseer@yahoo.com> said:
>
>> If I use something like: opendir(html,
>> 'e:/inetpub/wwwroot/cgi-bin/listings') or die "can't
>> opendir directory: $!"; @dirlist = readdir(html);
>> foreach $f(@dirlist){ if(-f $f){ ($sec, $min, $hour,
>> $mday, $mon, $year, $wday, $yday, $isdst) =
>> localtime((stat($f))[9]);
>
>> When the path points to the directory where the script
>> is located all is well, I get a list of all files and
>> their last modification date/time but if the path is
>
>readdir() returns the *name* of the files in the
>directory. It doesn't mean that the *path* to the file
>with that name is equal to the name. You will need to
>prefix the path to the name in order to perform operations
>on the file. Or chdir() there first (which is the same
>thing, really).
>
>hth
>t
Thanks Tony, that did the trick.
------------------------------
Date: Sun, 16 Mar 2003 02:59:09 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: socket question
Message-Id: <3E742ECD.BD53B04D@earthlink.net>
smackdab wrote:
>
> Hi,
>
> I am creating a non-blocking io::socket to talk to a remote server,
> which I got working ;-)
> Now, I need to create a listen socket in my program and accept a
> connection myself.
>
> Can I reuse the io::select I already created for the listen socket or
> should I create a new one?
What happened when you tried?
> Hope this question makes sense ;-)
>
> thanks!
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: 16 Mar 2003 07:57:27 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: socket question
Message-Id: <b51ap7$1qb$1@nets3.rz.RWTH-Aachen.DE>
Also sprach smackdab:
> I am creating a non-blocking io::socket to talk to a remote server, which I
> got working ;-)
> Now, I need to create a listen socket in my program and accept a connection
> myself.
>
> Can I reuse the io::select I already created for the listen socket or should
> I create a new one?
It depends. IO::Select (or simply select()) are often used in
tight-loops where you check which of your handles (sockets) are ready to
send or receive data. Now if both of your sockets need to be handled in
the same place of your program, then stuff them all into one IO::Select
object.
Since your program should probably be non-blocking I guess you want your
sockets all handled by one select object. Your question is not so much a
technical one but rather about the logic of your program so we can't
give definite answers.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 4716
***************************************