For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > November 2004 > Why do I get Q









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Why do I get Q
Ian Pellew

2004-11-19, 8:57 pm

Hi All;

Why am I getting the perl -W complaint like:-
[Thu Nov 18 22:44:07 2004] w: Useless use of a constant in void
context at w line 208.
[Thu Nov 18 22:44:07 2004] w: Useless use of a constant in void
context at w line 397.
. . . . .

from the likes of :-
199: my $xml;
200: $xml = get_pg_dir() . . . . . .;
208: $db?print qq(Tags file = '$xml'\n):"";

I use $xml a lot later in the process.

Regards
Ian
Måns Rullgård

2004-11-19, 8:57 pm

ipellew@pipemedia.co.uk (Ian Pellew) writes:

> Hi All;
>
> Why am I getting the perl -W complaint like:-
> [Thu Nov 18 22:44:07 2004] w: Useless use of a constant in void
> context at w line 208.
> [Thu Nov 18 22:44:07 2004] w: Useless use of a constant in void
> context at w line 397.
> . . . . .
>
> from the likes of :-
> 199: my $xml;
> 200: $xml = get_pg_dir() . . . . . .;
> 208: $db?print qq(Tags file = '$xml'\n):"";


Line 208 could also be written as

if($db){
print qq(Tags file = '$xml'\n);
} else {
"";
}

Here, it should be rather obvious that the else block does nothing.
Maybe line 208 would be better off as

print qq(Tags file = '$xml'\n) if $db;

--
Måns Rullgård
mru@inprovide.com
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com