#!/usr/bin/perl -- use strict; use warnings; use File::Find::Rule qw/ find rule /; use Path::Tiny qw/ path /; my $root = path( grep defined, shift, '.' )->realpath; for my $file ( find( name => qr/R2_001.fastq$/ , in => $root ) ){ OneThing( $file ); } for my $file ( find( name => qr/R1_001.fastq$/, in => $root ) ){ TwoThing( $file ); } exit 0;