in reply to overloading ">>" generates warning?
That warning is generated at compile-time, and is correct for non-overloaded invocants (>> returns a new value, and doesn't modify its parameters), so I'd say the behaviour is expected, but annoying in this case.
You can disable the warning by using
no warnings 'void';
By the way, stringification gives you the same warning in similar cicumstances:
#!/usr/bin/perl -w use strict; my $foo = Foo->new; "$foo"; package Foo; use strict; use overload '""' => 'stringy'; sub new {bless {}, __PACKAGE__} sub stringy { print "OK!\n"}
Useless use of string in void context at test.pl line 4. OK!
|
|---|