wfsp has asked for the wisdom of the Perl Monks concerning the following question:
I'm writing a test for a method that uses mkpath. I want the test to fail and I can trap the error ok but I'd also like to supress any output.
From the docs
If a system error prevents a directory from being created, then the mkpath function throws a fatal error with Carp::croak.What's the best way of going about this?
produces#!/usr/bin/perl use strict; use warnings; use File::Path; my $path = q{a:/tmp}; # non existent drive eval {no warnings 'all'; mkpath $path}; if ($@){ print qq{failed\n}; } else{ print qq{ok\n}; }
update: fixed typoArgument "No such file or directory; The system cannot find the pa..." + isn't numeric in scalar assignment at c:/perl/lib/File/Path.pm line +152. failed
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Fixed: Suppressing mkpath error output
by grinder (Bishop) on Feb 14, 2008 at 11:13 UTC |