#! /usr/bin/perl -w
use strict;

@ARGV == 1 or die "Usage: $0 filename\n";
my $filename =  $ARGV[0];
my $stat = `p4 fstat $filename`;

my $headRev;
if ($stat =~ /... headRev (\d+)/) {
      $headRev = $1;
} else {
      die "Can not find any version in depot for $filename\n";
}
my $preRev = $headRev - 1;

my $command = "p4 diff -db -dw -dl $filename#$preRev\n";
print $command;
print `$command`;

=head1 DESCRIPTION
Compare the latest depot version with its immediate predecessor

=head1 README
Give Perforce users a tool like "cleartool diff -pre" of ClearCase
Compare the latest depot version with its immediate predecessor

=head1 PREREQUISITES
requires strict module

=head1 SCRIPT CATEGORIES
VersionControl/Perforce

=head1 AUTHOR
Xin Zhou (zhouxin@cpan.org), October 2012

=head1 COPYRIGHT
This program is free software. You may copy or redistribute it under the same
terms as Perl itself.

=cut