Carp::Parse - Parse a Carp stack trace into an array of caller information with parsed arguments.


Carp produces a stacktrace that includes caller arguments; this module parses each line of the stack trace to extract its arguments, which allows rewriting the stack trace (for example, to redact sensitive information).


Version 1.0.7


        # Retrieve a Carp stack trace with longmess(). This is tedious, but you will
        # normally be using this module in a context where the stacktrace is already
        # generated for you and you want to parse it, so you won't have to go through
        # this step.
        sub test3 { return Carp::longmess("Test"); }
        sub test2 { return test3(); }
        sub test1 { return test2(); }
        my $stack_trace = test1();
        # Parse the Carp stack trace.
        use Carp::Parse;
        my $parsed_stack_trace = Carp::Parse::parse_stack_trace( $stack_trace );
        use Data::Dump qw( dump );
        foreach my $caller_information ( @$parsed_stack_trace )
                # Print the arguments for each caller.
                say dump( $caller->get_arguments_list() );



Parse a stack trace produced by Carp into an arrayref of Carp::Parse::CallerInformation objects.

        my $parsed_stack_trace = Carp::Parse::parse_stack_trace( $stack_trace );


Kate Kirby, <kate at>.

Guillaume Aubert, <aubertg at>.


Please report any bugs or feature requests to bug-carp-parse at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

        perldoc Carp::Parse

You can also look for information at:


Thanks to ThinkGeek ( and its corporate overlords at Geeknet (, 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 GNU General Public License version 3 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see