use File::Spec::Functions( rel2abs canonpath ); my $full_inpath = canonpath( rel2abs( $infile ) ); my $full_outpath = canonpath( rel2abs( $outfile ) ); if ( $full_inpath eq $full_outpath ) { ... }