in reply to Tk::Error: Can't call method "selectionGet" on unblessed reference at C:/Perl64/ site/lib/Tk/DirSelect.pm line 53. using TK::DirSelect

I don’t know if this applies to this case at all, or not, but that particular error-message just popped up for me today and I thought I’d briefly mention what it was.

Consider:

'use strict; use warnings; my $foo=[1,2]; foreach my $bar ($foo) { print "bar is $bar\n"}' bar is ARRAY(0x100804ed0)

versus ...

'use strict; use warnings; my $foo=[1,2]; foreach my $bar (@{$foo}) { print "bar is $bar\n"}' bar is 1 bar is 2

The only difference between the two code examples is that, in the second case, @{} has been used i the foreach statement, to tell Perl that it is an array-reference.   When this is done, Perl produces the behavior you probably intended:   it returns each of the elements in the referenced array.   Whereas, in the first example, it returns one thing ... the arrayref itself; the present value of $foo.

If (as was indeed the case in my actual code) the array in question was “a list of objects,” and you wanted to invoke a method against each of those objects, you could get this error.   An arrayref, after all, is not ... (heh) ... “any blessed thing.”