I have this perl code I am trying to convert to powershell.
foreach my $f ( @file_list ) {
if( $f =~ /^([\d]+)_${base_ver}_([\d]{4})\.zip$/i ){
$pfile = $f;
( $pnum, $pdate ) = ( $pfile =~ /^([\d]+)_${base_ver}_([\d]{4})\.zip$/i ); # need to convert
( $pmon, $pyear ) = ( $pdate =~ /^(\d\d)(\d\d)$/ ); # need to convert
if( ($patch_nbr == 0) || ($patch_nbr == $pnum) ) {
$fcnt++;
}
}
}
I've converted most of it here..
$file_list = Get-ChildItem -force $base_dir
$file_list | foreach-object {
if($_ -match "/^([\d]+)_${base_ver}_([\d]{4})\.zip$/i"){
$pfile = $_
if($patch_nbr -eq 0 -or $pacth_nbr -eq $pnum){
$fcnt++
}
}
}
Not quite sure how to convert the two variables that equal the regex or if there is a better way to convert the perl code to powershell than what I already have.