Minggu, 13 Februari 2011

Powershell - Bruce Payette ql Function

While reviewing some of Shay Levy's Powershell on Luhn validation:
http://scriptolog.blogspot.com/2008/01/powershell-luhn-validation.html
I noticed a comment referring to Bruce Payette's ql function trick. Having never heard of this, I Googled a bit and found this:
http://blogs.msdn.com/b/powershell/archive/2007/03/01/year-of-the-pig-revisited-the-magic-of-ql.aspx
Using the following function:
function ql
{
$args
}
you can save yourself a lot of typing. For instance, if you want to just enter a long string within having to retype it, you can use this pattern:
function ql {$args}
ql Pig Rat Ox Tiger Rabbit Dragon Snake Horse Goat Monkey Rooster Dog
which will then proceed to echo back all the content of the $args collection in order.
Pig
Rat
Ox
Tiger
Rabbit
Dragon
Snake
Horse
Goat
Monkey
Rooster
Dog
In the context of Shay's post, the commenter added this:
function ql{$args}
test-luhnnumber (ql 0 6 6 2 4 9 1 8 9 2 3)

0 komentar:

Posting Komentar

 
Powered by Blogger