Venus::Role::Printable - Printable Role
Printable Role for Perl 5
package Example; use Venus::Class; with 'Venus::Role::Dumpable'; with 'Venus::Role::Printable'; attr 'test'; sub execute { return [@_]; } sub printer { return [@_]; } package main; my $example = Example->new(test => 123); # $example->say;
This package provides a mechanism for outputting (printing) objects or the return value of a dispatched method call to STDOUT.
This package provides the following methods:
print(Any @data) (Any)
The print method prints a stringified representation of the underlying data.
Since 0.01
0.01
package main; my $example = Example->new(test => 123); my $print = $example->print; # bless({test => 123}, 'Example') # 1
package main; my $example = Example->new(test => 123); my $print = $example->print('execute', 1, 2, 3); # [bless({test => 123}, 'Example'),1,2,3] # 1
print_pretty(Any @data) (Any)
The print_pretty method prints a stringified human-readable representation of the underlying data.
package main; my $example = Example->new(test => 123); my $print_pretty = $example->print_pretty; # bless({ test => 123 }, 'Example') # 1
package main; my $example = Example->new(test => 123); my $print_pretty = $example->print_pretty('execute', 1, 2, 3); # [ # bless({ test => 123 }, 'Example'), # 1, # 2, # 3 # ] # 1
print_string(Str | CodeRef $method, Any @args) (Any)
The print_string method prints a string representation of the underlying data without using a dump. This method supports dispatching, i.e. providing a method name and arguments whose return value will be acted on by this method.
Since 0.09
0.09
package main; my $example = Example->new(test => 123); my $print_string = $example->print_string; # 'Example' # 1
say(Any @data) (Any)
The say method prints a stringified representation of the underlying data, with a trailing newline.
package main; my $example = Example->new(test => 123); my $say = $example->say; # bless({test => 123}, 'Example')\n # 1
package main; my $example = Example->new(test => 123); my $say = $example->say; # [bless({test => 123}, 'Example'),1,2,3]\n # 1
say_pretty(Any @data) (Any)
The say_pretty method prints a stringified human-readable representation of the underlying data, with a trailing newline.
package main; my $example = Example->new(test => 123); my $say_pretty = $example->say_pretty; # bless({ test => 123 }, 'Example')\n # 1
package main; my $example = Example->new(test => 123); my $say_pretty = $example->say_pretty; # [ # bless({ test => 123 }, 'Example'), # 1, # 2, # 3 # ]\n # 1
say_string(Str | CodeRef $method, Any @args) (Any)
The say_string method prints a string representation of the underlying data without using a dump, with a trailing newline. This method supports dispatching, i.e. providing a method name and arguments whose return value will be acted on by this method.
package main; my $example = Example->new(test => 123); my $say_string = $example->say_string; # "Example\n" # 1
To install Venus, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Venus
CPAN shell
perl -MCPAN -e shell install Venus
For more information on module installation, please visit the detailed CPAN module installation guide.