in reply to Re^2: user input behavior from within a subroutine
in thread user input behavior from within a subroutine

So, unless you declare $value up above this snippet, you aren't using strict, which is foolhardy. You seem to be using a string comparison operator (gt) for a numerical comparison, which doesn't seem the best way to skin this cat.

In any case, the following standalone snippet works fine under perl 5.8.8 on a Solaris platform:

#!/usr/local/bin/perl use strict; use warnings; Main: { my @param_names = ('elevation','location_type','point_name','positi +on','road_type','road_type_description','vegetation'); categorize_attributes(\@param_names); } sub categorize_attributes { my ($value_ref) = @_; my @value_add = (); @value_add = @{$value_ref} if ref($value_ref) eq 'ARRAY'; if (scalar(@value_add) > 0){ foreach my $value (@value_add){ print "Is $value an attribute (y or n)? "; my $response = <STDIN>; chomp($response); if ($response =~ /^y$/i){ print "response is $response\n"; print "configure as an attribute\n"; } else { print "response is $response\n"; print "configure as a parser\n"; } } # end foreach $value (@value_add) } }

Update: Modified code sample so that the user input was handled by a subroutine, as specified by the OP.