3 %bcond_without tests # do not perform "make test"
7 Summary: Context::Preserve - run code after a subroutine call, preserving the context the subroutine would have seen if it were the last statement in the caller
9 Name: perl-Context-Preserve
13 License: GPL v1+ or Artistic
14 Group: Development/Languages/Perl
15 Source0: http://www.cpan.org/modules/by-authors/id/J/JR/JROCKWAY/Context-Preserve-0.01.tar.gz
16 # Source0-md5: e28c24d9e85d3f7de1c7b9a545ba991a
17 URL: http://search.cpan.org/dist/Context-Preserve/
18 BuildRequires: perl-devel >= 1:5.8.0
19 BuildRequires: rpm-perlprov >= 4.1-13
21 BuildRequires: perl-Test-Exception
22 BuildRequires: perl-Test-use-ok
25 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
28 Sometimes you need to call a function, get the results, act on the
29 results, then return the result of the function. This is painful
30 because of contexts; the original function can behave different if
31 it's called in void, scalar, or list context. You can ignore the
32 various cases and just pick one, but that's fragile. To do things
33 right, you need to see which case you're being called in, and then
34 call the function in that context. This results in 3 code paths,
35 which is a pain to type in (and maintain).
37 This module automates the process. You provide a coderef that is the
38 "original function", and another coderef to run after the original
39 runs. You can modify the return value (aliased to @_) here, and do
40 whatever else you need to do. wantarray is correct inside both
41 coderefs; in "after", though, the return value is ignored and the
42 value wantarray returns is related to the context that the original
43 function was called in.
45 # %description -l pl.UTF-8
49 %setup -q -n %{pdir}-%{pnam}-%{version}
52 %{__perl} Makefile.PL \
56 %{?with_tests:%{__make} test}
59 rm -rf $RPM_BUILD_ROOT
61 %{__make} pure_install \
62 DESTDIR=$RPM_BUILD_ROOT
65 rm -rf $RPM_BUILD_ROOT
68 %defattr(644,root,root,755)
70 %dir %{perl_vendorlib}/Context
71 %{perl_vendorlib}/Context/Preserve.pm