Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: what type of datastructure is this

by LanX (Saint)
on Oct 07, 2018 at 21:29 UTC ( [id://1223646]=note: print w/replies, xml ) Need Help??


in reply to what type of dsc is this

> My best guess is an array of blessed hashes

Well yes, an array of 3 different widget objects of class Gtk2::Window.

Data::Dumper is trying to represent the input as a string, which can be reversed by evaling it again. (quote: "stringified perl data structures, suitable for both printing and eval" )

Since the name of an object constructor is not fixed in Perl("->new" is only a convention) using bless is the most accurate way to do it.

edit

I just checked there is indeed a new constructor for Gtk2::Window :

http://gtk2-perl.sourceforge.net/doc/pod/Gtk2/Window.html#widget_Gtk2_Window_n

So it might be possible to represent the same information with

$VAR1 = [ Gtk2::Window->new(), Gtk2::Window->new(), Gtk2::Window->new() ]

but to be sure me as a human would need to look up the implementation. Data::Dumper as a piece of code can't do this.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

update

PS: Not sure what you meant with DSC, in perldsc this stands for Data Structure Cookbook..

Replies are listed 'Best First'.
Re^2: what type of datastructure is this
by swl (Parson) on Oct 08, 2018 at 00:31 UTC

    Further to LanX's comments, Data::Dumper knows about the data but not the code that generated it, hence the bless calls instead of method calls to new. This is the simplest way of recreating blessed objects after serialisation.

    I assume that the reason there is nothing inside the hashes is that the Gtk2 objects are external data that cannot be accessed by Data::Dumper (or the debugger). Such empty hashes are safer for serialisation and later reconstruction. I've hit issues in the distant past with Gtk objects reconstructed from Storable files. These caused segmentation faults when accessed, presumably because the contents no longer exist at the stored address. Needless to say I don't store references to the Gtk objects in the structures that are to be serialised.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1223646]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-23 20:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found