CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [PerlUser12] Meaning of -w and qw: Edit Log



Laurent_R
Veteran / Moderator

Oct 27, 2012, 7:34 AM


Views: 2519
Re: [PerlUser12] Meaning of -w and qw

Hi,

The -w enables warnings, which is a very good thing to do because it point you to errors in your program, except that this is a slightly outdated (and somewhat deprecated) way of enabling the warnings. Nowodays, the best way to do it is to use the following pragma:


Code
use warnings;


The qw (quote words) statement is synctatic sugar to define an array of strings.


Code
@array = qw/foo bar . . ./;

or

Code
@array = qw(foo bar . . .);


is the same as

Code
@array = (’foo’, ’bar’,. . .).


Basically, you avoid having to type the single quotes and the commas. There is nothing more to it.

EDIT: Fishmonger was faster than me. ;-)


(This post was edited by Laurent_R on Oct 27, 2012, 7:37 AM)


Edit Log:
Post edited by Laurent_R (Veteran) on Oct 27, 2012, 7:37 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives