Monday, October 29, 2012


How to write perl shell.

[root@manas ~]cat /tmp/perl_shell
#!/usr/bin/perl

my($output);
do {
    $output = eval;
    if($output =~ /^\s*$/) {
        print "\n$@";
    }
    else {
        print "\n$output";
    }
    print "\nperl_shell>";
} while(<>);


Now you can use perl shell like following :
perl_shell>print "Mandar Pande is a rich man ! "
Mandar Pande is a rich man !

perl_shell>print rand(100)
27.8423844211833

perl_shell>print sqrt(16);
4

2 comments: