Data::...ecoder(3pm)

πŸ“¦
version 0.021 Β· 3 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– Data::TableReader::Decoder β€” the 3pm man page, bestie edition πŸ’–

Okay so you found your way to Data::TableReader::Decoder(3pm), which lives in the User Contributed Perl Documentation corner of the perl universe. Pull up a chair, grab a strawberry πŸ“, and let's get into it.


✨ NAME ✨

Data::TableReader::Decoder β€” it's the base class for table decoders πŸ‘‘


🌸 VERSION 🌸

version 0.021 β€” yes, that's the one, no cap.


πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the tea. This is an abstract base class, which is fancy-speak for "it describes the API, it does not do the actual work, that's on the subclasses, bestie." It's giving blueprint energy. πŸ“

A decoder's whole job β€” its one job, its main character moment β€” is to iterate table rows of a file that's holding tabular data. That's it. That's the assignment.

And here's the important part: if a file hands you multiple tables of data (think worksheets, or <TABLE> tags πŸ‘€), then the decoder should also support the next_dataset method. Multiple tables means multiple datasets means multiple moments, and the decoder has to be ready for all of them. πŸ’…


πŸŽ€ ATTRIBUTES πŸŽ€

filename

Set by TableReader. Useful for logging. That's literally it, and honestly? A queen. πŸ“βœ¨

file_handle

Set by TableReader. This is what the iterator should parse. Like, the actual thing the iterator reads from. Don't sleep on it. πŸ”₯


πŸ’œ METHODS πŸ’œ

iterator

Okay so this one is a must β€” it must be implemented by the subclass, no skipping, no shortcuts, periodt. πŸ™…

It returns an instance of Data::TableReader::Iterator.

Now here's the vibe: the iterator should return an arrayref every single time it gets called. And it should accept one optional argument β€” a slice that's needed from the record. 🍰

And why does that matter? Because all decoder iterators return arrayrefs, so that slice should be an arrayref of column indices, equivalent to this exact perl syntax right here:

@row[@$slice]

Copy it, love it, use it. πŸ’–


🌈 AUTHOR 🌈

Michael Conrad <mike@nrdvana.net> β€” iconic behavior, honestly. 🫢


This software is copyright (c) 2024 by Michael Conrad.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Slay. πŸ’…


And that's the whole page, bestie β€” no notes. This was Data::...ecoder(3pm) from perl v5.38.2, dated 2024-06-21. Mwah, take care of yourself, hydrate, and go iterate some rows. πŸ§šπŸ’œπŸŒˆ

πŸ“¦ where this page comes from