1 package Test::Valgrind::Command::PerlScript;
8 Test::Valgrind::Command::PerlScript - A Test::Valgrind command that invokes a perl script.
16 our $VERSION = '1.16';
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>.
32 my $tvcps = Test::Valgrind::Command::PerlScript->new(
34 taint_mode => $taint_mode,
38 The package constructor, which takes several options :
44 C<$file> is the path to the C<perl> script you want to run.
46 This option is mandatory.
50 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.
54 Other arguments are passed straight to C<< Test::Valgrind::Command::Perl->new >>.
60 $class = ref($class) || $class;
64 my $file = delete $args{file};
65 $class->_croak('Invalid script file') unless $file and -e $file;
67 my $taint_mode = delete $args{taint_mode};
68 if (not defined $taint_mode and open my $fh, '<', $file) {
71 if ($first and my ($args) = $first =~ /^\s*#\s*!\s*perl\s*(.*)/) {
72 $taint_mode = 1 if $args =~ /(?:^|\s)-T(?:$|\s)/;
74 $taint_mode = 0 unless defined $taint_mode;
77 my $self = bless $class->SUPER::new(
78 taint_mode => $taint_mode,
82 $self->{file} = $file;
87 sub new_trainer { Test::Valgrind::Command::Perl->new_trainer }
91 my $file = $tvcps->file;
93 Read-only accessor for the C<file> option.
97 sub file { $_[0]->{file} }
102 return $self->SUPER::args(@_),
108 L<Test::Valgrind>, L<Test::Valgrind::Command::Perl>.
112 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
114 You can contact me by mail or on C<irc.perl.org> (vincent).
118 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>.
119 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
123 You can find documentation for this module with the perldoc command.
125 perldoc Test::Valgrind::Command::PerlScript
127 =head1 COPYRIGHT & LICENSE
129 Copyright 2009,2010,2011,2013,2015 Vincent Pit, all rights reserved.
131 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
135 1; # End of Test::Valgrind::Command::PerlScript