Eric Preece wrote: > > Hello, Hello,
> Yet another newbie question. I have a file, each line is a > pipe delimited list (user name and password). I want to open > the file, search through each line using the first entry as > a key (so this may turn into a question about hashes, but I > am not sure). If I get a positive result I want to execute > some logic, if not then bail out. My confusion is my inability > to properly search through each line. If I open the file and > read it into an array I get each line as an element of the > array, not what I wanted. ex: > > use strict; > use warnings; > use CGI qw/:standard/; > my $path = "D:/crap/names.txt"; > > open(FILE, $path) or die ("Couldn't open file - !$\n"); ^^ $! > @array = <FILE>; > close (FILE) or die ("Couldn't close file - !$\n"); > print $array[0]; > > This prints the first element of the array - name|value. What > I want is to be able to search for a name then if I have a > name match perform some operations (comparing the value with > a var). I need to be able to search through the name array > elements for a sub-set of the array elements. Make sense? my @found = grep /^user name\|/, <FILE>; > I suspect I will need to put the data into a hash but I do not > know how to convert an array where elements = name|value into > a hash = key|value. my ( $name, $value ) = split /\|/; $hash{ $name } = $value; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]