Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

[off-site] Perl snippets at Microsoft

by fglock (Vicar)
on Mar 03, 2005 at 15:20 UTC ( [id://436240]=perlmeditation: print w/replies, xml ) Need Help??

The Script Center Script Repository: Sample Perl Scripts at the Microsoft site.

Before reading the scripts, you may want to see the Copyright notice for the terms of use.

Replies are listed 'Best First'.
Re: [off-site] Perl snippets at Microsoft
by dragonchild (Archbishop) on Mar 03, 2005 at 15:34 UTC
    I peeked at one script and found the following:
    • no strict
    • no warnings
    • no taint
    • foreach my $foo ( in $stuff ) { ... } ... apparently Win32::OLE defines in()?

    I'd be worried if my Windows sysadmin suddenly asked me for my Camel ...

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

      foreach my $foo ( in $stuff ) { ... } ... apparently Win32::OLE defines in()?

      Yes it does:

      use Win32::OLE('in'); ...

      in(COLLECTION) - If COLLECTION is an OLE collection object then in $COLLECTION returns a list of all members of the collection. This is a shortcut for Win32::OLE::Enum-All($COLLECTION).

      The absence of strict, warnings, and taint don't necessarily imply a bad script. I'll grant that they increase the chances that a script doesn't do what are commonly accepted as "bad" things, but they are not necessary. There are some I know that code under strict and warnings, but then remove them when the final cut is made so as not to be anti-social and assume that everyone wants these module loaded. If there was only One True Way to code Perl, those modules wouldn't be modules, they'd be part of the language spec.

      thor

      Feel the white light, the light within
      Be your own disciple, fan the sparks of will
      For all of us waiting, your kingdom will come

        The absence of strict, warnings, and taint don't necessarily imply a bad script.

        No, it doesn't. Each is useful for different purposes.

        • strict is useful is you plan on ever making a change to the thing as it will decrease the time you need to do so safely.
        • warnings is useful is you are a less-experienced developer.
        • taint is useful if you are taking information from an untrusted source.

        Of these three, I would add strict and taint. Warnings are ... annoying in production code. I take it out in my CPAN stuff. I would add taint because I'm not sure what Win32::OLE is going to return to me. I'd like to see if Perl trusts it before I do.

        Being right, does not endow the right to be rude; politeness costs nothing.
        Being unknowing, is not the same as being stupid.
        Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
        Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

      Yes, and? strict is a 100% development aid, warnings mostly is as well, and the majority of the programs doesn't need taint to be turned on. Your complaint sounds like "I don't think this building is good. The constructor didn't leave the scaffoldings".
      I looked at a handful of scripts, and they are similar: a use statement, importing the 'in' function, definition of two constants, three assignments, and a loop, whose body consists of nothing more than print statements.

      Such programs don't really need strict, warnings or taint. I would have 'my'ed the variables, but that doesn't add much.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://436240]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-03-29 07:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found