I have a routine that takes a file descriptor as an argument. How to create a file descriptor from the file path specified on the command line? I don’t want to process this file myself, I just want to transfer it to this other routine, which returns an array of hashes with all the analyzed data from the file.
Here, what uses the command line input is as follows:
$ ./getfile.pl /path/to/some/file.csv
Here, what the start of the subroutine that I call looks like this:
sub parse {
my $handle = shift;
my @data = <$handle>;
while (my $line = shift(@data)) {
}
}
source
share