#!/usr/bin/perl -w use strict; use 5.10.0; while (<DATA>) { chomp; process_path($_); } sub process_path { my $path = shift; if ( $path =~ m{^.*/home/(.*)/\.forward} ) # m[...] or # m|...| works also { say "i've got >$1<"; } else { say "ups >$path<"; } } =prints i've got >aaa< i've got >bbb< i've got >ccc< i've got >ddd< =cut __DATA__ /home/aaa/.forward /home/bbb/.forward /home/ccc/.forward /home/ddd/.forward
In reply to Re^3: Why this simple code doesn't work?
by Marshall
in thread Why this simple code doesn't work?
by uksza
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |