Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!udel!rochester!pt.cs.cmu.edu!o.gp.cs.cmu.edu!andrew.cmu.edu!bobg+ From: bobg+@andrew.cmu.edu (Robert Steven Glickstein) Newsgroups: comp.lang.perl Subject: Novice surprise Message-ID: Date: 11 Feb 91 21:54:07 GMT Organization: Information Technology Center, Carnegie Mellon, Pittsburgh, PA Lines: 47 Today I ran my very first Perl program; it was generated by a2p. The awk program was: BEGIN {x = 0} $0 == "" {x = 1} x == 1 The perl program produced was: eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_]+=)(.*)/ && shift; # process any FOO=bar switches $x = 0; while (<>) { chop; # strip record separator if ($_ eq '') { $x = 1; } print $_ if $x == 1; } The idea: skip the first lines of the input until a blank line is found, then start echoing the lines. The awk program worked fine, the perl program did not. I kept getting "cannot open file" errors. It was two hours of staring at this stupid thing before I realized that the problem was this: The filenames that I was passing as arguments happened to begin with a "+". Since I didn't have write-access, I got a "cannot open file" error. I couldn't figure out a way to circumvent this in Perl, so instead of the command-line perlscript +a +b +c I used perlscript ./+a ./+b ./+c The big question: What is the *right* way around this problem? ______________ _____________________________ Bob Glickstein | Internet: bobg@andrew.cmu.edu Information Technology Center | Bitnet: bobg%andrew@cmuccvma.bitnet Carnegie Mellon University | UUCP: ...!harvard!andrew.cmu.edu!bobg Pittsburgh, PA 15213-3890 | (412) 268-6743 | Sinners can repent, but stupid is forever