Saturday, February 5, 2011

Dryloc Water Proofing

Useful: B:: Deparse and B:: Concise

In OTRS morning I found the following diff :
 
--- UnitTest.pm February 2, 2011 09:20:20 -0000 1:46
+ + + UnitTest.pm February 4, 2011 23: 37:31 -0000 1:47
@ @ @ @ -265.4 +265.7
}}

+ elsif (system 'uname-s' eq 'FreeBSD') {$ result summary
+ {vendor} = 'FreeBSD' . system 'uname-r';
+} else {

$ Result summary {vendor} = 'unknown';
There are with me right jumped all the alarm bells - this can not work. If only that "system" the result (say, the output) of the executed command does not return.

But in order to show the author of the code, what actually happens, you can B:: Deparse and B: take Concise . For the test, I then took a one-liner, but who exactly reproduces the code above.

B:: Concise

 $ perl-MO = Concise,-exec-e 'print "yes \\ n" if system "uname-s" eq "Linux"' 
a <0> enter
2 <;> next state (main 1 -e: 1) v
3 <0> push mark s
4 <$> const [SPECIAL sv_no] s
5 <@> system [t2] sK
6 <|> and (other-> 7) vK / 1
7 <0> push mark s
8 <$> const [PV "yes \\ n "] s
9 <@> print vK
a <@> leave [1 ref] VKP / REFC
-e syntax OK

shows the same yet another problem: precedence! The "eq" is executed before the "system". The "eq" returns "false" (sv_no) and passes to the "system". A "system sv_no" always worked - at least on Ubuntu ...

But what is actually executed? This can be with B:: View Deparse:

 $ perl-MO = Deparse-e 'print "yes \\ n" if system "uname-s" eq "Linux"' 
print "yes \\ n" if system 1;!
-e syntax OK

As you can see The two modules may very well help to identify problems. About a couple of B:: *- modules I have in the way of Spring 2009 issue of $ foo written about how B:: Concise with Präzendenz problems, help in the summer of 2008 output.

0 comments:

Post a Comment