[p4perl] Help with Hashes

Craig Leigh cleigh@blackboard.com
Wed, 29 Dec 2004 11:09:53 -0500


Nice!

This:

	$p4->Edit ("c:/src/file.txt");
	foreach my $e ($p4->Errors()){
	      print "$e->[0]\n";
	}

gives:

	Path 'c:/src/file.txt' is not under client's root 'C:\code'.

Which is correct!

But!

	foreach $e (@$chglist){
	print "$e->[0]\n";
	}

gives this:

	Not an ARRAY reference at C:\src\p4synop.pl line 66, <STDIN>
line 1.

Huh!


--Craig
CM Team
Lead Engineer
x2554
 
 

-----Original Message-----
From: Robert Cowham [mailto:robert@vaccaperna.co.uk] 
Sent: Wednesday, December 29, 2004 10:53 AM
To: Craig Leigh; 'Tony Smith'; p4perl@perforce.com
Subject: RE: [p4perl] Help with Hashes

Dereference things like this (one of the reasons I don't use Perl any
more
unless I have to!!):

    foreach my $e ($p4->Errors()){
      print "$e->[0]\n";
    } 

> -----Original Message-----
> From: p4perl-admin@perforce.com 
> [mailto:p4perl-admin@perforce.com] On Behalf Of Craig Leigh
> Sent: 29 December 2004 15:36
> To: Tony Smith; p4perl@perforce.com
> Subject: [p4perl] Help with Hashes
> 
> Hi Tony,
> 
> 
> I have used p4::ParseForms() like this:
> 
> [-----
> 
> $p4->SetPassword($mypassword);
> $p4->ParseForms();
> $p4->Connect() or die ("Failed to connect to Perforce Server");
> 
> ------]
> 
> then I call:
> 
> [-----
> 
> my $chglist = $p4->Run ("changes","-t","",$param); foreach 
> $listitem (@$chglist){ print "$listitem\n"; }
> 
> ------]
> 
> which without the $p4->ParseForms() call produces this 
> output: (which I could work with, but)
> 
> Change 82981 on 2004/12/20 17:37:54 by hnatour@hnatourxp_dev 'scr
> 13742--
> Change 82975 on 2004/12/20 16:41:43 by 
> rpeterson@rpeterson_mainline Change 82967 on 2004/12/20 
> 16:28:09 by hnatour@hnatourxp_dev 'scr
> 12653--
> Change 82966 on 2004/12/20 16:23:57 by rpeterson@rpeterson_mainline 
> 
> [-----------------------------------------------------------------]
> 
> With $p4->ParseForms() the output produces this: 
> 
> HASH(0x225098)
> HASH(0x18c2894)
> HASH(0x18c28f4)
> HASH(0x18248a8)
> 
> How do I dereference the values?
> 
> The code I use like this:
> 
> [-----
> 
> my $chglist = $p4->Run ("changes","-t","",$param); foreach 
> $listitem (@$chglist){ print "${%listitem}\n";
> 
> ------]
> 
> gives me this:
> 
> C:\src\p4synop.pl
> C:\src\p4synop.pl
> C:\src\p4synop.pl
> C:\src\p4synop.pl
> 
> 
> What am I doing wrong, Sir.  
> 
> Thanks
> --Craig
> CM Team
> Lead Engineer
> x2554
>  
> 
> 
> This e-mail is intended only for the personal and 
> confidential use of the recipient(s) named above. 
> It may include Blackboard confidential and proprietary 
> information, and is not for redistribution.
> 
> 
> 
> _______________________________________________
> p4perl mailing list
> p4perl@perforce.com
> http://maillist.perforce.com/mailman/listinfo/p4perl
> 
>