Debug the Perl script

Source: Internet
Author: User
Tags perl script

-- Start

Perl is a very loose language. By default, we use an undefined variable or perform mathematical operations on a string and a number. It does not report any errors, so when we write a Perl script, we 'd better use one of the following methods for debugging.

#! /Usr/bin/perl # method 1 -- modify the sandband and add the-W option #! /Usr/bin/perl-W # method 2 -- add the warnings compilation command # Use warnings; # method 3 -- add the diagnostics compilation command to display details # Use diagnostics; $ num1 = "test"; $ num2 = 3; print ($ num1 * $ num2 );

The disadvantage of the above three methods is that after we debug the script, we must manually delete these Debugging commands, otherwise it will affect the performance. The following two methods provide great flexibility by adding command line parameters.

# Add the-W option and provide a simple error message Perl-W test. pl # Add the diagnostics compilation command and provide detailed error information Perl-mdiagnostics test. pl

 

-- For more information, see Perl.

--Shengming: reprinted, please indicate the source
-- Last updated on 2012-06-11
-- Written by shangbo on 2012-06-11
-- End

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.