Data::...amples(3pm)

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

πŸ’– Data::Fake::Examples β€” the perl manual, but make it cute πŸ’–

okay bestie, gather round, because this is the manual page for Data::Fake::Examples (that's the 3pm perl doc situation, yes we read those, we're cultured like that) and it's literally just a little scrapbook of how do i actually put these fake-data generators together 🧚✨


🌸 NAME 🌸

Data::Fake::Examples β€” Examples of combining Data::Fake generators

like, not the generators themselves, bestie. the combos. the remixes. the collabs. πŸŽ€


✨ VERSION ✨

version 0.006

tiny number, big energy πŸ’…


πŸ”₯ EXAMPLES πŸ”₯

okay so the author says, and i quote the vibe here: I plan to add additional examples here over time. Contributions are welcome.

which is literally the politest way to say "this page is a work in progress and your pull requests are iconic" 🫢 so if you have a cute generator mashup, send it in.

🌈 URLs 🌈

the goal here is fake URLs that look like this:

# http://example.com/
# https://www.example.com/
# http://www23.example.com/

look at those. so normal. so plausible. nobody would ever suspect a thing 😭

here's the whole flex:

use Data::Fake qw/Core Internet/;

my $fake_url = fake_template(
    "%s://%s%s/",
    fake_pick(qw(http https)),
    fake_pick( "", "www.", fake_digits("www##.") ),
    fake_domain(),
);

the way this works is chef's kiss: fake_template takes a format string "%s://%s%s/" and then you just feed it generators in order, one per %s. so slot one gets a scheme from fake_pick(qw(http https)), slot two gets either nothing, or "www.", or a fake_digits("www##.") situation (that's www plus two digits plus a dot, so like www23.), and slot three gets a fake_domain(). and boom. a whole fake URL, no cap. πŸ”₯

reminder bestie: you gotta pull in the right generators, hence the use Data::Fake qw/Core Internet/; up top. Core and Internet are the flavour packs here. πŸ’œ

πŸ‘‘ AUTHOR πŸ‘‘

David Golden <dagolden@cpan.org>

the icon. the legend. the moment. πŸ’…


This software is Copyright (c) 2015 by David Golden.

This is free software, licensed under:

The Apache License, Version 2.0, January 2004

free as in free, bestie. go wild, but read the license, fr fr. πŸ“œβœ¨


and that's the whole page, no notes πŸ¦‹ this doc came to you courtesy of perl v5.38.2, dated 2024-07-24, so if you're reading this from the future, hi, hope the fake URLs still slay πŸ’– stay hydrated, format your templates carefully, and remember: every %s needs a generator or it's giving chaos 🌸 periodt ✨

πŸ“¦ where this page comes from