Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

counting opened files

Status
Not open for further replies.

rafiu

Programmer
Jul 3, 2007
14
US
i'm using a file handle to open multiple files but I'm not getting the actual results - not knowing how many files that are opened. do you guys know any little code I can use?
Below is what I'm using but its giving me a bogus answer.

use strict;
my $count = 0 ;
while ( $count >= 0 )
{
$count++ ;
$FH = "FILE" . "$count" ;
open $$FH , "$file_path" or last ;
}

print "\n $count File opens\n" ;

 
hmmm.... the code you posted will not even compile. Is that the real code you are using?

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
use strict;
foreach $file_path (@file_path)
{
print "$file_path\n" #this has the full path to each file
my $count = 0 ;
while ( $count >= 0 )
{
$count++ ;
$FH = "FILE" . "$count" ;
open $$FH , "$file_path" or last ;
}

print "\n $count File opens\n" ;
}
 
Thats not going to compile either if thats all the code. Are we to assume the code is valid and compiles and runs?
If so, what does it print at the end?

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
I concur with Kevin: please post a working code without errors (there is one for example in the fourth line), even if it doesn't what you need, and better specify the goal of the code: why are you opening many (how many?) files at the same time?

Franco
: Online tools for structural design
: Magnetic brakes for fun rides
: Air bearing pads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top