.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Env::ShellWords 3" .TH Env::ShellWords 3 2024-09-01 "perl v5.40.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Env::ShellWords \- Environment variables for arguments as array .SH VERSION .IX Header "VERSION" version 0.02 .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 4 \& # Tie Interface \& use Env::ShellWords; \& tie my @CFLAGS, \*(AqEnv::ShellWords\*(Aq, \*(AqCFLAGS\*(Aq; \& tie my @LDFLAGS, \*(AqEnv::ShellWords\*(Aq, \*(AqLDFLAGS\*(Aq; \& \& # same thing with import interface: \& use Env::ShellWords qw( @CFLAGS @LDFLAGS ); \& \& # usage: \& $ENV{CFLAGS} = \*(Aq\-DBAR=1\*(Aq; \& unshift @CFLAGS, \*(Aq\-I/foo/include\*(Aq; \& push @CFLAGS, \*(Aq\-DFOO=Define With Spaces\*(Aq; \& \& # now: \& # $ENV{CFLAGS} = \*(Aq\-I/foo/include \-DBAR=1 \-DFOO=Define\e\e With\e\e Spaces\*(Aq; \& \& unshift @LDFLAGS, \*(Aq\-L/foo/lib\*(Aq; \& push @LDFLAGS, \*(Aq\-lfoo\*(Aq; .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" This module provides an array like interface to environment variables that contain flags. For example Autoconf can uses the environment variables like \f(CW\*(C`CFLAGS\*(C'\fR or \f(CW\*(C`LDFLAGS\*(C'\fR, and this allows you to manipulate those variables without doing space quoting and other messy mucky stuff. .PP The intent is to use this from alienfile to deal with hierarchical prerequisites. .PP You can provide split and join callbacks when you tie: .PP .Vb 5 \& use Env::ShellWords; \& # split on any space, ignore quotes \& tie my @FOO, \*(AqEnv::ShellWords\*(Aq, \& sub { split /\es+/, $_[0] }, \& sub { join \*(Aq \*(Aq, @_ }; .Ve .PP Which may be useful if you have to split on words on an operating system with a different specification. .SH CAVEATS .IX Header "CAVEATS" Not especially fast. \f(CW\*(C`undef\*(C'\fR gets mapped to the empty string \f(CW\*(Aq\*(Aq\fR since \f(CW\*(C`undef\*(C'\fR doesn't have a meaning as an argument in a string. .PP Writing to an environment variable using this interface is inherently lossy. .SH "SEE ALSO" .IX Header "SEE ALSO" Env .SH AUTHOR .IX Header "AUTHOR" Graham Ollis .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2017 by Graham Ollis. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.