cannot open files with while (<>)

  • kac

    kac - 2010-03-06

    I'm running Ubuntu 9.10, Eclipse 3.5.1.
    I'm learning perl and I want to use eclipse as I worked as a java programmer for a few years and thats the IDE I know.

    If I run this simple program from the command line it works fine, but if I run it from within Eclipse I get

    Can't open *.pl: No such file or directory at /home/kieran/workspace/perldev/ line 10.
    Current directory is /home/kieran/workspace/perldev
    Regex is

    my run config has and args new *.pl

    as it runs from the command line ok I have to assume that this is a permissions issue perhaps?
    I hope you help as I want to get on and work my way through other exercises in my perl book.

    Heres my code, it looks for the word "new" in all perl programs in the current directory;

    my $regex = shift @ARGV;

    use Cwd;
    $dir = cwd();
    print "Current directory is ".$dir."\n";

    print "Regex is \n";
            print if m/$regex/;

  • Jan Ploski

    Jan Ploski - 2010-03-06

    EPIC, unlike the shell, doesn't do any wildcard expansion on the command line arguments. So what your program receives as the argument is a literal "*.pl" string, which is obviously not a correct file name.

  • kac

    kac - 2010-03-06

    Thanks jploski, I appreciate that,
    I'll just work out how to list all the *.pl files in the directory and do it that way instead.



Log in to post a comment.