in reply to Re: split a file to several smaller file
in thread split a file to several smaller file

thanks.. and what is $fh_out? $fh_in is the text file it is reading right? Now there is no errors but I am not spawning any files.. there is no output..
  • Comment on Re^2: split a file to several smaller file

Replies are listed 'Best First'.
Re^3: split a file to several smaller file
by ikegami (Patriarch) on Dec 29, 2007 at 04:34 UTC

    Did you actually open a file and assign the handle to $fh_in?

    open(my $fh_in, '<', $qualified_name) or die("Unable to open file \"$qualified_name\" to split: $!\n");
Re^3: split a file to several smaller file
by doom (Deacon) on Dec 29, 2007 at 06:19 UTC

    and what is $fh_out? $fh_in is the text file it is reading right?

    Yes, except that these are "file handles" rather than the actual file in any sense, (hence the naming convention "fh").

    Does that make sense? If you do a close $fh_out; the file doesn't go away, just perl's ability to write to the file via that particular handle.

      Thanks for the explaination of file handler.. it make sense.. i did specified a fh_in. but i'm still not sure what does fh_out do? we have $base and $ext to work out the file name of the output so what does fh_out do?
Re^3: split a file to several smaller file
by sardines (Novice) on Dec 31, 2007 at 02:19 UTC
    Thanks for the explaination of file handler.. it make sense.. i did specified a fh_in. but i'm still not sure what does fh_out do? we have $base and $ext to work out the file name of the output so what does fh_out do?
      Just as '$fh_in' is the file handle for input, '$fh_out' is the file handle for output. The print function checks its first argument (the first thing that comes after the word "print"), and if this arg turns out to be a file handle, then the rest of the args are printed to that file; if the first arg after "print" is not a file handle, then print assumes 'STDOUT' (the default output file handle) and prints all its args to that "file" (which is usually your terminal window).