[23452] in Perl-Users-Digest
Perl-Users Digest, Issue: 5667 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 16 00:05:53 2003
Date: Wed, 15 Oct 2003 21:05:06 -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 Wed, 15 Oct 2003 Volume: 10 Number: 5667
Today's topics:
Re: add text to next line? <geoff.cox@blueyonder.co.uk>
Re: add text to next line? <geoff.cox@blueyonder.co.uk>
Re: Converting indented data to a tree (Jay Tilton)
Re: Converting indented data to a tree <tore@aursand.no>
Re: Getting part of a number <tore@aursand.no>
Re: How can i write the values of a form through a cgi <tore@aursand.no>
Re: How Do I Use Proxy in Net:HTTP? <gisle@activestate.com>
Re: How does one move down a line in a file? <no@spam.here>
Re: How does one move down a line in a file? (James Willmore)
Re: How to update entries in a file <no@spam.here>
Re: Is flock Needed for Logs? (Malcolm Dew-Jones)
Re: Is flock Needed for Logs? <ir@labranche.com>
Re: Is flock Needed for Logs? <ir@labranche.com>
Re: mod_perl and 5.8.1 <rgarciasuarez@free.fr>
Re: Perl scripts for Unix on my windows machine (James Willmore)
Re: Perl scripts for Unix on my windows machine (Ren Patterson)
Re: Threads and OO Question (Bill)
Re: Unexpected alteration of array's content (Anno Siegel)
Re: Unexpected alteration of array's content <uri@stemsystems.com>
Re: Why Is My Hash Assignment Taking So Long? <nospam_for_jkeen@concentric.net>
Re: Why Is My Hash Assignment Taking So Long? (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 15 Oct 2003 22:47:42 GMT
From: Geoff Cox <geoff.cox@blueyonder.co.uk>
Subject: Re: add text to next line?
Message-Id: <0jjrov4c8mt6bibjnlv4snunetv53tpof5@4ax.com>
On Wed, 15 Oct 2003 16:10:09 +0100, Peter Hickman
<peter@semantico.com> wrote:
>What you prehaps should be looking at is CSS, you can have one stylesheet for
>screen display and another for printing. The use just has to select that they
>wish to print the page and the printing stylesheet will be used.
Peter,
that sounds interesting ... how does yser select the print style
sheet?
Cheers
Geoff
------------------------------
Date: Wed, 15 Oct 2003 23:07:45 GMT
From: Geoff Cox <geoff.cox@blueyonder.co.uk>
Subject: Re: add text to next line?
Message-Id: <clkrovc7b8n29scqrovclslbl25gsu7k0n@4ax.com>
On 15 Oct 2003 10:15:35 -0700, rjohnson@shell.com (Roy Johnson) wrote:
>Sorry, I answered the question you posted there, but not the question
>you started this thread about. To add a line after each line
>containing <body>:
>
>while (<>) {
> print;
> print "Whatever new text\n" if /<body>/;
>}
Roy,
I will use above idea in a minute but following code works except it
does not attack the sub folders ... can you see why? Also having got
the temp- files, do I delete the original file and rename the temp
file with that name or is there a better way?
Cheers Geoff
use warnings;
use strict;
use File::Find;
my $dir = 'html/test';
find sub {
my $name = $_;
if (($name =~ /.html$/) && ($name !~ /^print/)) {
open (IN, "$name");
while (defined (my $line =<IN>)) {
if ($line =~ /<body>/i) {
$line =~ s/<body>/<body>\nSelect page with smaller font <a
href="print-$name">for printing<\/a>/i;
}
open (OUT, ">>html/test/temp-$name");
print OUT ($line);
}
}
}, $dir;
------------------------------
Date: Wed, 15 Oct 2003 22:08:57 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Converting indented data to a tree
Message-Id: <3f8dbf4c.298035321@news.erols.com>
Tore Aursand <tore@aursand.no> wrote:
: The "innermost" array is a [id, parent_id] thing. While the 'id' can be a
: simple counter (incremental), I need to keep track of the relationship to
: the parent also.
:
: While writing this message I got the idea of push'ing and pop'ing the
: current parent '$count' onto/from an array, and it _seems to_ work;
:
: my @array = ();
: my $this_level = 0;
: my $prev_level = 0;
: my @parents = (0);
: my $count = 0;
:
: while ( <DATA> ) {
: chomp;
: next unless ( length );
: $count++;
:
: my ( $spaces ) = m,^( *),;
: $this_level = length( $spaces ) / 4;
:
: if ( $this_level > $prev_level ) {
: push( @parents, $count );
^^^^^^
Not really what you're after. The resulting data structure will end up
pointing to the parent node's first child instead of pointing to the
parent node itself.
push( @parents, $count-1 );
: }
: elsif ( $this_level < $prev_level ) {
: pop( @parents );
It's possible for $this_level to drop more than one from $prev_level.
If your data went like this:
Page 1
Page 1.1
Page 1.1.1
Page 1.1.2
Page 2
then the tree outline would be thrown out of alignment.
splice() will work better than pop() :
splice @parents, $this_level - $prev_level;
: }
:
: push( @array, [$count, $parents[-1]] );
: $prev_level = $this_level;
: }
:
: Anyone for a better solution?
Use the level to index the @parents array directly instead of
adding/removing elements at its end.
my @parents = 0;
my @array;
while(<DATA>) {
my $depth = length( (/^( *)/)[0] ) / 4;
$parents[$depth+1] = $. ;
push @array, [ $. , $parents[$depth] ];
}
------------------------------
Date: Thu, 16 Oct 2003 03:21:53 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Converting indented data to a tree
Message-Id: <pan.2003.10.15.18.53.22.640137@aursand.no>
On Wed, 15 Oct 2003 20:32:26 +0200, Tore Aursand wrote:
> if ( $this_level > $prev_level ) {
> push( @parents, $count );
> }
> elsif ( $this_level < $prev_level ) {
> pop( @parents );
> }
Found out that the last elsif won't work, 'cause there will be times when
I need to "jump" from level 4 to level 1.
Solved it by doing this instead:
elsif ( $this_level < $prev_level ) {
pop( @parents ) for ( $this_level .. ($prev_level - 1) );
}
Tata!
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Thu, 16 Oct 2003 03:21:52 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Getting part of a number
Message-Id: <pan.2003.10.15.18.39.22.623975@aursand.no>
On Wed, 15 Oct 2003 12:50:26 -0400, slack3r wrote:
> I'm probably missing something simple but if you have a five digit zip
> code, how would you go about getting just the first 3 digits?
perldoc -f substr
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Thu, 16 Oct 2003 03:21:53 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: How can i write the values of a form through a cgi script in a txt file.
Message-Id: <pan.2003.10.15.18.41.09.901981@aursand.no>
On Wed, 15 Oct 2003 10:33:23 -0700, JR wrote:
> How can i write the values of a form through a cgi script in a txt file.
What have you tried so far? What doesn't work?
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: 15 Oct 2003 15:22:10 -0700
From: <gisle@activestate.com>
Subject: Re: How Do I Use Proxy in Net:HTTP?
Message-Id: <m3ad82rvjh.fsf@eik.i-did-not-set--mail-host-address--so-shoot-me>
"Public Interest" <ir@labranche.com> writes:
> Can anyone tell me how the proxy is implemented in LWP:UserAgent? I have to
> use a proxy in Net:HTTP, but proxy is not supported in it.
Net::HTTP support proxies just fine. RFC 2616 explains how to do it.
You basically just provide full absolute URLs with the requests you
send.
--
Gisle Aas
------------------------------
Date: Thu, 16 Oct 2003 00:55:17 GMT
From: "John" <no@spam.here>
Subject: Re: How does one move down a line in a file?
Message-Id: <V%ljb.152458$bo1.87433@news-server.bigpond.net.au>
"Roy Johnson" <rjohnson@shell.com> wrote in message
news:3ee08638.0310150851.4ee77f03@posting.google.com...
> "John" <no@spam.here> wrote in message
news:<Gy7jb.151558$bo1.15116@news-server.bigpond.net.au>...
> > > James Willmore <jwillmore@remove.adelphia.net> wrote:
> > > > --untested--
> > > > while(<FILE>){
> > > > my $first = <FILE>;
> > > > my $second = <FILE>;
> > > > my $third = <FILE>;
> > > > last;
> > > > }
> ...
> > can some1 pls elaborate why the variables start getting values from the
2nd
> > line instead of the 1st one?
> > what happens to the first line? goes into a void?
>
> No, it goes into $_. What did you think the "while(<FILE>)" line is
> doing?
>
> Each time you use the <> operator, you grab a new line. Your original
> example put the same grabbed line into each variable. The example
> above has four reads, and the first one is basically ignored.
>
> Reading the whole thing into an array (as suggested by Eric Roode) may
> be your most straightforward bet, depending on what you are really
> trying to do.
>
> Here's a variation on Abigail's recommendation for getting lines into
> three variables:
>
> READLOOP:{
> defined($_=<DATA>) or last READLOOP for (my ($v1, $v2, $v3));
>
> # Process lines here
>
> redo;
> }
Roy and Glen,
Thanks once again :)
------------------------------
Date: 15 Oct 2003 19:20:58 -0700
From: jwillmore@myrealbox.com (James Willmore)
Subject: Re: How does one move down a line in a file?
Message-Id: <d61170e5.0310151820.68d241d8@posting.google.com>
rjohnson@shell.com (Roy Johnson) wrote in message news:<3ee08638.0310151307.48f60bf3@posting.google.com>...
> James Willmore <jwillmore@remove.adelphia.net> wrote in message news:<20031015125342.67fce71f.jwillmore@remove.adelphia.net>...
<snip>
> You need to increment $count each time, or you're going to repeatedly
> assign $_ and $first, and none of the others. Is it not possible for
> you to test the solutions you propose?
Yes, it is possible for me to test code before posting. However, as
you pointed out, I made a mistake in one of the code snipits. So, I
_always_ put untested before and after the code. Sorry about that.
Next time I'll double check my post before posting - but leave the
"untested" in place in case I make a mistake.
>
> > --untested--
> > my @lines = <FILE>;
> > #access each ine as an element of the array
> > --untested--
>
> That's a winner, at least.
No, not really. It's an example of how to get lines of a file into an
array - but it has issues that have been pointed out many times on
this newsgroup. As the OP indicated, he wanted to get the first three
lines of a file. This will will accomplish that - and more. So will
the other code examples I posted (minus the errors).
Bottom line - this is covered in perlfaq5, perlopentut, and perhaps a
few other places.
Jim
------------------------------
Date: Thu, 16 Oct 2003 01:42:08 GMT
From: "John" <no@spam.here>
Subject: Re: How to update entries in a file
Message-Id: <QHmjb.152506$bo1.7844@news-server.bigpond.net.au>
[snipped]
>
>
> Looks like you cannot be troubled to provide actual code even when
> asked to provide actual code.
>
> Sheesh!
>
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
I guess it was my inexperienced judgement which allowed me to think that
whatever I was providing was sufficient.
Since I'm coding on a different PC and posting from a different one, it was
not as easy as just doing a copy/paste.
So yes, I was trying to avoid a situation where I'm typing everything in. In
hindsight, that may not have been the correct decision.
Actual server.pl code follows. It is now working and it saves the data
passed from client.pl into test.xml.
***************
#!/usr/bin/perl -w
use strict;
use IO::Socket;
my ($server);
my (@lines);
sub fileupdate {
open TEST, "test.xml" or die "Could not open test.xml $!\n";
print DATA @lines;
print DATA "\n";
close DATA;
}
$server = new IO::Socket::INET {
LocalAddr => 'localhost:9000',
Proto => 'tcp',
Reuse => 1,
) or die "Can't setup server $!\n";
$server->listen();
$server->autoflush(1);
print "Server is waiting for data...\n";
my $data;
while ($data = $server->accept()) {
print "Connected from: ", $data->peerhost();
print " on port: ", $data->peerport(), "\n";
while <$data> { # this line has been removed - it is here for
illustration of the old code only
@lines = <$data>;
} # this line has been removed - it is
here for illustration of the old code only
fileupdate();
print "Connection closed\n";
close $data;
print "Waiting for more data...\n";
}
************
The
while <$data> {
is the old
while <$addr> {
which was giving me grief as line 1 of input received was going into $_ and
not into the @lines array as intended.
Does the above make more sense now? Do I need to post the client.pl script
as well?
Once again, apologies for the hassles.
------------------------------
Date: 15 Oct 2003 15:24:25 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Is flock Needed for Logs?
Message-Id: <3f8dc919@news.victoria.tc.ca>
Public Interest (ir@labranche.com) wrote:
: I want to run a banner exchange. Click-through exchange. So far, my script
: works fine in testing. I am not using flock in the file now. I am worried
: about if 2 people hit the same cgi the same time. I think 2 cgis will be
: started and try to write to the same log file. What will happen? Will the
: second one hold and wait for the first done with the log file?
: open (my $out1, ">>log.txt");
: open (my $out2, ">>log.txt");
: print $out1 1;
: print $out2 2;
: close $out1;
: close $out2;
We have various perl scripts and C programs running on linux that append
logging messages straight into shared files and which are often running
with multiple copies (i.e. 40 or 50 copies at a time), and I have never
seen these log files corrupted by intermingled lines. The files are
opened in append mode. The perl scripts typically use one print statement
per logical line. The C programs use stdio but don't do anything to
buffer the output into lines, other than whatever the stdio does to buffer
the output. One file in particular gets about 10 thousand lines per hour
written this way. As I said, I have never seen a problem with these log
files.
My understanding is that a single `write()' of less than a certain (fairly
large) size is supposed to be atomic on unix (and presumably on linux) -
that means atomic relative to other write() calls. I.e. if two programs
both make two seperate calls to write, under the size limit, destined to a
single receiver, then the receiver will receive all of the data from one
write before any of the data from the other write.
Higher level io (i.e. fopen, fwrite etc) will typically buffer writes
together so that many individual writes end up being a single write(), and
therefore also atomic upto that same size, though this becomes somewhat of
a coincidence as you no longer explicitly control it.
I do not think the above is true for windows based machines.
Counter claims welcome.
------------------------------
Date: Thu, 16 Oct 2003 03:02:48 GMT
From: "Public Interest" <ir@labranche.com>
Subject: Re: Is flock Needed for Logs?
Message-Id: <sTnjb.3051$Ec1.265013@bgtnsc05-news.ops.worldnet.att.net>
>
> We have various perl scripts and C programs running on linux that append
> logging messages straight into shared files and which are often running
> with multiple copies (i.e. 40 or 50 copies at a time), and I have never
> seen these log files corrupted by intermingled lines. The files are
> opened in append mode. The perl scripts typically use one print statement
> per logical line. The C programs use stdio but don't do anything to
> buffer the output into lines, other than whatever the stdio does to buffer
> the output. One file in particular gets about 10 thousand lines per hour
> written this way. As I said, I have never seen a problem with these log
> files.
>
> My understanding is that a single `write()' of less than a certain (fairly
> large) size is supposed to be atomic on unix (and presumably on linux) -
> that means atomic relative to other write() calls. I.e. if two programs
> both make two seperate calls to write, under the size limit, destined to a
> single receiver, then the receiver will receive all of the data from one
> write before any of the data from the other write.
>
> Higher level io (i.e. fopen, fwrite etc) will typically buffer writes
> together so that many individual writes end up being a single write(), and
> therefore also atomic upto that same size, though this becomes somewhat of
> a coincidence as you no longer explicitly control it.
>
> I do not think the above is true for windows based machines.
>
So, did you use flock in C or Perl programs? 40-50 copies are a lot...
What I want to find what is when it is nessary to implement flock and when
it is taken care automatically.
Again, for my log or ad exchange program, can anyone SHOW me a sample of
using flock and give me an idea how many CGI files can wait on a locked
file?
I also would like to know what is LOCK_SH, I understand LOCK_EX, but how can
a lock shared?
In perldoc -f flock, it also states "To avoid the possibility of
miscoordination, Perl now flushes
FILEHANDLE before locking or unlocking it." What is a flush of filehandle?
flush the buffer into the handle?
------------------------------
Date: Thu, 16 Oct 2003 03:15:10 GMT
From: "Public Interest" <ir@labranche.com>
Subject: Re: Is flock Needed for Logs?
Message-Id: <23ojb.3063$Ec1.266173@bgtnsc05-news.ops.worldnet.att.net>
out1: 691
out1: 6: 351
out2: 352
.
.
.
out1: 1030
out1:92
out2: 693
why is that? when 1 writes:out1: 6, 2 wrties 351, then how could there be
another out1: before 92?
------------------------------
Date: 15 Oct 2003 22:31:20 GMT
From: Rafael Garcia-Suarez <rgarciasuarez@free.fr>
Subject: Re: mod_perl and 5.8.1
Message-Id: <slrnborita.gc9.rgarciasuarez@dat.local>
Jeff Boes wrote in comp.lang.perl.misc :
> Does anyone here know if there are issues between mod_perl (V1.26, if I'm
> reading my info right) and Perl V5.8.1? When we upgraded Perl and rebuilt
> mod_perl, our webserver scripts stopped producing output. They run, and if they
> open files they produce output in the files, but nothing to the browser.
>
> I'm wondering if this has anything to do with the PerlIO change ...
From which version of perl did you upgrade ? Have you the latest
mod_perl (1.29) ? (some issues with 5.8.1 were only fixed in the latest
mod_perls IIRC.) Have you rebuilt all your XS modules ?
------------------------------
Date: 15 Oct 2003 17:07:16 -0700
From: jwillmore@myrealbox.com (James Willmore)
Subject: Re: Perl scripts for Unix on my windows machine
Message-Id: <d61170e5.0310151607.160cd103@posting.google.com>
"Michael P. Broida" <michael.p.broida@boeing_oops.com> wrote in message news:<3F8D8FA5.8F3030FF@boeing_oops.com>...
> James Willmore wrote:
> >
> > The first line of your script _may_ present an issue. Consider this:
> > #!/usr/bin/perl -w
> >
> > This is no /usr/bin on many Windows boxes (unless you're using Cygwin,
> > which it appears you're not).
>
> I've had that line in many of my Windows Perl scripts and
> had NO problems with it. Windows doesn't use that line
> in any way at all, so it's just another comment line.
<snip>
True - however, it is something to consider when writing a portable
script. When you try and go the other way (Windows to Unix) it _does_
matter. And is something the OP should be made aware of - especial in
a mixed OS environment (something you should already know about, given
your email address).
perlport is the FAQ I was eluding to in my previous post.
HTH
Jim
------------------------------
Date: 15 Oct 2003 18:50:34 -0700
From: reneap@hotmail.com (Ren Patterson)
Subject: Re: Perl scripts for Unix on my windows machine
Message-Id: <2e13d330.0310151750.56f27108@posting.google.com>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message news:<bmk5vk$ngmu4$1@ID->
> My point is that your way of justifying that you hadn't tried revealed
> an irritating lack of respect to those whose help you were seeking.
How in the world does wanting to learn whether it is known for a fact
that one "type" of script will not work in Windows, before installing
that very script represent a lack of respect much less irritating?
Have you ever heard of asking before acting? or when in doubt ask?
>
> As regards your initial general question, you got some general
> guidance. It's of course not possible for anybody to know whether your
> particualar programs, which we know nothing about, can be run on Windows.
You see, I was trying to see if I was attempting a senseless act for,
perhaps "NO" Unix cgi-perl script could work in a Windows 98
environment. Remember I am new (oh not the N word!) and my intention
was to appeal to your gathered knwoledge, which I do not have. And for
those who may be thinking "well why didn't you do a search for it" my
illustrious, I did! and could not find a solid answer.
Now that could not be so hard cgi-perl and perl geniuses!
LOL watch the flame
------------------------------
Date: 15 Oct 2003 17:11:13 -0700
From: wherrera@lynxview.com (Bill)
Subject: Re: Threads and OO Question
Message-Id: <239ce42f.0310151611.3dfbc186@posting.google.com>
"Edward Wildgoose" <Ed+nospam@ewildgoose.demon.co.uk@> wrote in message news:<TMfjb.6107219$mA4.867092@news.easynews.com>...
> > Good question, I think. Maybe Arthur Bergman knows the answer.
>
> Sorry for my ignorance. Who is this person? Aha, google turns up "who" he
> is, but does he run a web page of useful info? (Anyone?)
>
Oh, he wrote the threads routines in 5.8, I think...
> However, this then brings us full circle back to the problem. In the main
> thread how do I talk back to the worker thread in order to ask it to
> populate the shared hash? (I want to avoid IPC stuff since I already
Well, if what you have works, I guess it's okay, but watch out for
race conditions.
Maybe one safe way is to create a flattened scalar representation of
the object--kind of like when you want to save an object to disk--and
pass that scalar via Thread::Semaphore?
However I've never done this, so I'm out of ideas.
------------------------------
Date: 15 Oct 2003 23:00:25 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Unexpected alteration of array's content
Message-Id: <bmkji9$3kj$1@mamenchi.zrz.TU-Berlin.DE>
Roy Johnson <rjohnson@shell.com> wrote in comp.lang.perl.misc:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message
> news:<bmjqm4$h7h$1@mamenchi.zrz.TU-Berlin.DE>...
> > Only that I don't share your dislike of "@{[@ar]}".
>
> I think you may have mistaken my comments on this topic. There are two
> points I was making:
> 1. there is no reason to use @{[@ar]} to solve the problem under
> consideration
> 2. @{[@ar]} is odd enough that someone browsing the code will "blink"
> when they hit it.
>
> I think we agree on #2. Brian, on the other hand, suggested that it
> was something to get used to (to the point that it is immediately
> understood whenever encountered).
Well, that is in the eye of the beholder. People get used to the
weirdest things, not limited to, but particularly in computer languages.
COBOL programmers used to put up with having to write a few hundred lines
of declarations before the first executable statement. No blink-effect
there, not after a few years of the same.
In one context, the "@{[ ... ]}" construct *is* idiomatic. It is regularly
used to interpolate arbitrary expressions into strings, as in
print "1 + 2 = @{[ 1 + 2 ]}\n";
The weirdness factor is even greater here, because there is only one
element in the inner array, but that's established Perl.
> > If you want an anonymous copy of an array, it's the way to go.
>
> Yes, it is. However, making an anonymous copy of the array is not the
> way to go to avoid modifying your array in a loop. There may be good
> reasons for making an anonymous copy of an array, although I haven't
> come up with any.
Well, string interpolation is one example. Another is a fix to a
misbehaving map or grep. "Oops, it's changing my array! Let's put
@{[ ... ]} around it." That comes close to the loop example.
I mentioned I didn't think it comes up often, but there are uses.
> I can see wanting to do [@ar], and I can certainly see @$ref, but not
> instantly dereffing a newly-created array ref.
>
> If the question is how to avoid the side-effects of loop variable
> modification, the answer is to make a local copy of the loop variable,
> not to copy the entire array.
Why not? Once the blink reflex has worn off, it's a possible alternative.
I would probably not use it in a traditional loop (with a block body),
but with statement-modifying "for", as with "map" above, a local copy is
less easy to accommodate. A lot depends on context, and I can see contexts
where "@{[ ... ]}" is appropriate.
Anno
------------------------------
Date: Thu, 16 Oct 2003 00:51:52 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Unexpected alteration of array's content
Message-Id: <x7ekxeuhqv.fsf@mail.sysarch.com>
>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
AS> In one context, the "@{[ ... ]}" construct *is* idiomatic. It is
AS> regularly used to interpolate arbitrary expressions into strings,
AS> as in
AS> print "1 + 2 = @{[ 1 + 2 ]}\n";
the scalar version also works but is uglier: "${\ 1 + 2 }. and it has a
bug because it provides list context. the Interpolate module supports
the use of $() for that. perl6 will also have $() and @() to do it as
builtins (they also will work outside strings and replace scalar()).
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 15 Oct 2003 22:07:59 GMT
From: "James E Keenan" <nospam_for_jkeen@concentric.net>
Subject: Re: Why Is My Hash Assignment Taking So Long?
Message-Id: <bmkgfv$tc@dispatch.concentric.net>
"Uri Guttman" <uri@stemsystems.com> wrote in message
news:x7ptgz3dyk.fsf@mail.sysarch.com...
> >>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
> [snip]
> i ran into this many
> years ago and redesigned a subsystem to use multiple subdirs before
> finding a particular file. it effectively converted a linear search to a
> tree search. i used 2 digits of the log file name for 2 levels keeping
> the number of entries in any directory to under 100. it was much much
> faster than the old system which had 10k+ entries in one dir. this is
> still a common and easy technique.
And after I pondered Anno's first response to my OP, I began to design a new
directory structure that works along very much the same principle (viz.,
breaking up this one big directory into smaller directories where the files
sort on a very simple principle such as the 1st letter of the file name).
> [snip]
>
> and i would limit dir sizes to way less than 1000. 100-300 seems to be a
> good value.
>
Agreed.
> and this is way OT as it has no perl content at all.
>
Disagree. See my original posting. I thought the posting might be due to
some problems in my Perl hash assignment. While Anno pointed out some ways
in which my code could be optimized (which I've since implemented), he
explained something about file systems I didn't previously know and
correctly diagnosed the problem as a system problem rather than a Perl
problem.
jimk
------------------------------
Date: 15 Oct 2003 23:12:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Why Is My Hash Assignment Taking So Long?
Message-Id: <bmkk8l$3kj$2@mamenchi.zrz.TU-Berlin.DE>
James E Keenan <nospam_for_jkeen@concentric.net> wrote in comp.lang.perl.misc:
>
> "Uri Guttman" <uri@stemsystems.com> wrote in message
> news:x7ptgz3dyk.fsf@mail.sysarch.com...
> > >>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
> > and i would limit dir sizes to way less than 1000. 100-300 seems to be a
> > good value.
> >
>
> Agreed.
>
> > and this is way OT as it has no perl content at all.
> >
> Disagree. See my original posting. I thought the posting might be due to
> some problems in my Perl hash assignment. While Anno pointed out some ways
> in which my code could be optimized (which I've since implemented), he
> explained something about file systems I didn't previously know and
> correctly diagnosed the problem as a system problem rather than a Perl
> problem.
...which means that my reply was off topic already. Let's no prolong it.
Anno
------------------------------
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 5667
***************************************