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

Hi,

I am learning the perl. During my very baby-walk coding, I kept getting this error:

BEGIN not safe after errors--compilation aborted at /System/Library/Perl/5.12/Carp/Heavy.pm line 4. Compilation failed in require at /Users/apple/Library/Application Support/TextMate/Managed/Bundles/Perl.tmbundle/Support/exception_handler.pm line 30.

My actual codes:

#!/usr/bin/perl

use strict;

use warnings;

my $pi = 3.141592654;

print "what is the radius?\n";

my ($radius)= ;

$radius = <STDIN>;

chomp $radius;

my ($circ) = 2* $pi * $radius;

print "the circumference of a circle of $radius is $circ.\n";

Thanks
  • Comment on very 1st question for my baby-walk coding

Replies are listed 'Best First'.
Re: very 1st question for my baby-walk coding
by LanX (Saint) on Apr 03, 2014 at 00:44 UTC
    my ($radius)= ; # empty assignment? :) delete the = $radius = <STDIN>;

    Cheers Rolf

    ( addicted to the Perl Programming Language)

Re: very 1st question for my baby-walk coding
by AnomalousMonk (Archbishop) on Apr 03, 2014 at 01:49 UTC
Re: very 1st question for my baby-walk coding (textmate)
by Anonymous Monk on Apr 03, 2014 at 00:38 UTC

    I suggest running your code from shell and not from textmate

    You have a choice, debugging textmate/Perl.tmbundle or your own perl code :)

    Running your code from shell is discussed in the following Behind the GUI lives the Shell and perlintro / perlrun

Re: very 1st question for my baby-walk coding
by Discipulus (Canon) on Apr 03, 2014 at 06:59 UTC
    sorry but is this unknown TextMate masking the error?
    And why it is reporting about Carp::Heavy?
    The empty assignement must be the error:

    C:\SCRIPTS>perl -e "use strict; use warnings; my ($a)=;" syntax error at -e line 1, near "=;" Execution of -e aborted due to compilation errors.

    L*
    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.