beginner

L

luc

This program runs perfect when i execute it in dos in the perl directory.
But when i run it in a perl editor(perlide) it does nothing. Does anybody
know why?

print "Please tell me your name: ";
$name=<STDIN>;
chop $name
print "Thanks for making me happy, $name !\n"
 
G

gnari

luc said:
This program runs perfect when i execute it in dos in the perl directory.
But when i run it in a perl editor(perlide) it does nothing. Does anybody
know why?

you should select a meaningful Subject line for your message.
print "Please tell me your name: ";
$name=<STDIN>;
chop $name
print "Thanks for making me happy, $name !\n"

I do not believe thet this program runs perfect from the command line,
because it has syntax errors. please do not retype your programs, but
use cut and paste. then we can spend more time on solving the
real problem.

I am not familiar with your editor, but does your (corrected) program
work without STDIN input ? does it work if you add "\n" to the first
print statement?

gnari
 
S

Stefan

luc said:
This program runs perfect when i execute it in dos in the perl directory.
But when i run it in a perl editor(perlide) it does nothing. Does anybody
know why?

print "Please tell me your name: ";
$name=<STDIN>;
chop $name
print "Thanks for making me happy, $name !\n"


Never heard of "perlide" but generally speaking, you could try to disable
buffering. Also use chomp() in stead of chop() and finally, always (and I
really mean *always*) use strict ! Did you copy-paste the code or re-type
it 'cause there was a missing ; in the chop $name and print "..." lines.

So the improved code is something like this;

#!/usr/local/bin/perl -w # just a habbit ;)
use strict; # always use this - check the
documentation for the details
use warnings; # optional and the same as perl -w
$| = 1; # disable buffering
print "Please tell me your name: ";
my $name=<STDIN>; # must use my() because of use strict;
chomp $name; # chomp() only removes \n when necessary
print "Thanks for making me happy, $name !\n";

This looks like one of your 1st scripts. Just keep going and don't forget to
read (or at least scan) the FAQs of both Perl and Perlide.

Good luck,
Stefan
 
E

Exide Arabellan

luc said:
This program runs perfect when i execute it in dos in the perl directory.
But when i run it in a perl editor(perlide) it does nothing. Does anybody
know why?

print "Please tell me your name: ";
$name=<STDIN>;
chop $name
print "Thanks for making me happy, $name !\n"

Definately take into account what the others have said (subject line,
use strict, copy and paste, and check the documentation often).

Since the program works from the command line in the perl directory, im
assuming it to be a problem with your PATH. I only use my Win32 box for
gaming, and have (maybe purposefully) blocked how to set such things
over the years :) Do a www.google.com search for setting your path in
whatever OS you're using.

Exide Arabellan
www.arabellan.com
 
S

Stuart Moore

luc said:
This program runs perfect when i execute it in dos in the perl directory.
But when i run it in a perl editor(perlide) it does nothing. Does anybody
know why?

The thought occurs that the perl editor in question may do strange
things with STDIN which'd mean you couldn't get it to work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
EmeliaBryc

Latest Threads

Top