Using Reference (Part 10)-- Perl Study Notes
Create explicit reference
$sv="hello";
@av=qw(1 2 hello);
%hv=qw(k1 v1 k2 v2);
$rs=\$sv; #create $sv reference named $rs;
$ra=\@av; #create $av reference named $ra;
$rh=\$hv; #create $hv reference named $rh;
$ra->[0]; #return first value of the array;
$rh->{"k1"}; #return value of k1 of the hash;
$ra->[0,1,2]; # same as $ra->[2];
Create anonymous reference
$rs=\"hello world"; # create an scalar referecne named $rs;
$ra=[1,2,"hello"]; # create an array reference named $ra;
$rh={"k1","v1","k2","v2"}; # create an hash reference named $rh;
Dereferencing
must use @$sa,%$sh,$$ss to dereferce the array, hash and scalar variable
Querying a Reference
$a=10;
$ra=\$a;
ref($a); return false since $a is a scalar not a referecne
ref($ra); return SCALAR scine $ra is a scalar reference
Symbolic Reference
$x=10;
$var="x";
$$var=30; # $var will be replaced by x. $$var=30 will look as $x=30
$var="x";
@$var=(1,2,3); # sets @x to (1,2,3)
It is important to note that symbolic references work only for global variables
Subroutine References
References to Named Subroutines
sub great{
print "hello world\n";
}
$rs=\&grett; # create a reference to subroutine great
$rs=\&greet(); # this does not create a reference to subroute great but a reference to the return value
References to Anonymous Subroutines
$rs=sub{
print "hello \n";
}
Dereferencing subroutine References
&$rs(10,20); # call the subroutine indirectly
$rs->(10,20); #same as above
Symbolic Reference
sub foo { print "foo called\n"}
$rs="foo";
&$rs(); # call foo subroutine and print "foo called"
In these days, I am preparing the env setup for ClearCase and ClearQuest integration. Since ClearCase need a domain env to begin, I try to setup one domain and here are the brief steps. All machines run Win2k3 server.
A. assign one machine as active directory server and setup the AD and create one domain on it.
B. on that domain controller, add DNS server role
C. add other machines to this domain. You can do this on the domain controller or the machine itself. After doing this, you can see the new domain in the logon to drop down list when you try to login domain machines.
D. in each domain machine, point to the DNS server to the Domain Controller. Else, you may encounter errors (RPC Server is unavailable) when doing step E
E. in each domain machine, add domain users or domain group into the Remote Desktop Users group. After doing this, granted domain users/groups can login domain machines
Here is some cases happened these days caused by the SQL Server Driver for ODBC
1. When import CQ profile using IBM Rational ClearQuest Maintenance Tool, user encountered error message as below,
Unable to login to the database using the following connection information:Driver= {SQL Server};UID=xxx;DataBase=xxx;PWD=xxx;SERVER=XXXVerify that the information used matches the way the database was set up
The error message was: SQLDriverConnect:RETCODE=-1,State=08001,Native Error=52
[Microsoft][ODBC SQL Server Driver][dbnmpntw]ConnectionOpen(CreateFile())
[Microsoft][ODBC SQL Server Driver][dbnmpntw]ConnectionOpen(CreateFile())
[Microsoft][ODBC Driver Manager]Driver's SQLSetConnectAttr failed
2. When users login CQ using CQ native client, below error massage happens,
Unable to logon to the SQL_SERVER database xxx
The vendor error message was:
SQLDriverConnect: RETCODE=-1, State=IM003, Native Error=160
pecified driver could not be loaded due to system error 126 (SQL Server).
Here are the steps to diagnose the cause,
1. Open ODBC Data Source Administrator
2. Enter the Drivers tab to check the version of SQL Server
3. Check your CQ product version and get the supported SQL Server version in CQ release notes
4. In most cases, the version is not the correct one to match the CQ products
5. Login microsoft to download the right MDAC(Microsoft Data Accessing Components) version to install and correct the version.
Best Regards
Oliver Zheng
Tel: 86-756-3398810
ClearQuest API ListSelection method is not available from ClearQuest Web interface
Just as the subject, you can not use ListSelection in CQ web or you may encounter error. Here is the IBM notes to explain this issue
How to solve unexpected characters in export package
In the clearquest, user can not input non-support characters in ClearQuest UI since the code page settings. But with a uncertain reason, we will meet sometimes error when export package and it says like
Fri Jun 20 15:46:02 2008 -- Job started
Multiutil: Found unexpected characters outside ASCII range.
Offending characters were found at:
line 2
column 0
byte 50
The packlet being exported was oplog serial number 116298 of database 'CSEDI', replica 'HKG' (UUID = 587CB952-6052-4D32-8D7E-3B70222438F3).
Here is the steps to fix the problem with MS-SQL backend db servers
1. using below command to dump the binary file from ratal_oplog table
pdsql -v ss -s dbserver -u dbo_userid -p dbo_user_password -db dbname
>dump_longbinary c:\temp\serical_116298.txt select packlet from ratl_oplog where serial_no=116298;
>commit;
>quit;
You can access below URL for the pdsql usage. In this case, the dbname is physical database name for CSEDI project
http://www-1.ibm.com/support/docview.wss?uid=swg21145079
2. open the dump file ,which was generated by step 1 and named serical_116298 for example, with notepad and save the file using ANSI format and do not update/change anything in the file.
3. check the exact size. This can be done using Windows Explorer by right-clicking on the file and choosing Properties.
4. Run pdsql again against the dbname in step 1 using below command
pdsql -v ss -s dbserver -u dbo_userid -p dbo_user_password -db dbname
>insert_file binary c:\temp serical_116298.txt update ratl_oplog set packlet=? Where serial_no=116298
>update ratl_oplog set packlet_len=2088 where serial_no=116298
>commit;
>quit;
pls note, a. there are no space between path(c:\temp) and filename(serical_116298.txt). b. do not replace the question mark after "packlet=". c. 2088 is the exact file size of serical_116298 after step 3 and it is 2088 bytes.
5. Run the export job/command against CSEDI project again and make sure the package can be exported and imported in its destination sites
Before doing step 4, you are strongly recommended to backup all your database in case of any unexpected failure.