1IO::TieCombine(3) User Contributed Perl Documentation IO::TieCombine(3)
2
3
4
6 IO::TieCombine - produce tied (and other) separate but combined
7 variables
8
10 version 1.005
11
13 First, we set up a bunch of access points:
14
15 my $hub = IO::TieCombine->new;
16
17 my $str_ref = $hub->scalar_ref('x');
18 my $fh = $hub->fh('x');
19 my $callback = $hub->callback('x');
20
21 tie my $scalar, $hub, 'x';
22 tie local *STDOUT, $hub, 'x';
23
24 tie local *STDERR, $hub, 'err';
25
26 Then we write to things:
27
28 $$str_ref .= 'And ';
29 print $fh "now ";
30 $callback->('for ');
31 $scalar .= 'something ';
32 print "completely ";
33 warn "different.\n";
34
35 And then:
36
37 $hub->combined_contents; # And now for something completely different.
38 $hub->slot_contents('x'); # And now for something completely
39 $hub->slot_contents('err'); # different.
40
41 ACHTUNG!! Because of a serious problem with Perl 5.10.0, output sent
42 to a tied filehandle using "say" will not have the expected newline.
43 5.10.1 or later is needed. Since 5.10.0 is broken in so many other
44 ways, you should really upgrade anyway.
45
46 ACHTUNG!! Because of a different problem with Perls 5.10.1 - 5.16.3,
47 if you send output to a tied filehandle using "say", and "$\" is
48 undefined (which is the default), "$\" will not be restored to "undef"
49 after the "say"! This means that once you've used "say" to print to
50 any tied filehandle, you have corrupted the global state of your
51 program. Either start your program by setting "$\" to an empty string,
52 which should be safe, or upgrade to 5.18.0.
53
55 new
56 The constructor takes no arguments.
57
58 combined_contents
59 This method returns the contents of all collected data.
60
61 slot_contents
62 my $str = $hub->slot_contents( $slot_name );
63
64 This method returns the contents of all collected data for the named
65 slot.
66
67 clear_slot
68 $hub->clear_slot( $slot_name );
69
70 This sets the slot back to an empty string.
71
72 fh
73 my $fh = $hub->fh( $slot_name );
74
75 This method returns a reference to a tied filehandle. When printed to,
76 output is collected in the named slot.
77
78 scalar_ref
79 my $str_ref = $hub->scalar_ref( $slot_name );
80
81 This method returns a reference to scalar. When appended to, the new
82 content is collected in the named slot. Attempting to alter the string
83 other than by adding new content to its end will result in an
84 exception.
85
86 callback
87 my $code = $hub->callback( $slot_name );
88
90 Ricardo SIGNES <rjbs@cpan.org>
91
93 This software is copyright (c) 2015 by Ricardo SIGNES.
94
95 This is free software; you can redistribute it and/or modify it under
96 the same terms as the Perl 5 programming language system itself.
97
98
99
100perl v5.30.0 2019-07-26 IO::TieCombine(3)