Advertisement
hakonhagland

for-loop-map-prefix

May 23rd, 2021
1,721
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.23 KB | None | 0 0
  1. use feature qw(say);
  2. use strict;
  3. use warnings;
  4.  
  5. my @abc = ('1234.txt', '2345.txt', '3456.txt', '4567.txt');
  6. my @xyz;
  7. for my $abc (@abc) {
  8.     my ($prefix) = $abc =~ /(\d*).txt/;
  9.     say "$prefix";
  10.     push @xyz, $prefix;
  11. }
  12.  
  13.  
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement