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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
how to open mutltiple files and pass there refrence to another sub

 



Vipul
New User

Mar 2, 2009, 2:32 AM

Post #1 of 5 (1758 views)
how to open mutltiple files and pass there refrence to another sub Can't Post

i am writing a script where i accepts file names from user open those file and get time stamp form 1st line (according to which i need to sort the files)
and pass sorted list to a subroutine without closing the files
i am not having any idea how to do it
can anyone help


FishMonger
Veteran / Moderator

Mar 2, 2009, 4:44 AM

Post #2 of 5 (1756 views)
Re: [Vipul] how to open mutltiple files and pass there refrence to another sub [In reply to] Can't Post

Post what you've tried.


1arryb
User

Mar 2, 2009, 2:16 PM

Post #3 of 5 (1750 views)
Re: [Vipul] how to open mutltiple files and pass there refrence to another sub [In reply to] Can't Post

Hi Vipul,

What Fish said, plus:

1. How many files are you talking about? There are limits to the number of files you can open at one time.
2. Please provide a sample file, so we can take a look at the format.
3. What does your subroutine do? Maybe you don't need to have all the files open at once (see above).

Cheers,

Larry


Vipul
New User

Mar 2, 2009, 11:12 PM

Post #4 of 5 (1742 views)
Re: [1arryb] how to open mutltiple files and pass there refrence to another sub [In reply to] Can't Post

i got that solution but now i have another problem

the function gives a sorted list of hash
but i want two keys current one and next to it how can it be done

Code
foreach my $key (sort {$myhash{$a} cmp $myhash{$b}} keys %myhash) { 
parsefunction($myhash{$key});
}


KevinR
Veteran


Mar 2, 2009, 11:51 PM

Post #5 of 5 (1740 views)
Re: [Vipul] how to open mutltiple files and pass there refrence to another sub [In reply to] Can't Post

sort the keys into an array. Then you can use indexing to display the current and next element of the array.
-------------------------------------------------

 
 


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

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