trenchwar has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; open (FH, ">students.txt"); print FH "Perry*Steve*234\nSmith*Jane*456\nJones*Mary*567\n"; close (FH); $students="students.txt"; open(FH, $students) or die("Could not open file!"); while(<FH>) { @students = split (/*/, $_); $key = $students[0],$students[1]; $hash{$key} = $students[2]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Open a file and put the contents in a hash with a value
by cosmicperl (Chaplain) on Apr 11, 2008 at 21:54 UTC | |
by trenchwar (Beadle) on Apr 11, 2008 at 22:11 UTC | |
by oko1 (Deacon) on Apr 12, 2008 at 04:03 UTC | |
by trenchwar (Beadle) on Apr 12, 2008 at 18:13 UTC | |
by trenchwar (Beadle) on Apr 11, 2008 at 22:13 UTC |