Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

copying files through modules

by peeeeeeeeeeete (Initiate)
on May 18, 2005 at 05:24 UTC ( [id://458079]=perlquestion: print w/replies, xml ) Need Help??

peeeeeeeeeeete has asked for the wisdom of the Perl Monks concerning the following question:

hi, I'm trying to copy a file through a module and i seem to be stuck. the function in the module is supposed to pass out a file handle which will be used to save the file on the .pl file that is "using" the module. I dont understand how the .pl file can accept a module and then proceed to save the file. i also dont understand how the module will pass out a file handle. can someone please clarify these two points? thanks

Replies are listed 'Best First'.
Re: copying files through modules
by K_M_McMahon (Hermit) on May 18, 2005 at 06:44 UTC
    Hello Pete, welcome to the monastery. Your question is not very clear and you are new here, so let me start with a little advice:

    Read How do I post a question effectively? AND
    Writeup Formatting Tips ... these will help you form your questions more effectively.

    Specifically:
    Which module are you talking about.
    by .pl file do you mean your script? Perl scripts do not have to end in .pl
    Any sample code to illustrate the question (i.e. what have you tried?)? use code tags and paste into your question.
    what is the ultimate goal that you are trying to reach, remember TIMTOWTDI with perl.
    use strict and warnings.

    -Kevin
    my $a='62696c6c77667269656e6440676d61696c2e636f6d'; while ($a=~m/(^.{2})/s) {print unpack('A',pack('H*',"$1"));$a=~s/^.{2}//s;}
      hi Guys, Sorry abt my previous post. basically what i want to do is write a module that contains a function that returns an open filehandle at the begining of a file which i want to copy to a location specified in my local script. i'm not sure how to return a filehandle. i also dont know how i can accept a filehandle in the script. i tried this but it wouldn't work coz i use strict. copy.txt is the filename which i want to save it as. open OUTF, '>copy.txt; OUTF = MyModule::Myfunction; thanks for the help

        Would it be possible to, instead of describing a problem, actually demonstrate the code you're having trouble with? Not all 1000 lines, mind you. Create a 20-line (or less) snippet that isolates and illustrates your question. I'm starting to see what you're asking, but when you start saying things like "i also don't know how i can accept a filehandle in the script", that could have several meanings.


        Dave

Re: copying files through modules
by Thilosophy (Curate) on May 18, 2005 at 06:45 UTC
    I do not really understand most of your question, can you explain what you mean by "accept a module"?

    If all you are trying to do is copy a file from one disk location to another, you could use the File::Copy module which is included in the Perl base distribution:

    use File::Copy; copy("file1","file2") or die "Copy failed: $!";
Re: copying files through modules
by thcsoft (Monk) on May 18, 2005 at 08:15 UTC
    you will probably find the answers you're looking for in:
    perldoc perlsub perldoc perlref perldoc perltoot
    language is a virus from outer space.
Re: copying files through modules
by holli (Abbot) on May 18, 2005 at 06:44 UTC
    Boy, you mind telling us which module you talk about?


    holli, /regexed monk/

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2025-02-18 07:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found