I have an object with a method that returns a file descriptor, and I want to read it. The following does not work because the rectangular bracket of the method call is interpreted as the bracket of the closing angle of the input reader:
my $input = <$object->get_handle()>;
This is analyzed as:
my $input = ( < $object- > ) get_handle() >;
which is obviously a syntax error. Is there a way I can make a method call inside an angle operator, or do I need to break it into two steps?
my $handle = $object->get_handle();
my $input = <$handle>;
source
share