1 package Test::Valgrind::Command::PerlScript;
8 Test::Valgrind::Command::PerlScript - A Test::Valgrind command that invokes a perl script.
16 our $VERSION = '1.00';
20 This command is meant to abstract the argument list handling of a C<perl> script.
24 use base qw/Test::Valgrind::Command::Perl Test::Valgrind::Carp/;
28 This class inherits L<Test::Valgrind::Command::Perl>.
30 =head2 C<< new file => $file, [ taint_mode => $taint_mode ], ... >>
32 Your usual constructor.
34 C<$file> is the path to the C<perl> script you want to run.
36 C<$taint_mode> is a boolean that specifies if the script should be run under taint mode.
37 If C<undef> is passed (which is the default), the constructor will try to infer it from the shebang line of the script.
39 Other arguments are passed straight to C<< Test::Valgrind::Command::Perl->new >>.
45 $class = ref($class) || $class;
49 my $file = delete $args{file};
50 $class->_croak('Invalid script file') unless $file and -e $file;
51 my $taint_mode = delete $args{taint_mode};
53 my $self = bless $class->SUPER::new(%args), $class;
55 $self->{file} = $file;
57 if (not defined $taint_mode and open my $fh, '<', $file) {
60 if ($first and my ($args) = $first =~ /^\s*#\s*!\s*perl\s*(.*)/) {
61 $taint_mode = 1 if $args =~ /(?:^|\s)-T(?:$|\s)/;
63 $taint_mode = 0 unless defined $taint_mode;
65 $self->{taint_mode} = $taint_mode;
70 sub new_trainer { Test::Valgrind::Command::Perl->new_trainer }
74 Read-only accessor for the C<file> option.
78 Read-only accessor for the C<taint_mode> option.
82 eval "sub $_ { \$_[0]->{$_} }" for qw/file taint_mode/;
87 return $self->SUPER::args(@_),
88 (('-T') x!! $self->taint_mode),
94 L<Test::Valgrind>, L<Test::Valgrind::Command::Perl>.
98 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
100 You can contact me by mail or on C<irc.perl.org> (vincent).
104 Please report any bugs or feature requests to C<bug-test-valgrind at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Valgrind>.
105 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
109 You can find documentation for this module with the perldoc command.
111 perldoc Test::Valgrind::Command::PerlScript
113 =head1 COPYRIGHT & LICENSE
115 Copyright 2009 Vincent Pit, all rights reserved.
117 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
121 1; # End of Test::Valgrind::Command::PerlScript