1Env::ShellWords(3) User Contributed Perl Documentation Env::ShellWords(3)
2
3
4
6 Env::ShellWords - Environment variables for arguments as array
7
9 version 0.02
10
12 # Tie Interface
13 use Env::ShellWords;
14 tie my @CFLAGS, 'Env::ShellWords', 'CFLAGS';
15 tie my @LDFLAGS, 'Env::ShellWords', 'LDFLAGS';
16
17 # same thing with import interface:
18 use Env::ShellWords qw( @CFLAGS @LDFLAGS );
19
20 # usage:
21 $ENV{CFLAGS} = '-DBAR=1';
22 unshift @CFLAGS, '-I/foo/include';
23 push @CFLAGS, '-DFOO=Define With Spaces';
24
25 # now:
26 # $ENV{CFLAGS} = '-I/foo/include -DBAR=1 -DFOO=Define\\ With\\ Spaces';
27
28 unshift @LDFLAGS, '-L/foo/lib';
29 push @LDFLAGS, '-lfoo';
30
32 This module provides an array like interface to environment variables
33 that contain flags. For example Autoconf can uses the environment
34 variables like "CFLAGS" or "LDFLAGS", and this allows you to manipulate
35 those variables without doing space quoting and other messy mucky
36 stuff.
37
38 The intent is to use this from alienfile to deal with hierarchical
39 prerequisites.
40
41 You can provide split and join callbacks when you tie:
42
43 use Env::ShellWords;
44 # split on any space, ignore quotes
45 tie my @FOO, 'Env::ShellWords',
46 sub { split /\s+/, $_[0] },
47 sub { join ' ', @_ };
48
49 Which may be useful if you have to split on words on an operating
50 system with a different specification.
51
53 Not especially fast. "undef" gets mapped to the empty string '' since
54 "undef" doesn't have a meaning as an argument in a string.
55
56 Writing to an environment variable using this interface is inherently
57 lossy.
58
60 Env
61
63 Graham Ollis <plicease@cpan.org>
64
66 This software is copyright (c) 2017 by Graham Ollis.
67
68 This is free software; you can redistribute it and/or modify it under
69 the same terms as the Perl 5 programming language system itself.
70
71
72
73perl v5.30.0 2019-07-26 Env::ShellWords(3)