LoginSignup
1
0

More than 5 years have passed since last update.

Perlでのダンプ処理

Last updated at Posted at 2017-04-02
use strict;
use warnings;
use Data::Dumper;

:

# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# ■ デバッグ用
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

my $print_header = 0;

sub dump
{
    my $param = shift;
    my $exit  = shift;

    if( !$print_header )
    {
        print "Content-type: text/html\n\n";
        local $Data::Dumper::Deparse = 1;
        $print_header = 1;
    }

    print Data::Dumper::Dumper $param;

    # 第二引数があればそこで終了
    if( $exit ne undef )
    {
        exit;
    }
}

こうしておいて、ダンプしたくなったら。

&dump($self);
&dump($env);

一旦処理を止めたい場合

&dump($params, 1);
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0