header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

eliminating temporary variable
Last Post 30 Apr 2008 01:02 PM by halr9000. 1 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
johndcookUser is Offline
New Member
New Member
Posts:7

--
30 Apr 2008 11:26 AM  

I've written a one-liner that munges the contents of the clipboard using the PSCX cmdlets get-clipboard and out-clipboard. I needed to replace each block of whitespace with a comma. How could I eliminate the temporary variable $a?

$a = get-clipboard; $a -replace '\s+', ',' | out-clipboard 

Thanks.

halr9000User is Offline
Basic Member
Basic Member
Posts:316

--
30 Apr 2008 01:02 PM  
No problem, just add parentheses. (get-clipboard) -replace "foo" | out-clipboard

Otherwise, the parser will try to pass -replace to get-clipboard as a parameter.
You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer