Lhamo_rin has asked for the wisdom of the Perl Monks concerning the following question:

Can someone tell me why the following code would give me a syntax error on the Label line?
sub open_file { my $success = open RF, "/bin/.saved_points" unless ($succeed) { my $fail = MainWindow->new(): $fail->Label(-text => "File Failed to open")-> pack(); } }

Replies are listed 'Best First'.
Re: (unless) usage
by particle (Vicar) on Jun 30, 2003 at 13:14 UTC
    my $success = open RF, "/bin/.saved_points"; ## missing semi-colon

    also, you set success, but check succeed in the next line. are you using warnings? or strict? it might help.

    ~Particle *accelerates*

Re: (unless) usage
by broquaint (Abbot) on Jun 30, 2003 at 13:15 UTC
    You're missing a semi-colon on the 2nd line
    my $success = open RF, "/bin/.saved_points" <-- needs a semi-colon
    Also the 4th line has a colon instead of a semi-colon
    my $fail = MainWindow->new(): <-- should be a ;

    HTH

    _________
    broquaint

Re: (unless) usage
by Zaxo (Archbishop) on Jun 30, 2003 at 14:42 UTC

    Also, you have a colon where you want a semicolon in line 5:

    my $fail = MainWindow->new(); # ^

    After Compline,
    Zaxo