Mac-Pasteboard

 view release on metacpan or  search on metacpan

eg/save_image  view on Meta::CPAN

#!/usr/local/bin/perl

use strict;
use warnings;

use Mac::Pasteboard;

my $file = shift @ARGV || 'clipboard';

my $pb = Mac::Pasteboard->new ();

my @img = $pb->paste_all ('public.image')
    or die "No data conforming to 'public.image' found.\n";

foreach my $item (@img) {
    my $tags = $pb->flavor_tags ($item->{flavor});
    my $fn = $tags->{extension} ? "$file.$tags->{extension}" : $file;
    warn "Creating $fn\n";
    open (my $fh, '>', $fn) or die "Failed to open $fn: $!\n";
    binmode $fh;
    print $fh $item->{data};
    close $fh;
}



( run in 1.087 second using v1.01-cache-2.11-cpan-84e82930d8c )