in reply to Updates problem with single quote

When I'm using the perl debugger and I want to make sure I can see exactly what is contained within a string, I do something like this:
p "==$string_variable=="
Any sort of whitespace at the edges of the string value (or anywhere within it) will be obvious that way, as well as any quotes or other stuff. The occurrence of an empty string comes across pretty clearly as well.

For that matter, you could improve your error message from the "die" call, to make it more likely for the real problem to be visible:

chdir($cmd) or die "chdir($cmd) failed: $!";
If you know that the parens should contain only a valid path string and nothing else, then putting the string into error message will make it possible to see whether the variable really contains what you intended (without having to use the perl debugger).

Replies are listed 'Best First'.
Re^2: Updates problem with single quote
by Sun751 (Beadle) on Jul 24, 2009 at 05:36 UTC
    Finally!!!! it was the space which was creating problem thanks guys below trick is helpful,
    p "==$string_variable=="
    now I change my ch_dir function to this,
    my ($cmd,$patch,$step) = @_; $cmd =~ s/\s*cd\s* //; chdir($cmd) || die
    Cheers!!!