1 package Test::Valgrind::Command::PerlScript;
8 Test::Valgrind::Command::PerlScript - A Test::Valgrind command that invokes a perl script.
16 our $VERSION = '1.12';
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 The package constructor, which takes several options :
38 C<$file> is the path to the C<perl> script you want to run.
40 This option is mandatory.
44 C<$taint_mode> is actually handled by the parent class L<Test::Valgrind::Command::Perl>, but it gets special handling in this subclass : if C<undef> is passed (which is the default), the constructor will try to infer its right value from the shebang line of the script.
48 Other arguments are passed straight to C<< Test::Valgrind::Command::Perl->new >>.
54 $class = ref($class) || $class;
58 my $file = delete $args{file};
59 $class->_croak('Invalid script file') unless $file and -e $file;
61 my $taint_mode = delete $args{taint_mode};
62 if (not defined $taint_mode and open my $fh, '<', $file) {
65 if ($first and my ($args) = $first =~ /^\s*#\s*!\s*perl\s*(.*)/) {
66 $taint_mode = 1 if $args =~ /(?:^|\s)-T(?:$|\s)/;
68 $taint_mode = 0 unless defined $taint_mode;
71 my $self = bless $class->SUPER::new(
72 taint_mode => $taint_mode,
76 $self->{file} = $file;
81 sub new_trainer { Test::Valgrind::Command::Perl->new_trainer }
85 Read-only accessor for the C<file> option.
89 sub file { $_[0]->{file} }
94 return $self->SUPER::args(@_),
100 L<Test::Valgrind>, L<Test::Valgrind::Command::Perl>.
104 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
106 You can contact me by mail or on C<irc.perl.org> (vincent).
110 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>.
111 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
115 You can find documentation for this module with the perldoc command.
117 perldoc Test::Valgrind::Command::PerlScript
119 =head1 COPYRIGHT & LICENSE
121 Copyright 2009,2010,2011 Vincent Pit, all rights reserved.
123 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
127 1; # End of Test::Valgrind::Command::PerlScript