Re: Question from perl newbie



Roy Jaffray wrote:
am a newbie as well .. with exactly the same problem.

I have a file called "helloworld.pl". When it wouldnt put out any
output using <stdin> I decided to try to create and open a file and
write to that.
____helloworld.pl________________________________

You are missing
use strict;
use warnings;

open(geo,">perltest.txt") or die ("Cannot Open perltest.txt");

It would be better to include the reason why the open failed.
.... or die ("Cannot Open perltest.txt because $!");

for ($loop_index =1; $loop_index <=5; $loop_index++)

What's wrong with
for $loop_index (1..5)
Much easier to read

{
Print geo "hello world!\n"

Where to you define the funtion Print()?

}
Print "there!\n\n\n"

Where do you define the function Print()?

close (geo);
print "Press <enter> to continue" ;
<stdin>;
_____________________________________________
I then double clicked on the name and got the dos flicker .. but no
file was created.

Well, yeah, sure. Why don't you fix that syntax error that perl is telling
you about?

String found where operator expected at C:\tmp\t.pl line 8, near "Print
"there!\
n\n\n""
(Do you need to predeclare Print?)
syntax error at C:\tmp\t.pl line 8, near "Print "there!\n\n\n""
Execution of C:\tmp\t.pl aborted due to compilation errors.

so problem continues ... (new computer Windows XP .. and newly
downloaded ActivePerl seemingly sucessfully installed. )

Irrelevant. Your Perl code has a syntax error. Of course it doesn't produce
anything because it never even passed the syntax check.

jue


.



Relevant Pages

  • Re: potential problem with fork()
    ... > I m not sure whether the following Perl code is correct with fork(). ... Syntax error, unbalanced parens. ...
    (comp.lang.perl.misc)
  • Inserting perl code into a file
    ... I'm trying to insert some perl code into another file. ... print FILE $code; ... It just says syntax error at the end of the file. ... Gary Mayor ...
    (comp.lang.perl.misc)
  • Re: using python with -c (as a inline execution in shell)
    ... > but suppose I want to read from the stdin i don't know how to do this since ... > gives a syntax error. ... If you really must do this, there's always PyOne: ... Wouldn't touch it with a bargepole, ...
    (comp.lang.python)