[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Missing @INC path for pkg-perl-autopkgtest



Hi Roland,

I can't really comment on the autopkgtest issue, but I'd like to
explain how to avoid collisions on filehandle E:

> +sub readandsetenv {
> +    my $file = "debian/tests/pkg-perl/syntax-env";
> +    -r $file or return ();

Either you add this before calling open:

```
local *E;
```

> +    open (E, '<', $file)
> +        or BAIL_OUT("$file exists but can't be read");
> +    while (<E>) {
> +        chomp;
> +        if (/^(.+)=(.*)$/) {
> +            $ENV{$1} = $2;
> +        } else {
> +            BAIL_OUT("syntax error in $file: $_");
> +        }
> +    }
> +    close E;
> +}

Or replace E with a scalar filehandle (e.g. $env_fd) previously
declared with my or straight into the open call:

```
open (my $env_fd, '<', $file)
# ...
while (<$env_fd>) {
# ...
close $env_fd;
```

You could even avoid calling close because both *E and $env_fd
will be bound to the scope of readandsetenv sub, and the
filehandle will be closed when leaving that scope.

Cheers and sorry for nitpicking,
Alex

--
  ⢀⣴⠾⠻⢶⣦⠀
  ⣾⠁⢠⠒⠀⣿⡁   Alex Muntada <alexm@debian.org>
  ⢿⡄⠘⠷⠚⠋   Debian Developer 🍥 log.alexm.org
  ⠈⠳⣄⠀⠀⠀⠀

Attachment: signature.asc
Description: PGP signature


Reply to: