use strict; use warnings; use File::Spec::Functions qw(:ALL); use feature 'say'; my $testpath = catdir('foo','bar'); #say $testpath; my $sepchar; ($sepchar) = ($testpath =~ m/(\\|\/)/); say $sepchar;