I need to open and use the contents of files as they are passed as a reference into my subroutine. I have researched and found 

[How to pass a file handle to a function?](https://stackoverflow.com/questions/6845376/how-to-pass-a-file-handle-to-a-function)

but this did not work for me.

I have minimized the code considerably to get to the point. Here it is.

```
#!/usr/bin/env perl
use strict;
use warnings;

my @dirs = qw(/opt/r2configs/sapbid00/2018/03/15/lparstat-i.out /opt/r2configs/sapbiq00/2018/03/15/lparstat-i.out);

sub _ce {

    die "no parameter!\n" unless @_;
    my ($ce_ref) = @_;

    for my $name (@{ $ce_ref }) {
        print "$name\n";
        chomp $name;
        open (my $i, "+<", $name) or warn $!;
        while (<$i>) {
            print "$i,\n";
        }
    }
}

_ce( \@dirs );

```

```none
# perl -c foo
foo syntax OK
root@r2nim01.xxx.com(/usr/local/scripts)$
# perl foo
/opt/r2configs/sapbid00/2018/03/15/lparstat-i.out
GLOB(0x20020148),
GLOB(0x20020148),
GLOB(0x20020148),
GLOB(0x20020148),
GLOB(0x20020148),
/opt/r2configs/sapbiq00/2018/03/15/lparstat-i.out
GLOB(0x20020148),
GLOB(0x20020148),
.
.
.

### The files do exist and I am root user. ###
# ls -l /opt/r2configs/sapbiq00/2018/03/15/lparstat-i.out
-rw-r--r--    1 root     system         2217 Mar 15 20:35 /opt/r2configs/sapbiq00/2018/03/15/lparstat-i.out

```