You've got a conditional tacked onto a my-declaration. This has rather unintuitive effects: it contructs a local static variable (in c-speak). This feature/bug is deprecated, and not what you want to do anyway, so you are safe to stick to your second version.
I should be more specific, as dave_the_m below: you get problems if you use statement modifiers on a my. AFAIK the ternary conditional is an expression.