Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: a4cc714fca
Fetching contributors…

Cannot retrieve contributors at this time

201 lines (122 sloc) 4.834 kb
package Carp::Parse::CallerInformation::Redacted;
use warnings;
use strict;
use Carp;
use Data::Dump;
use base 'Carp::Parse::CallerInformation';
=head1 NAME
Carp::Parse::CallerInformation::Redacted - Represent the parsed caller information for a line of the Carp stack trace.
This module inherits from Carp::Parse::CallerInformation and adds the
get_redacted_arguments_list() method to it. See C<Carp::Parse::CallerInformation>
for the list of all the methods this module offers.
As a user, you should not have to create Carp::Parse::CallerInformation objects
yourself, they will get created for you by C<Carp::Parse::Redact>.
=head1 VERSION
Version 1.1.1
our $VERSION = '1.1.1';
# Retrieve the redacted arguments array.
my $redacted_arguments_list = $caller_information->get_redacted_arguments_list();
=head1 METHODS
=head2 new()
Create a new C<Carp::Parse::CallerInformation::Redacted> object.
my $redacted_caller_information = Carp::Parse::CallerInformation::Redacted->new(
arguments_string => $arguments_string,
arguments_list => $arguments_list,
redacted_arguments_list => $redacted_arguments_list,
line => $line,
sub new
my ( $class, $data ) = @_;
# Verify parameters.
croak 'The first argument must be a hashref with the data to set on the object.'
unless defined( $data ) && UNIVERSAL::isa( $data, 'HASH' ); ## no critic (BuiltinFunctions::ProhibitUniversalIsa)
my $line = delete( $data->{'line'} );
my $arguments_string = delete( $data->{'arguments_string'} );
my $arguments_list = delete( $data->{'arguments_list'} );
my $redacted_arguments_list = delete( $data->{'redacted_arguments_list'} );
croak "The data hashref must contain the 'line' key with the original stack line"
unless defined( $line );
croak "The following parameters are not supported: " . Data::Dump::dump( $data )
if scalar( keys %$data ) != 0;
return bless(
line => $line,
arguments_string => $arguments_string,
arguments_list => $arguments_list,
redacted_arguments_list => $redacted_arguments_list,
=head2 get_redacted_arguments_list()
Return an arrayref of the arguments parsed for this caller, with the sensitive
arguments redacted out.
my $redacted_arguments_list = $caller_information->get_redacted_arguments_list();
sub get_redacted_arguments_list
my ( $self ) = @_;
return $self->{'redacted_arguments_list'};
=head2 get_redacted_line()
Return the redacted version of the original line from the stack trace.
my $redacted_line = $caller_information->get_redacted_line();
sub get_redacted_line
my ( $self ) = @_;
my $line = $self->get_line();
my $arguments_string = $self->get_arguments_string();
if ( defined( $arguments_string ) )
my $redacted_arguments_list = $self->get_redacted_arguments_list() || [];
# Data::Dump::dump() is really nice except that it treats arrays with
# only one member as a string, so we need to make an exception for
# formatting in that case.
my $redacted_arguments_string = Data::Dump::dump( @$redacted_arguments_list );
$redacted_arguments_string = "($redacted_arguments_string)"
if scalar( @$redacted_arguments_list ) == 1;
$line =~ s/\(\Q$arguments_string\E\)/$redacted_arguments_string/x;
return $line
=head1 AUTHOR
Kate Kirby, C<< <kate at> >>.
Guillaume Aubert, C<< <aubertg at> >>.
=head1 BUGS
Please report any bugs or feature requests to C<bug-carp-parse-redact at>, or through
the web interface at L<>.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Carp::Parse::CallerInformation::Redacted
You can also look for information at:
=over 4
=item * RT: CPAN's request tracker
=item * AnnoCPAN: Annotated CPAN documentation
=item * CPAN Ratings
=item * Search CPAN
Thanks to ThinkGeek (L<>) and its corporate overlords
at Geeknet (L<>), for footing the bill while we eat pizza
and write code for them!
Copyright 2012 Kate Kirby & Guillaume Aubert.
This program is free software; you can redistribute it and/or modify it
under the terms of the Artistic License.
See for more information.
Jump to Line
Something went wrong with that request. Please try again.