while (my $line = ) { $line =~ s/\n$//; while ($line =~ s/(\w+)\/(\w+)//) { #the {\cM} should create a word boundry since it's not alpha numeric print "key: $1\nvalue: $2\n"; } }