stevena has asked for the wisdom of the Perl Monks concerning the following question:

When I had Strawberry perl 5.22.0.1 (strawberry-perl-5.22.0.1-64bit.msi) installed under Windows 10, all was fine.

Then I installed Strawberry perl 5.28.0.1 (strawberry-perl-5.28.0.1-64bit.msi), after which trying to require 'getopts.pl'; gives the error "Can't locate getopts.pl in @INC (@INC contains: C:/Strawberry/perl/site/lib C:/Strawberry/perl/vendor/lib C:/Strawberry/perl/lib) at SCRIPTNAME line LINENUM."

How do I make sure my installation has getopts.pl? (I made some probably-misdirected attempts using the cpan executable to get it installed.)

I'd be grateful for either a "Please read <url>" or direct answer. Thank you.

"perl -V" output follows

Summary of my perl5 (revision 5 version 28 subversion 0) configuration:

  Platform:
    osname=MSWin32
    osvers=10.0.17134.112
    archname=MSWin32-x64-multi-thread
    uname='Win32 strawberry-perl 5.28.0.1 #1 Sat Jun 23 13:55:45 2018 x64'
    config_args='undef'
    hint=recommended
    useposix=true
    d_sigaction=undef
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=undef
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='gcc'
    ccflags =' -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -D__USE_MINGW_ANSI_STDIO -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -fwrapv -fno-strict-aliasing -mms-bitfields'
    optimize='-s -O2'
    cppflags='-DWIN32'
    ccversion=''
    gccversion='7.1.0'
    gccosandvers=''
    intsize=4
    longsize=4
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='long long'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='g++'
    ldflags ='-s -L"C:\STRAWB~1\perl\lib\CORE" -L"C:\STRAWB~1\c\lib"'
    libpth=C:\STRAWB~1\c\lib C:\STRAWB~1\c\x86_64-w64-mingw32\lib C:\STRAWB~1\c\lib\gcc\x86_64-w64-mingw32\7.1.0
    libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    libc=
    so=dll
    useshrplib=true
    libperl=libperl528.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs
    dlext=xs.dll
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags='-mdll -s -L"C:\STRAWB~1\perl\lib\CORE" -L"C:\STRAWB~1\c\lib"'


Characteristics of this binary (from libperl):
  Compile-time options:
    HAS_TIMES
    HAVE_INTERP_INTERN
    MULTIPLICITY
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_IMPLICIT_CONTEXT
    PERL_IMPLICIT_SYS
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    USE_64_BIT_INT
    USE_ITHREADS
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
  Built under MSWin32
  Compiled at Jun 23 2018 14:00:04
  @INC:
    C:/Strawberry/perl/site/lib
    C:/Strawberry/perl/vendor/lib
    C:/Strawberry/perl/lib

Replies are listed 'Best First'.
Re: reinstall Strawberry perl loses getopts.pl
by pryrt (Abbot) on Aug 22, 2018 at 20:55 UTC

    per perl5160delta,

    Several old perl4-style libraries which have been deprecated with 5.14 are now removed:

    abbrev.pl assert.pl bigfloat.pl bigint.pl bigrat.pl cacheout.pl complete.pl ctime.pl dotsh.pl exceptions.pl fastcwd.pl flush.pl getcwd.pl getopt.pl getopts.pl hostname.pl importenv.pl lib/find{,depth}.pl look.pl newgetopt.pl open2.pl open3.pl pwd.pl shellwords.pl stat.pl tainted.pl termcap.pl timelocal.pl

    They can be found on CPAN as Perl4::CoreLibs.

    And, per Perl4::CoreLibs, you should be using Getopt::Std in lieu of getopts.pl

    update: I'm not sure why it was in your 5.22, because I cannot find it in any of my strawberries after 5.14. I am assuming you (or someone else) installed it alone (ie, copied it from an older perl 5.14 or earlier) or by installing Perl4::CoreLibs.

      Thank you both. Yes, it's an old script I'm trying to run.

      As suggested, getting and installing Perl4::CoreLibs worked. (I must have done that with 5.2.2, lost to memory.)

Re: reinstall Strawberry perl loses getopts.pl
by haukex (Archbishop) on Aug 22, 2018 at 20:55 UTC

    getopts.pl was removed in Perl v5.16. Although you could install Perl4::CoreLibs to get it back, I'd strongly recommend you switch to the core module Getopt::Std or Getopt::Long - often the replacement is pretty simple; in particular, have a look at getopts from Getopt::Std.

    getopts.pl says:

    This library is no longer being maintained, and is included for backward compatibility with Perl 4 programs which may require it.

    In particular, this should not be used as an example of modern Perl programming techniques.

    Suggested alternatives: Getopt::Long or Getopt::Std