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

Hi,
I have the following script which is running fine when I execute it from Enginsite Perl Editor Lite. But when I execute it from command prompt I am getting following error:

D:\New Folder>perl test2.pl
Cannot open c:/double_click.db for writing:Invalid argument
Script is:
#!/usr/bin/perl use strict; use warnings; use diagnostics; my $dc_db_file = 'c:/double_click.db'; if (!open(DC_DB, " > $dc_db_file")) { die "Cannot open $dc_db_file for + writing:$!\n"; } close DC_DB;
If I remove the space before file mode operator its working fine even from command prompt. can anybody tell me whats happening.I use active state perl 5.005_03 built for MSWIN32-x86
Thanks
Kamesh

Replies are listed 'Best First'.
Re: Problem with command prompt execution
by japhy (Canon) on Mar 17, 2005 at 06:41 UTC
    "Doctor, it hurts when I do this."

    "So don't do that."

    Seriously, though, the space before the file mode is what's breaking it. Remove that space. Or use the three-arg version of open().

    open(DC_DB, ">", $dc_db_file) or die ...;
    _____________________________________________________
    Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
    How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart