in reply to Re^2: Creating a new file in a directory
in thread Creating a new file in a directory

chomp does not remove all whitespace from the end of a string. I recommend that you be more explicit and use:

$mycrdir =~ s!\s*$!!;

Also, what is the error message your OS gives you in $! when creating the file fails?

Replies are listed 'Best First'.
Re^4: Creating a new file in a directory
by parthodas (Acolyte) on Aug 21, 2015 at 07:47 UTC
    Getting this error, when running the script --
    Please enter your selection : 1
    Please enter the CR# :117365
    CR num is 117365

    File type confirmation for CR 117365..........

    Cannot open D:\SiebelAdmin\CR_Files\CR117365_20150821_0045
    /file_detail.txt: Invalid argument

    D:\SiebelAdmin\Operations>pause
    Press any key to continue . . .

      Yes, that means you have a newline in $mycrdir. This is because you read $mycrdir from the user and that readline includes the final newline as entered by the user. You could have shown this part of your code as well to make it more obvious that $mycrdir is read from the outside.

Re^4: Creating a new file in a directory
by parthodas (Acolyte) on Aug 21, 2015 at 07:56 UTC
    That helped a lot. Thanks a lot. Issue is resolved. The variable was a input which was used in different section. Hence, it was not included.
Re^4: Creating a new file in a directory
by parthodas (Acolyte) on Aug 21, 2015 at 07:51 UTC
    The error message is as below
    Please enter your selection : 1 Please enter the CR# :117365 CR num is 117365 File type confirmation for CR 117365.......... Cannot open D:\SiebelAdmin\CR_Files\CR117365_20150821_0045 /file_detail.txt: Invalid argument D:\SiebelAdmin\Operations>pause Press any key to continue . . .