This just bit me. Ouch!
My script looks something like this:
#!/usr/bin/perl
use strict;
use warnings;
use IS::Creative;
use IO::Prompt;
foreach my $creative_id (@ARGV) {
my $creative = IS::Creative->new( $creative_id );
if ( !$creative->exists() ) {
warn "Creative #$creative_id doesn't exist, skipping";
}
if ( prompt("Are you sure you want to delete creative #$creative_id?
", '-yt') ) {
$creative->delete();
print "Creative $creative_id deleted!\n";
}
}
Example run:
jay@webdev:~$ ./delete_creatives.pl 4141849643
Can't open 4141849643: No such file or directory at
./delete_creatives.pl line 16
jay@webdev:~$
After reading this discussion I added -t to the prompt() options, and
things started working like I expected.
I probably would have solved this problem this much faster (boy was I
confused!) if the "Can't open %s: %s" part of the DIAGNOSTICS section
added a line like this:
If @ARGV contains something other than a file when prompt() is called,
either use the -tty option or remove those values from @ARGV.