perl-Capture-Attribute - s/return/print/g

Property Value
Distribution ALT Linux Sisyphus
Repository Autoimports noarch
Package name perl-Capture-Attribute
Package version 0.003
Package release alt1
Package architecture noarch
Package type rpm
Installed size 37.59 KB
Download size 37.59 KB
Official Mirror
Sometimes you write a function that needs to build a long string via a
convoluted series of conditional statements, loops and so on. I tend to
end up defining a variable `$return' at the top of the code,
concatenating bits to it as required, and then return it at the end. For
sub count_to_10 {
my $return = "Listen to me count!\n";
foreach (1..10) {
$return .= "$_\n";
$return .= "Half-way there!\n" if $_==5;
$return .= "All done!\n";
return $return;
To      => '',
From    => '',
Subject => 'I can count!',
data    => count_to_ten(),
Capture::Attribute simplifies this pattern by capturing all output to
STDOUT, so you can use STDOUT as a place to capture each part of the
sub count_to_10 :Capture {
say "Listen to me count!";
foreach (1..10) {
say $_;
say "Half-way there!" if $_==5;
say "All done!";
To      => '',
From    => '',
Subject => 'I can count!',
data    => count_to_ten(),
Doesn't that look nicer?
Within a sub marked with the ":Capture" attribute, all data that would be
printed is captured instead. When the sub is finished, the return value is
ignored and the captured text is returned instead.
The `return' keyword still works just fine for its control flow purpose
inside a captured sub. The return value just doesn't get returned.


Package Version Architecture Repository
perl-Capture-Attribute - - -


Name Value
/usr/share/perl5 -
perl(Any/ -
perl(Attribute/ -
perl(Capture/ -
perl(Sub/ -
perl( -
perl( -
perl-base >= 1:5.10.0
rpmlib(PayloadIsLzma) -


Name Value
perl(Capture/ = 0.003
perl(Capture/Attribute/ = 0.003
perl-Capture-Attribute = 0.003-alt1


Type URL
Binary Package perl-Capture-Attribute-0.003-alt1.noarch.rpm
Source Package perl-Capture-Attribute-0.003-alt1.src.rpm

Install Howto

  1. Add the following line to /etc/apt/sources.list:
    rpm [Sisyphus] noarch autoimports
    rpm [Sisyphus] noarch autoimports
  2. Update the package index:
    # sudo apt-get update
  3. Install perl-Capture-Attribute rpm package:
    # sudo apt-get install perl-Capture-Attribute



See Also

Package Description
perl-Capture-SystemIO-0.01-alt1.noarch.rpm system() capture stderr, stdout, and signals
perl-Capture-Tiny-Extended-0.114-alt1.noarch.rpm Capture STDOUT and STDERR from from Perl, XS or external programs (with some extras)
perl-Capulcu-Bot-0.1-alt1.noarch.rpm Capulcu Bot
perl-Capulcu-Bot-scripts-0.1-alt1.noarch.rpm Capulcu-Bot scripts
perl-Card-Magnetic-0.003-alt1.noarch.rpm Magnetic Stripe parser
perl-Caroline-0.22-alt1.noarch.rpm Yet another line editing library
perl-Carp-Always-Color-0.07-alt1.noarch.rpm Carp::Always, but with color
perl-Carp-Always-DieOnly-0.01-alt1.noarch.rpm Like Carp::Always, but only print stacktrace on die()
perl-Carp-Always-Dump-0.06-alt1.noarch.rpm Like Carp::Always, but dumps the content of function arguments
perl-Carp-Always-EvenObjects-0.003000-alt2.noarch.rpm DEPRECATED
perl-Carp-Always-SyntaxHighlightSource-0.03-alt1.noarch.rpm Carp::Always, but show syntax-highlighted source code context
perl-Carp-Clan-Share-0.013-alt1_27.noarch.rpm Share your Carp::Clan settings with your whole Clan
perl-Carp-Diagnostics-0.05.3-alt1.noarch.rpm Carp with a diagnostic message
perl-Carp-Ensure-0.23-alt1.noarch.rpm perl module Carp-Ensure
perl-Carp-Fix-1_25-1.000001-alt1.noarch.rpm Smooth over incompatible changes in Carp 1.25