" /> Status for Andrew DeFaria: January 8, 2006 - January 14, 2006 Archives

« January 1, 2006 - January 7, 2006 | Main | January 15, 2006 - January 21, 2006 »

January 13, 2006

Perl test

  • Ray wanted an easy/medium/hard Perl test

Perl Test

Easy

  1. What does Perl stand for?
  2. Practical Extraction and Reporting Language

  3. What basic datatypes does Perl support?
  4. Scalar, Array, Hash, Typeglob

  5. What does the following do:
  6. my @output = <STDIN>;
    
    foreach (@output) {
      print "$_\n" if /\d+/;
    }
    

    Echoes lines that have numbers in them)

Medium

  1. What is use strict and why is it important to use?
  2. Strict requires that variable references are scoped - e.g. my $var)

  3. What does the following code do:
  4. sub d {
      my %p = @_;
    
      print "\np:\n";
    
      foreach (sort (keys (%p))) {
        if (/password/) {
          print "$_: <password>\n";
        } else {
          print "$_: ${p {$_}}\n";
        } # if
      } # foreach
    } # d
    

    Displays the contents of the passed in hash %p substituting "<password>" if the hash happens to have a key of password

  5. What do you do to enable Perl to find user written modules?
  6. You need to modify the @INC array to include the path to your modules)

Hard

  1. What is the difference between require and use?
  2. See this article for the answer

  3. What is a better way to do the following and why:
  4. undef $/;
    

    See this article) for the answer

  5. What does the following print out when executed:
  6. sub foo {
      my ($x, $y) = @_;
    
      my @z = `$x 2>&1`; chomp @z;
      my $s = $?;
    
      if ($s ne 0) {
        if (defined $y) {
          print "$_\n" foreach (@z);
        }
      }
    
      return ($y, @z);
    } # foo
    
    my @a;
    my $c="ls /temp";
    my $d;
    
    ($d, @a) = foo $c;
    print "Worked!\n" if !$d;
    

    (It will output:

    Worked!
    

    Yet nothing really worked at all! Key issues are:

    • Passing parameters to subroutines. Two parameters are passed in
    • Parameter return: Two parameters are returned
    • Evaluation of parameters: $y in foo is not passed in thus the print... foreach doesn't execute>
    • Evaluation of true/false: foo returns $y which is errno, which is not 0 thus not true but the !$d evaluates to true and the print "Worked!\n" gets executed.

January 12, 2006

Clearcase Merging/CQ Time Stamp problem/CQ Help problem

  • Consulted with Ann Wisotzky regarding Clearcase Merging
  • Investigated email time stamp problem with PQA
  • Worked with Rational regarding Clearquest: Help problem

January 11, 2006

Stglocs/replicating perftest

  • Investigated stglocs
  • Replicated /vobs/perftest and set up log_activity, stats and pulse for all of:
    • ccase-rmna-3
    • ccase-sj1-1
    • ccase-sj1-2
    • ccase-irva-2

Chris, if you can spare a Windows machine to host the views (meaning to run the view_server processes on) then I believe the following stgloc would be your best answer:

$ your_filer=<your_filer>
$ your_share=<your_share>
$ your_windows_view_server=<your_windows_view_server>
$ p=\\\\$your_filer\\$your_share\\viewstore
$ cleartool mkstgloc -view -force -host $your_windows_view_server \
> -hpath $p -gpath $p viewstore $p

This would create a "stgloc" which can be used in mkview:

$ cleartool mkview -tag <tag> -stgloc viewstore (or -auto)

Users can also select this stgloc in the Clearcase Explorer GUI. Views will be placed on $your_filer and served by $your_windows_view_server (meaning view_server processes will run there and that that machine should have a static IP).

Views can be cross tagged into the Linux region with:

$ cleartool mktag -view -tag defaria2 -host 10.136.65.5 -hpath \\\\fs-rmna-01\\ccstgloc-cabu\\viewstore\\BROADCOM\\adefaria\\defaria2.vws -gpath /projects/ccstgloc-cabu/viewstore/BROADCOM/adefaria/defaria2.vws
/projects/ccstgloc-cabu/viewstore/BROADCOM/adefaria/defaria2.vws
cleartool: Warning: Storage pathname "/projects/ccstgloc-cabu/viewstore/BROADCOM/adefaria/defaria2.vws"
may not reside on host "10.136.65.5".

Notes:

  • I specified host as an IP address because the test "server" I was using was using DHCP (IOW nslookup pcrmna-ccrmt02 doesn't work from Unix)
  • Backslashes are doubled because bash collapses them
  • The host path (-hpath) must be a valid path from the host's point of view. The host (pcrmna-ccrmt02 in this case) is a Windows box thus a UNC style path is used for -hpath.
  • The global path (-gpath) must be a valid path from the client's point of view. Since we are cross tagging to Linux the path is a Unix style path (in the automount map) of /projects/ccstgloc-cabu/viewstore... You're directory under /projects would be different.
  • View creation and serving on Windows machines is Windows domain aware. What they do is create a directory for the domain (e.g. BROADCOM) then a directory for the user (e.g. adefaria) then the view directory is created (defaria2) with an appended .vws. This is Windows specific behavior, hence you see and additional .../BROADCOM/adefaria/defaria2.vws.
  • You need not use the name or directory "viewstore". This is just an example. I've seen others user the directory name of say vws. Also the stgloc need not be named viewstore - you might use bt-filer-views or whatever.

Now you can similarly create a Unix oriented stgloc if you want:

$ your_share=<your_share>
$ your_linux_view_server=<your_linux_view_server>
$ p=/projects/$your_share/viewstore
$ cleartool mkstgloc -view -force -host $your_linux_view_server \
> -hpath $p -gpath $p viewstore $p

And then your users can cross tag them into the Windows region using the Region Synchronize tool (Note: It will fail initially as it cannot determine what the UNC path needs to be so the users will have to specify that) or by the command line:

$ your_filer=<your_filer>
$ your_share=<your_share>
$ your_linux_view_server=<your_windows_linux_server>
$ p=\\\\$your_filer\\$your_share\\viewstore
$ cleartool mktag -view -tag adefaria_linux -host $your_linux_view_server \
> -hpath /projects/$your_share/viewstore/adefaria_linux.vws \
> -gpath $p\\adefaria_linux.vws $p\\adefaria_linux.vws

The advantages here are:

  • Your Linux server bears the brunt of serving views since the view_server processes run there

The disadvantages are:

  • Users can't create views using this stgloc from Windows
  • Users must cross tag views to their Windows region
  • Windows users don't like the command line.

January 10, 2006

Getting log_activity/stats and pulse to work

  • Re-wrote most Clearcase modules to utilize Clearcase::cleartool and for Clearcase.pm to work out where cleartool resides
  • Changed Mail.pm to only attempt to use MIME:Entity and others if html is requested
  • Got pulse working for /vobs/preftest. If the vob is not present it simply logs that and exists

January 9, 2006

Mail.pm/pulse

  • Worked on Mail.pm
  • Incorporated Mail.pm into Logger
  • Created Element.pm
  • Added code to pulse to mkelem and rmelem