Howdy! > Hi! > > Just noticed some strange behaviour, and wonder if it's a bug in MacPerl, > or in my program. I'd suspect the latter... > > #! perl -w > > use strict; > > package Bug; > > sub new { > my $class = ref $_[0] || $_[0]; > print $class . " is born ...\n"; > bless {}, $class; > } > > sub DESTROY { > print "Arggh! " . ref shift() . " is killed!\n"; putting in the parentheses implied, what you have is: print("Arggh! " . ref(shift() . " is killed!\n")); but you were expecting it to mean: print("Arggh! " . ref(shift()). " is killed!\n"); you also could have tried: print "Arggh! " , ref shift() , " is killed!\n"; > } > > package main; > > my $a = Bug->new(); > > __END__ > > prints: > > Bug is born ... > Arggh! > > and not the rest of the sentence. Changing the DESTROY sub to > > sub DESTROY { > print "Arggh! " . ref shift(); > print " is killed!\n"; > } > > gives the expected result. > > Any ideas? > You appear to have been unclear on precedence of operators and all that. Your change to the DESTROY sub was a step in the right direction. You probably would be best off to use the commas to separate the pieces being printed instead of explicitly concatenating them with dot. yours, Michael -- Michael and MJ Houghton | Herveus d'Ormonde and Megan O'Donnelly herveus@radix.net | White Wolf and the Phoenix Bowie, MD, USA | Tablet and Inkle bands, and other stuff | http://www.radix.net/~herveus/ # ===== Want to unsubscribe from this list? # ===== Send mail with body "unsubscribe" to macperl-request@macperl.org