Env::ShellWords(3)
π Env::ShellWords π
okay bestie, so this is Env::ShellWords, a lil Perl module from the User Contributed Perl Documentation corner of the universe, and it is literally about giving environment variables an array glow-up. no cap.
β¨ NAME β¨
Env::ShellWords β environment variables for arguments as array π«Ά
like. that's the whole thing. env vars, but you get to treat them like a cute lil array instead of one long string you have to squint at. iconic behaviour honestly.
πΈ VERSION πΈ
version 0.02 π
π SYNOPSIS π
here's the vibe, watch this:
# Tie Interface
use Env::ShellWords;
tie my @CFLAGS, 'Env::ShellWords', 'CFLAGS';
tie my @LDFLAGS, 'Env::ShellWords', 'LDFLAGS';
# same thing with import interface:
use Env::ShellWords qw( @CFLAGS @LDFLAGS );
# usage:
$ENV{CFLAGS} = '-DBAR=1';
unshift @CFLAGS, '-I/foo/include';
push @CFLAGS, '-DFOO=Define With Spaces';
# now:
# $ENV{CFLAGS} = '-I/foo/include -DBAR=1 -DFOO=Define\\ With\\ Spaces';
unshift @LDFLAGS, '-L/foo/lib';
push @LDFLAGS, '-lfoo';
okay so like. you tie a plain old array to an environment variable and suddenly push and unshift on it are β¨talking to the envβ¨. the quoting? handled. the mess? not your problem anymore. main character energy fr fr. π₯
π¦ DESCRIPTION π¦
so this module gives you an array-like interface to environment variables that hold flags. think about Autoconf β it uses env variables like CFLAGS or LDFLAGS, and this lets you poke at those variables without doing space quoting and other messy mucky stuff. no more doing escape-character gymnastics at 2am, bestie, we're done with that π
the intent here is to use this from alienfile to deal with hierarchical prerequisites. iykyk.
you can also hand it your own split and join callbacks when you tie, if you're feeling custom:
use Env::ShellWords;
# split on any space, ignore quotes
tie my @FOO, 'Env::ShellWords',
sub { split /\s+/, $_[0] },
sub { join ' ', @_ };
which may be useful if you have to split on words on an operating system with a different specification. π so valid, honestly.
β οΈ CAVEATS β οΈ
- not especially fast. it's giving "does the job, doesn't sprint". π
undefgets mapped to the empty string''β becauseundefdoesn't have a meaning as an argument in a string. so it just becomes nothing. humble of it.- > writing to an environment variable using this interface is inherently lossy. π like, information will get lost in the round trip. that's not a bug bestie that's just how the format works. be aware!!
π SEE ALSO π
Env
π AUTHOR π
Graham Ollis <plicease@cpan.org> β king behaviour, honestly.
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2017 by Graham Ollis.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
and that's the whole page, bestie β perl v5.42.0, dated 2025-07-25, and it's Env::ShellWords(3) signing off. slay, stay quoted, and remember: escape characters are a love language π
β¨π
π¦ where this page comes from
- fedora 43: perl-Env-ShellWords 0.02-24.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms