# # read in -Ztag output. # # Note that this is a very simple-minded implementation # that only reads in the first line of a field - multiline # fields (descriptions, etc) require more code here. # # Copyright 2004 Perforce Corporation, Inc. All rights reserved. sub readinZtag { my ($str) = @_; my (@retval); my ($oldIFS) = $/; $/ = ''; # set IFS to double-newline print "running \"$str\"\n"; open(FD, "$str|") || die "cannot run \"$str\""; while () { my (%h); @fields = split("\n", $_); # # input is "... fieldname fieldvalue", # so we parse it and put into assoc. array # foreach $f (@fields) { if ($f =~ /^\.\.\.\s+(\S+)\s+(.*)/) { local($key, $val) = ($1,$2); $h{$key} = $val; } } push(@retval, \%h) if length(keys(%h)) > 0; } close(FD); $/ = $oldIFS; # reset IFS return @retval; } sub readInfo { my ($str) = "$p4 info"; my (%retval); open(FD, "$str|") || die "cannot run \"$str\""; while () { if (/^\.\.\.\s+(\S+)\s+(.*)/) { local($key, $val) = ($1,$2); $retval{$key} = $val; } } close(FD); return %retval; } 1;