X hits on this document

PDF document

Running and Debugging Perl - page 8 / 30

119 views

0 shares

0 downloads

0 comments

8 / 30

Chapter 9

To turn off or on certain classes of warnings, give them as a list after the use or no warnings. So, in this case, to just turn off the warning about qw but leave the others untouched, you would write:

#!/usr/bin/perl

  • #

    warntest4.plx

use warnings;

{

no warnings "qw"; my @a = qw(one , two , three , four); } my @b = qw(one , two , three , four);

The categories of warnings you can turn on and off are organized hierarchically as follows, and the warnings they cover are detailed in the perldiag documentation:

misc

internal

prototype

numeric

malloc

qw

all

First, we'll look at the variables. When use strict is applied, a variable must either be declared lexically (using my $var) and belong to a block or file, or be declared globally, to be available in every part of the program. You can do this either by using our $var (in the same way as my) or by specifying its full name, $main::var. We'll see where the main comes from in the next chapter.

Strict on Variables

once

overflow

pack

portable

recursion

redefine

regexp

severe

debugging

inplace

taint

unmask

uninitialized

unpack

untie

utf8

void

y2k

You should also know by now that use strict forces you to declare your variables before using them. In fact, it controls three areas of your programming: variables, references, and subroutines.

chmod

signal

use strict

reserved

semicolon

closure

substr

unopened

syntax

ambiguous

bareword

deprecated

digit

parenthesis

precedence

printf

pipe

newline

exec

exiting

glob

io

closed

286

Document info
Document views119
Page views119
Page last viewedMon Jan 23 07:12:26 UTC 2017
Pages30
Paragraphs723
Words10014

Comments