![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Perl split function equivalent It is definate that PowerShell is very powerful with hooks to WMI and so forth but it appears to be lacking of some string manipulation functions. I am a newbie to PowerShell but I cannot find anything close to the Perl split. I found a regex split but that isn't what I really needed. What I need is: my ($f1,$f2) = split (/,/, $record); my $total = $f2 + $count; to split the fields delimeted by a comma, then I would like to deal only with field two. Is this possible? Thanks in advance |
| | #2 (permalink) |
| Guest | Re: Perl split function equivalent PS C:\TEMP> $line = "one,3" PS C:\TEMP> $total = $line.split(",")[1] + $count -- William Stacey [C# MVP] PCR concurrency library: www.codeplex.com/pcr PSH Scripts Project www.codeplex.com/psobject "Frank" <Frank@discussions.microsoft.com> wrote in message news:F807C9A2-F28F-479C-88AA-C50AF166010D@microsoft.com... | It is definate that PowerShell is very powerful with hooks to WMI and so | forth but it appears to be lacking of some string manipulation functions. I | am a newbie to PowerShell but I cannot find anything close to the Perl split. | I found a regex split but that isn't what I really needed. What I need is: | | my ($f1,$f2) = split (/,/, $record); | my $total = $f2 + $count; | | to split the fields delimeted by a comma, then I would like to deal only | with field two. Is this possible? | | Thanks in advance | | |
| | #3 (permalink) |
| Guest | Re: Perl split function equivalent Hi, PS > "1,2,3".split(',') 1 2 3 PS > $a,$b = "1,2,3".split(',') PS > $a 1 PS > $b 2 3 PS > $a + [Math]::Pi # Note $a was parsed as a string. 13.14159265358979 PS > [int]$a + [Math]::Pi 4.14159265358979 PS > You will also want to read up on the -match and -replace operators, which are sometimes convenient for pattern matching. The most important cmdlet to know and use often is Get-Member. As a Perl user the trickiest cmdlets for you will be Get-Content, Set- Content, Get-ChildItem. Mike On Feb 14, 6:20 pm, Frank <F...@discussions.microsoft.com> wrote: > It is definate that PowerShell is very powerful with hooks to WMI and so > forth but it appears to be lacking of some string manipulation functions. I > am a newbie to PowerShell but I cannot find anything close to the Perl split. > I found a regex split but that isn't what I really needed. What I need is: > > my ($f1,$f2) = split (/,/, $record); > my $total = $f2 + $count; > > to split the fields delimeted by a comma, then I would like to deal only > with field two. Is this possible? > > Thanks in advance |
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem using split function | Meat | VB Script | 4 | 07-23-2008 11:25 AM |
| can I install Perl on Vista? | anna | Vista General | 5 | 03-09-2008 02:09 PM |
| Split function | IT Staff | PowerShell | 6 | 10-24-2007 01:48 PM |
| Is there an equivalent of the DOS pause function | Fil | PowerShell | 3 | 11-22-2006 04:14 PM |
| What I think of the Office2007 and Vista Perl.... | John Jay Smith | Vista General | 0 | 09-01-2006 01:42 PM |