in reply to Another Pattern Matching Question
May you wanted something like this:
The if iterate like so:use warnings; use strict; while ( defined( my $filename = <DATA> ) ) { chomp $filename; if ( my ( $product, $year, $month, $day, $hour, $suffix, $ver ) = $filename =~ m/^(.+?)\.(\d{4})(\d{2})(\d{2})(\d{2})\.(.+?)\.(. ++?)\./ ) { print join ' ', ( $product, $year, $month, $day, $hour, $suffi +x, $ver ), $/; } } __DATA__ 3B40RT.2000033121.7.bin.gz 3B40RT.2000033121.7R.bin.gz 3B40RT.2000033121.7RWER.bin.gz
I hope that helps... if ( my ( $product, $year, $month, $day, $hour, $suffix, $ver ) = $filename =~ m/^(.+?) # matches PRODUCT \. (\d{4}) # matches YEAR (\d{2}) # matches MONTH (\d{2}) # matches DAY (\d{2}) # matches HOUR \. (.+?) # SUFFIX matches both 7,7R or 7anythin +g \. (.+?) # VERSION \./x ) { print join ' ', ( $product, $year, $month, $day, $hour, $suffi +x, $ver ), $/; } ...
|
|---|