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

Re^2: Class / package weak association

by dd-b (Monk)
on Jun 10, 2021 at 21:40 UTC ( [id://11133748] : note . print w/replies, xml ) Need Help??

in reply to Re: Class / package weak association
in thread Class / package weak association

Possibly Dumper is the wrong tool here, yeah.

I looked at JSON and XML, and it looked to me like the overhead was unreasonable for this use, and that I had to use options that made the generated "standard" representation non-standard to do what I needed (which was to convey Perl objects that I created specifically for communicating between these two programs, between these two programs). And it's a pretty personal specialized application, I don't see it really ever being used outside my network. So this looked like the quickest and cleanest way to get it running, the big downside being that it's solidly perl-specific. Which doesn't bother me a bit.

I was looking for how to format the information (some header information followed by a list of filenames, repeated multiple times) and parse it to separate the "finding the files to display" function from the "generate the PDF showing the image thumbnails and some information" function, and I realized that inventing my own format was stupid and I should use something standard, but when I looked at the obvious "standard" choices they required generating and parsing code to get to what I needed, and I realized that Dumper didn't. In this limited use I'm not scared of evaling the input (which I produced myself and stored in a file in my own directory), and there's nothing approaching the complexity of circular references or anything, nor likely to ever be (just doesn't fit the data model).

Replies are listed 'Best First'.
Re^3: Class / package weak association
by hippo (Bishop) on Jun 11, 2021 at 10:25 UTC
    I looked at JSON and XML

    Those are good* formats for exchanging generic data with other applications - especially so when the other applications are not (necessarily) Perl.

    If you are intending to exchange data between only Perl applications then something like Storable (or Sereal) might be more appropriate.

    * for some definitions of "good" ;-)