Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

have synax error in this coding?

by virudinesh (Acolyte)
on Dec 11, 2013 at 09:26 UTC ( #1066577=perlquestion: print w/ replies, xml ) Need Help??
virudinesh has asked for the wisdom of the Perl Monks concerning the following question:

STDIN is okay. But do you think this program will work? Did

you run this program and check? Still there are very basic syntax errors in your program and this program will not work. You could have found out if you have executed this code

coding for print 47
#!/usr/bin/perl use strict; use warnings; print "Enter a number:"; my $input = <STDIN>; chomp $input; if ( $input == 47 ); print "number is 47\n" else print " number does'not match . enter number again"

Comment on have synax error in this coding?
Download Code
Re: have synax error in this coding?
by choroba (Abbot) on Dec 11, 2013 at 09:33 UTC
    Read perlsyn - Perl Syntax on how to use if in Perl.
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      specifically  [doc://perlintro#if] if
Re: have synax error in this coding? (teacher already told you so)
by Anonymous Monk on Dec 11, 2013 at 09:35 UTC
Re: have synax error in this coding?
by Anonymous Monk on Dec 11, 2013 at 09:40 UTC
    Ok, a quote from perlintro#if
    if ( condition ) { ... } elsif ( other condition ) { ... } else { ... }
    So the things you're missing are curly braces (not square brackets, or round parenthesis/parens)
Re: have synax error in this coding?
by marto (Chancellor) on Dec 11, 2013 at 10:01 UTC

    So you took the code I gave you yesterday, broke it and didn't take the advice? Given your previous posts are more advanced than this does this mean that you simply did a copy and paste of code from elsewhere? If you are at all interested in learning the tool you've chosen to use, stop trying things at random, stop ignoring what Perl tells you, read the documentation: perlintro, tutorials, http://learn.perl.org.

Re: have synax error in this coding?
by marto (Chancellor) on Dec 11, 2013 at 10:35 UTC

    Actually:

    "you run this program and check? Still there are very basic syntax errors in your program and this program will not work. You could have found out if you have executed this code"

    Reads like feedback someone has given you when you submitted this homework task.

    Update: s/tasks/task/

Re: have synax error in this coding?
by taint (Chaplain) on Dec 11, 2013 at 15:08 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1066577]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2014-08-31 09:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls