From 6135c79ba91b65f7d8a62969caaf52f9de6622ba Mon Sep 17 00:00:00 2001 From: Maik Hentsche Date: Wed, 17 Apr 2013 02:16:16 -0700 Subject: [PATCH] cleanup module usage This patches cleans up usage of external modules. First, we only want to have one YAML module which will be YAML::XS. Therefore, I superseeded YAML::Syck with YAML::XS. Furthermore, a "use" line should never go somewhere inside a function but alsways at the beginning of a code file to make all used modules easy to see for developers. Also, File::Slurp does not add much value over reading the file manually. Therefore, I removed it too. --- lib/Tapper/CLI/Testrun/Command/newscenario.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Tapper/CLI/Testrun/Command/newscenario.pm b/lib/Tapper/CLI/Testrun/Command/newscenario.pm index 7951f9f..a2cf63a 100644 --- a/lib/Tapper/CLI/Testrun/Command/newscenario.pm +++ b/lib/Tapper/CLI/Testrun/Command/newscenario.pm @@ -7,6 +7,7 @@ use warnings; no warnings 'uninitialized'; use parent 'App::Cmd::Command'; +use YAML::XS; use Tapper::Cmd::Scenario; use Tapper::Cmd::Testrun; @@ -83,12 +84,13 @@ sub execute { my ($self, $opt, $args) = @_; - use File::Slurp 'slurp'; - my $scenario = slurp($opt->{file}); + my $scenario = do {local $/; + open (my $, '<', $opt->{file}) or die "Can open file:$!\n"; + <$fh> + }; $scenario = $self->apply_macro($scenario, $opt->{d}); - use YAML::Syck 'Load'; - my $scenario_conf = Load($scenario); + my $scenario_conf = YAML::XS::Load($scenario); given ($scenario_conf->{scenario_type}) { when ('interdep') { $self->parse_interdep($scenario_conf->{description}, $opt);