Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: passing file handle to functions

by Samy_rio (Vicar)
on May 18, 2006 at 05:53 UTC ( [id://550164]=note: print w/replies, xml ) Need Help??


in reply to passing file handle to functions

Hi, if I have understood your question correctly then try this,

use strict; use warnings; #####Function 1############# open (FF, "sample.xml")||die $!; my @con = <FF>; close(FF); #Passing Array to a function &function1(\@con); #####Function 2############# open (FF, "sample.xml")||die $!; #Passing File handle to a function &function2(\*FF); close(FF); sub function1{ my ($con) = @_; #Dereference the array my @con = @{$con}; $,="\n"; print @con; } sub function2{ my ($con) = @_; print <$con>; }

View these How (Not) To Ask A Question and How do I post a question effectively?

Regards,
Velusamy R.


eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://550164]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-26 04:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found