Catman..._string(3pm)

๐Ÿ“ฆ
version 1.2025 ยท 4 versions
, in ubuntu resolute, ubuntu stonking

๐Ÿ’– NAME ๐Ÿ’–

Catmandu::Fix::import_from_string โ€” bestie, this one slurps data out of a string and drops it into an array ref, using an importer you name yourself. It's giving "glow up your string into actual data" energy. โœจ


๐ŸŒธ SYNOPSIS ๐ŸŒธ

Okay so watch the glow-up happen in real time:

#BEFORE: { 'json' => '[{"name":"Nicolas"}]' }
#AFTER:  { 'json' => [{"name":"Nicolas"}] }

import_from_string('json','JSON')

Look at that โ€” a string walked in and an array of hashes walked out. ๐Ÿ’…

#BEFORE: { record => qq(first_name;name\nNicolas;Franck\nPatrick;Hochstenbach\n) }
#AFTER:  { record => [{ "first_name" => "Nicolas",name => "Franck" },{ "first_name" => "Patrick",name => "Hochstenbach" }] }

import_from_string('record','CSV', 'sep_char' => ';')

And yes, you can pass extra options through, like 'sep_char' => ';' up there โ€” the importer gets them. ๐ŸŽ€


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

โœจ import_from_string( PATH, NAME [, IMPORT_OPTIONS ] ) โœจ

This fix calls the function import_from_string from the package Catmandu, but plot twist: you have to hand it the NAME of the importer. It can't guess. It's not psychic, bestie. ๐Ÿ”ฎ

And here's the thing you can always count on: it always returns an array of hashes. No cap, no exceptions, just hashes in an array. Periodt. ๐Ÿ‘‘

๐ŸŒˆ PATH

(That's the one โ€” the path. That's it, that's the entry.) ๐Ÿ˜Œ

๐ŸŒˆ NAME

This is the name of the importer to use. As usual in Catmandu, you've got options, and you can choose:

  • the full package name of the importer (e.g. 'Catmandu::Importer::JSON')
  • the short package name of the importer (e.g. 'JSON')
  • the name of the importer as declared in the Catmandu configuration

Pick your fighter, they all slay. ๐Ÿซถ

๐ŸŒˆ IMPORT_OPTIONS

Extra options for the named importer โ€” pass whatever that importer needs, it's all vibes and parameters. โœจ


๐ŸŽ€ AUTHOR ๐ŸŽ€

Nicolas Franck, "<nicolas.franck at ugent.be>" โ€” iconic, we love an author credit. ๐Ÿ’–


๐ŸŒŸ SEE ALSO ๐ŸŒŸ

  • Catmandu::Fix
  • Catmandu::Importer

Go read those next, bestie, they're the supporting cast. ๐Ÿฆ‹


And that's the whole page, mwah ๐Ÿ’‹ โ€” this lil manual came to you courtesy of perl v5.40.1, dated 2026-01-24, filed under that Catman..._string(3pm) title up top (iykyk, the header got truncated, not my fault, I don't make the rules ๐Ÿซ ). Stay hydrated, stay importing. ๐ŸŒธโœจ

๐Ÿ“ฆ where this page comes from