Re: how do prlglobs expand (was Re: 'nobody' using sudo -- scary!)
- From: Ben Morrow <ben@xxxxxxxxxxxx>
- Date: Sat, 28 Jun 2008 15:01:55 +0100
[please quote properly]
Quoth news1234@xxxxxxx:
What would happen if I use follwing statement in perl"
foreach my $file (</home/*/.forward>){
do_something($file);
}
would perl
- iterate through the files
- or would perl first create a list of all the files and then
iterate through them.
'foreach' always creates a list and then iterates over it.
- or would it hit a linit and not provide all hits.
- or does it depend on the system perl is running on
You will eventually hit the memory limit on your system, and the limit
on the size of the pointer used to index the perl stack; you won't hit
any limits before that.
You can avoid pre-creating the list by using 'while' instead:
while (my $file = </home/*/.forward>) {
...
}
Ben
--
For far more marvellous is the truth than any artists of the past imagined!
Why do the poets of the present not speak of it? What men are poets who can
speak of Jupiter if he were like a man, but if he is an immense spinning
sphere of methane and ammonia must be silent? [Feynmann] ben@xxxxxxxxxxxx
.
- Follow-Ups:
- References:
- 'nobody' using sudo -- scary!
- From: Johnny
- Re: 'nobody' using sudo -- scary!
- From: RedGrittyBrick
- Re: 'nobody' using sudo -- scary!
- From: Big and Blue
- how do prlglobs expand (was Re: 'nobody' using sudo -- scary!)
- From: nntpman68
- 'nobody' using sudo -- scary!
- Prev by Date: Re: Simplest way (or module) to tweak query in CGI server-side validation
- Next by Date: Re: Simplest way (or module) to tweak query in CGI server-side validation
- Previous by thread: how do prlglobs expand (was Re: 'nobody' using sudo -- scary!)
- Next by thread: Re: how do prlglobs expand (was Re: 'nobody' using sudo -- scary!)
- Index(es):
Relevant Pages
|