in reply to Re: Use of uninitialized value when using regex
in thread Use of uninitialized value when using regex
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.
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(#!/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
C:\>cd do* C:\Documents and Settings>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Use of uninitialized value when using regex
by PerlScholar (Acolyte) on Sep 14, 2010 at 09:17 UTC |