in reply to How do I test a script that doesn't have a .pl extension

This seems to work require_ok("foo\0");

As does use lib 'source'; require_ok('bin/foo');

Both \0 and / signal to require_ok that you're looking to require a file ( as in require_ok_file or require_ok_expr, not require_bareword )

  • Comment on Re: How do I test a script that doesn't have a .pl extension

Replies are listed 'Best First'.
Re^2: How do I test a script that doesn't have a .pl extension
by Corion (Patriarch) on Nov 02, 2012 at 13:24 UTC

    Just as a heads-up, I expect Perl to issue a warning (or maybe even a fatal error, maybe with taint) in the future when it is told to open a file from a scalar containing a \0. This is under the assumption that most such usage is malicious, for example to circumvent naïve "filename" validation like the following:

    # Read (malicious) filename from user, over the web: $filename = "/etc/passwd\0.jpg"; # Verify it's a .jpg file: $filename =~ /\.jpg$/ or return; # Verify it exists: -f $filename or return; # Output the file to the user: send_file( $filename );
Re^2: How do I test a script that doesn't have a .pl extension
by ten8ciousb (Novice) on Nov 02, 2012 at 13:20 UTC
    thank you. yes. this also works.
    one note to future Seekers:
    you need the "", not ''
    require_ok('foo\0'); ### it no work require_ok("foo\0"); ### passes