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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Updates problem with single quote
by graff (Chancellor) on Jul 24, 2009 at 04:17 UTC
    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).
      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!!!
Re: Updates problem with single quote
by toolic (Bishop) on Jul 24, 2009 at 02:00 UTC
Re: Updates problem with single quote
by CountZero (Bishop) on Jul 24, 2009 at 04:40 UTC
    Did you spot the difference between:
    ' cd /and/updates'
    and
    "cd /and/updates"
    (and don't look at the single and double quotes!)

    You have an extra space character in the first string and your regex-substitution in ch_dir doesn't remove it.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re: Updates problem with single quote
by ikegami (Patriarch) on Jul 24, 2009 at 02:16 UTC

    Now I want to get rid of single quote "'" so I did $chdir_cmd =~ s/'/"/g;

    uh, while that does get rid of the single quote, it puts a double quote in its place

    A reply falls below the community's threshold of quality. You may see it by logging in.