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

I've recently upgrading my perl version from 628 to 631 and now the backticks are not returning the output from their system calls. The following example used to work on 628 but no longer works after the 631 upgrade. I'd rewrite the function (not mine in the first place) but it doesn't solve the problem that backticks still don't work and we use them other places in the code. Any help would be appreciated.
print "Ourname = $ourname"; ($ourshortname = $0) =~ s!/!\\!g; $ourshortname = `dir /b $ourname`; $ourshortname =~ s/[^\.\w-]//g; $ourname =~ m!(.*)\\([^\\]*)$!; $ourname = "cgi-bin/$ourshortname"; print "ourname is now $ourname<BR>";

Added code tags - dvergin 2002-03-27

Replies are listed 'Best First'.
Re: backtick problems with perl 5.6.1.631
by particle (Vicar) on Mar 27, 2002 at 20:19 UTC
    are you sure?
    H:\perllib\Tk800.024>perl -v This is perl, v5.6.1 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail) Copyright 1987-2001, Larry Wall Binary build 631 provided by ActiveState Tool Corp. http://www.ActiveS +tate.com Built 17:16:22 Jan 2 2002 Perl may be copied only under the terms of either the Artistic License + or the GNU General Public License, which may be found in the Perl 5 source ki +t. Complete documentation for Perl, including FAQ lists, should be found +on this system using `man perl' or `perldoc perl'. If you have access to + the Internet, point your browser at http://www.perl.com/, the Perl Home Pa +ge. H:\perllib\Tk800.024>perl -e "@dir=`dir`;print \"hello, $dir[0]\"" hello, Volume in drive H is Disk#1 H:\perllib\Tk800.024>

    ~Particle ;Þ

      Ok, I finally have the command line giving me the value returned from the command executed in the `dir` part of your code. Someone had set the PERL5SHELL and it wasn't picking up the correct command prompt to run from. But I still can't get these lines of code to work properly.
      Yes, I've checked the perl -v and it's exactly the same Running your code, I get this though C:\>perl -e "@dir=`dir`;print \"hello, $dir[0]\"" hello, It may not be perl itself, but are there any other suggestions?
        It's true, typing:
        perl -e "@dir=`dir`; print qq{hello, $dir[0]};"
        Does print
        hello,
        However, this is because the first line of output from the Windows "dir" command is a blank line. If instead you use
        perl -e "@dir=`dir`; print qq{hello, $dir[1]};"
        you'll get
        hello, Volume in drive C has no label

        stephen

        Clarification: My response only referred to the example in the parent node. I'm sorry that my response wasn't helpful. I tested my example code on 5.6.1.631 running on Windows 98, and it gave the results I stated. Perhaps I've got an incorrect assumption running around someplace.

Re: backtick problems with perl 5.6.1.631
by webadept (Pilgrim) on Mar 27, 2002 at 20:41 UTC
    Locally applied patches:
    ActivePerl Build 631
    Built under MSWin32
    Compiled at Jan 2 2002 17:16:22

    This is working on my laptop, but I have tried command lines in the past that didn't work because of the backticks. I just thought it was some MS thing and did them in a linux window. I'm so use to running into MS problems on the active state perl that I just don't pay attention much anymore. however
    perl -e "@dir=`dir`; print\"Hello, $dir[0]\""
    gives the proper responce.

    Glenn H.