CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
looping filehandles problem


New User

May 29, 2008, 6:00 AM

Post #1 of 2 (453 views)
looping filehandles problem Can't Post

I'm trying to make my program copy these txt files all into one,


while( <$my_filehandle> )


print $my_filehandle $_;


this code works fine, except im trying to print output from than one file. So when i change my code to the following,


my $counter = 0;

while( $counter < 3 ) # if i have 3 files..


while (<"@filehandles[$counter]">)


print <....> $_;




For some reason when i try to loop it it wont work, but when i copy and paste my 1st while statement with differend filehandles it works.

I've tried using the foreach method of copying data, same thing it copies if hardcode my file handles but when i try to make them change using an array, or using

$my_file handle = @filehandles[$counter];

but that doesn't work..

Anyone have any idea?

Thx ahead of time

New User

May 29, 2008, 7:59 AM

Post #2 of 2 (448 views)
Re: [z00m-z00m] looping filehandles problem [In reply to] Can't Post

never mind, i got it...

it was the way i was initializing my array of filehandle names...

i used @my_filehandles = "in","out",....;

then i tried @my_filehandles = 'in','out',....;


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives