# Task: output list of 'opened' files, using local pathnames. # # status: tested on Win/NT using perl 5.6 with p4perl API # num of calls to 'p4': 2 # room for optimization/improvement: add getopts call # # Copyright 2004 Perforce Corporation, Inc. All rights reserved. use P4; my $p4 = new P4; $p4->ParseForms(); $p4->Init() or die "Failed to initialize 'p4' object!"; $p4->Tagged(); #----------------------------------------------------------- # first call to P4: 'p4 client -o' # Note that it's easier to get the client root dir from # the 'client spec', hence the "FetchClient" call. #----------------------------------------------------------- my $info = $p4->FetchClient(); $cl_name = $info->{"Client"}; $cl_root = $info->{"Root"}; #----------------------------------------------------------- # second call to P4: 'p4 opened' #----------------------------------------------------------- @ret = $p4->Opened(); #----------------------------------------------------------- # Now, loop through the output of 'p4 opened'. The tagged # output gives us a client-syntax version of the name # in the form "//clientName/rest-of-local-path", # so we substitute the client root dir before printing. #----------------------------------------------------------- $oldtag = "//$cl_name"; foreach $h (@ret) { $localFile = $h->{'clientFile'}; $localFile =~ s/$oldtag/$cl_root/; print "$localFile\n"; }