Hi Shaji,
On Wed, May 29, 2013 at 4:19 AM, *Shaji Kalidasan* <[email protected]>wrote:
> Greetings,
>
> Where can I get more information on Perl's most common error codes? Is
> there a single source (repository/resource) for such most frequently
> encountered error codes?
>
> [code-1]
> use strict;
> use warnings;
>
> my @names = qw/bat, ball, %&!*, king, (^@), eagle, zebra/;
>
with "qw", you don't use a 'comma' to separate the element of the array.
Because, the element are separated by space.
So, the correct thing to do is:
my @names = qw/bat ball %&!* king (^@) eagle zebra/;
> foreach (@names) {
> print "$_\n" if /\w/;
> }
> [/code-1]
>
> [output-1]
> Possible attempt to separate words with commas at C:/Users/shaji
> kalidasan/workspace/juno-sr1/shaji/Shaji Code Snippets/hari.pl line 4.
> bat,
> ball,
> king,
> eagle,
> zebra
> [/output-1]
>
> [code-2]
> use strict;
> use warnings;
>
> my @names = qw/orange apple %&!*# banana (^@) grapes mango/;
>
Also, with "qw", you can't use '#', the use warnings gives a warning that
the string contain '#'.
So, to use your expression, you can do like so:
my @names = split/\s/, q/orange apple %&!*# banana (^@) grapes mango/;
> foreach (@names) {
> print "$_\n" if /\w/;
> }
> [/code-2]
>
> [output-2]
> orange
> apple
> banana
> grapes
> mango
> Possible attempt to put comments in qw() list at C:/Users/shaji
> kalidasan/workspace/juno-sr1/shaji/Shaji Code Snippets/hari.pl line 4.
> [/output-2]
>
> So considering these two programs mentioned above, I am getting the
> following warning messages
>
> 1) Possible attempt to separate words with commas at C:/Users/shaji
> kalidasan/workspace/juno-sr1/shaji/Shaji Code Snippets/hari.pl line 4.
>
> 2) Possible attempt to put comments in qw() list at C:/Users/shaji
> kalidasan/workspace/juno-sr1/shaji/Shaji Code Snippets/hari.pl line 4.
>
> Please suggest some pointers or resources for this type of frequently
> encountered error codes/warnings and its possible meanings.
>
In fact, if you do 'perldoc -f qw' from the Command Line Interface, the
last paragraph says:
A *common* mistake is to try to *separate the words with
comma*
or *to put comments into a multi-line "qw"-string*. For
this
reason, the "use warnings" pragma and the --ww switch
(that
is, the $^W variable) produces warnings if the STRING
contains the "," or the "#" character.
Hope this helps