if ($_ =~ /ORG\:(.+)/) { # $1 in scope A if ($1 =~ /^(.+)\;(.+)\;(.+)$/) { # $1 now in scope B $card{'org'}=$1; $card{'div'}=$2; $card{'dept'}=$3; } # $1 now in scope A again elsif ($1 =~ /^\;(.+)\;(.+)$/) { # $1 now in scope C