Tengo el siguiente código:
Using perl Syntax Highlighting
- #!/usr/bin/env perl
- use v5.30;
- my $Win = 0;
- if ($^O =~ /mswin32/i) { $Win = 1; }
- if ($^O =~ /cygwin/i) { $Win = 1; }
- if ($^O =~ /msys/i) { $Win = 1; }
- if ($Win) {
- say 'Cargando el módulo Win32::TieRegistry';
- eval 'use Win32::TieRegistry qw|KEY_READ REG_SZ|';
- my $open_params = {Access => KEY_READ(), Delimiter => q{/}};
- }
- else{
- say 'No cargamos el módulo Win32::TieRegistry';
- }
- __END__
Coloreado en 0.005 segundos, usando GeSHi 1.0.8.4
La salida en Windows es:
La salida en Linux es:
Y la salida usando git bash en Windows es:
- Cargando el módulo Win32::TieRegistry
- Undefined subroutine &main::KEY_READ called at forum.pl line 12.
Asumo que el problema pasa por MINGW64/MSYS y alguna configuración de variable de entorno que confunde a perl cuando carga el módulo. La salida de env es:
- $ env
- USERDOMAIN=WORKTEX
- OS=Windows_NT
- COMMONPROGRAMFILES=C:\Program Files\Common Files
- PROCESSOR_LEVEL=6
- PSModulePath=C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
- CommonProgramW6432=C:\Program Files\Common Files
- CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
- LANG=es_MX.UTF-8
- MSYSTEM_CARCH=x86_64
- DISPLAY=needs-to-be-defined
- HOSTNAME=worktex
- PUBLIC=C:\Users\Public
- CONFIG_SITE=/mingw64/etc/config.site
- EXEPATH=C:\Program Files\Git
- MSYSTEM_CHOST=x86_64-w64-mingw32
- USERNAME=pablo
- ChocolateyInstall=C:\ProgramData\chocolatey
- JAVA_HOME=D:\jdk
- LOGONSERVER=\\WORKTEX
- PROCESSOR_ARCHITECTURE=AMD64
- LOCALAPPDATA=C:\Users\pablo\AppData\Local
- COMPUTERNAME=WORKTEX
- !::=::\
- SYSTEMDRIVE=C:
- USERPROFILE=C:\Users\pablo
- PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
- SYSTEMROOT=C:\Windows
- USERDOMAIN_ROAMINGPROFILE=WORKTEX
- PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 42 Stepping 7, GenuineIntel
- MINGW_PACKAGE_PREFIX=mingw-w64-x86_64
- PWD=/d/linux/ltximg/test
- SSH_ASKPASS=/mingw64/libexec/git-core/git-gui--askpass
- HOME=/c/Users/pablo
- TMP=/tmp
- TERM_PROGRAM=mintty
- TERM_PROGRAM_VERSION=3.1.6
- MSYSTEM_PREFIX=/mingw64
- OneDrive=C:\Users\pablo\OneDrive
- PROCESSOR_REVISION=2a07
- TMPDIR=/tmp
- NUMBER_OF_PROCESSORS=2
- ProgramW6432=C:\Program Files
- COMSPEC=C:\Windows\system32\cmd.exe
- APPDATA=C:\Users\pablo\AppData\Roaming
- SHELL=/usr/bin/bash
- TERM=xterm
- WINDIR=C:\Windows
- MINGW_CHOST=x86_64-w64-mingw32
- ProgramData=C:\ProgramData
- SHLVL=1
- PLINK_PROTOCOL=ssh
- ACLOCAL_PATH=/mingw64/share/aclocal:/usr/share/aclocal
- PROGRAMFILES=C:\Program Files
- MANPATH=/mingw64/local/man:/mingw64/share/man:/usr/local/man:/usr/share/man:/usr/man:/share/man
- ORIGINAL_TEMP=/tmp
- ORIGINAL_TMP=/tmp
- ALLUSERSPROFILE=C:\ProgramData
- TEMP=/tmp
- DriverData=C:\Windows\System32\Drivers\DriverData
- MSYSTEM=MINGW64
- MINGW_PREFIX=/mingw64
- asl.log=Destination=file
- SESSIONNAME=Console
- ProgramFiles(x86)=C:\Program Files (x86)
- PATH=/c/Users/pablo/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/pablo/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/cmd:/c/ProgramData/chocolatey/bin:/c/Strawberry/c/bin:/c/Strawberry/perl/site/bin:/c/Strawberry/perl/bin:/c/Users/pablo/AppData/Local/Microsoft/WindowsApps:/c/texlive/2020/bin/win32:/d/jdk/bin:/usr/bin/vendor_perl:/usr/bin/core_perl
- PS1=\[\033]0;$TITLEPREFIX:$PWD\007\]\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$
- HOMEDRIVE=C:
- ChocolateyLastPathUpdate=132361075449381174
- PKG_CONFIG_PATH=/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig
- INFOPATH=/usr/local/info:/usr/share/info:/usr/info:/share/info
- HOMEPATH=\Users\pablo
- ORIGINAL_PATH=/mingw64/bin:/usr/bin:/c/Users/pablo/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/cmd:/c/ProgramData/chocolatey/bin:/c/Strawberry/c/bin:/c/Strawberry/perl/site/bin:/c/Strawberry/perl/bin:/c/Users/pablo/AppData/Local/Microsoft/WindowsApps:/c/texlive/2020/bin/win32:/d/jdk/bin
- _=/usr/bin/env
¿Cuál es la manera correcta de cargar el módulo bajo MINGW64/MSYS?