in reply to Use of uninitialized value when using regex

Thanks guys combined all your advice to get it working.
  • Comment on Re: Use of uninitialized value when using regex

Replies are listed 'Best First'.
Re^2: Use of uninitialized value when using regex
by Marshall (Canon) on Sep 13, 2010 at 12:06 UTC
    I guess a bit off topic as you've gotten some good advice.. but I would recommend that you get out of the habit of using '\' in path names. This is just not necessary and this backslash the backslash stuff can get to be a mess!

    In ancient DOS days, the backslash was required. But now with the MS command line, that is no longer true. The \ character is the escape character in string evaluation and it just causes problems. Use the *nix style /, forward slash. Of course remember that when making a path name, put double quotes around the string "$a/$b" otherwise Perl will figure that you are doing division! But in general forego this \ stuff.

    #!/usr/bin/perl -w use strict; my $dir1 = 'Z:\My Documents\Workspace'; #you need single quote here my $versionFile = "$dir1\\version.txt"; print "$versionFile\n"; #Z:\My Documents\Workspace\version.txt my $dirA = "Z:/My Documents/Workspace"; #with / "" is no problem my $versionFileA = "$dirA/version.txt"; print "$versionFileA\n"; #Z:/My Documents/Workspace/version.txt
    Another tip for working with the command line, wild cards can be used like this: (not for use in a program, but for getting to where you want to go as a human without typing so much(
    C:\>cd do* C:\Documents and Settings>
      Thanks again Marshall :)