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

foreach $artefact (@objects) { $artefact=~ s/.bar//; print "artefact to be deployed is $artefact\n"; my $file = "C:/abc/def/klm/Properties/$artefact.properties"; open my $input_fh, '<', $file or die "failed to open '$file' +$!";
I get a error - failed to open 'C:/abc/def/klm/Properties/VerifyAccountId entity_Response .properties' Invalid argument at SIT_deploy.pl line 21, <INPUT> line 3. Could anyone please help me in fixing this error?

Replies are listed 'Best First'.
Re: Error while trying to open a file
by k_manimuthu (Monk) on Jan 05, 2011 at 04:11 UTC

    Check the file is exists or not.

    $file='File Path'; print "\nFile $file ", (-e $file && -f $file ) ? "exists" : "doesn't e +xists";

    Get the OS error by using of $!

    open (FILEHANDELER,"FILEPATH") || die "Cannot open the input file : $! +";

    And check the file permission

      The file exists and it has read and write permission too. If i replace $artefact with the name of the file it works.
Re: Error while trying to open a file
by Anonymous Monk on Jan 05, 2011 at 04:03 UTC
    Could anyone please help me in fixing this error?

    Don't feed junk to open?

    $ perl -Mautodie -e"open my$in, q!<!, q!echo|! " Can't open 'echo|' for reading: 'Invalid argument' at -e line 1
    on my operating system, filenames cannot contain |
Re: Error while trying to open a file
by samarzone (Pilgrim) on Jan 05, 2011 at 09:41 UTC

    Did you notice that you have a space just before ".properties" in your file name?

    --
    Regards
    - Samar
      It was a typo when i posted it.
A reply falls below the community's threshold of quality. You may see it by logging in.