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

Compile error for the perl code

by unnik (Initiate)
on Dec 17, 2007 at 05:32 UTC ( #657372=perlquestion: print w/ replies, xml ) Need Help??
unnik has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,
I am getting the following compile error
-----------------------------------------------
Bareword found where operator expected at do-bld3.pl line
2045, near "if ( $me3400(1) eq /cp"
(Might be a runaway multi-line // string starting on line 2000) (Do you need to predeclare if?)
Backslash found where operator expected at do-bld3.pl line 2045, near "mz \" (Do you need to predeclare mz?)
syntax error at do-bld3.pl line 2045, near "if ( $me3400(1) eq /cp me340x"
syntax error at do-bld3.pl line 2052, near "} else"
syntax error at do-bld3.pl line 2063, near "}"
--------------------------------------------------
Its showing for below piece of code..can u please help in debug.
======= if ($s1 == "j") {
$log = "\/users\/$u\/me3400-log.txt";
open(FILE, $log) || die "cud not read $log";
while(<FILE>) {
if ( $me3400(1) == /cp me340x-metrobase-mz \/tftpboot\/$u\/me340x-metrobase-mz/ )
{
open(OUTFILE,">>$of1") || die "cud not write";
print OUTFILE "me340x-metrobase-mz\n";
close(OUTFILE);
return;
} else {
open(OUTFILE,">>$of2") || die "cud not write";
print OUTFILE "me340x-metrobase-mz\n";
close(OUTFILE); return;
} } #end of while for me3400 log
} ### end of if if ($s1 == "j")
thanks
Unni

Comment on Compile error for the perl code
Re: Compile error for the perl code
by jonnyfolk (Vicar) on Dec 17, 2007 at 06:02 UTC

    The errors are mostly found for you in the error messages. One thing to note is that you are using the numerical operator == rather than eq.

    I'm not sure what

    if ( $me3400(1) == /cp me340x-metrobase-mz \/tftpboot\/$u\/me340x-metr +obase-mz/ ) {
    means but you would probably be better off with something like:
    if ( $me3400(1) eq "cp me340x-metrobase-mz /tftpboot/$u/me340x-metroba +se-mz" ) {
Re: Compile error for the perl code
by Thilosophy (Curate) on Dec 17, 2007 at 06:09 UTC
    Might be a runaway multi-line // string starting on line 2000)

    Do you have an (accidental) multi-line string starting at line 2000 ?

    if ( $me3400(1) == /cp me340x-metrobase-mz \/tftpboot\/$u\/me340x-metr +obase-mz/ )

    Not sure what this means, but you probably want to use the regex matching operator =~ rather than the numerical ==.

    What is $me3400(1) (I don't even get the syntax)?

    Since you are looping over a file line by line, is this supposed to be a comparison for the current line?

Re: Compile error for the perl code
by apl (Monsignor) on Dec 17, 2007 at 10:56 UTC
    BTW, good form when posting is to use the <code> and </code> tags around your Perl.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2014-08-29 02:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (275 votes), past polls