Regardless, here is an example you could study and hopefully modify for your own needs... #!/usr/bin/env perl use strict; use warnings; my @nodes; #Change the input record separator so that the #readline operator reads newline-separated records local $/ = ; while (my $record = <DATA>){ chomp $record; my %node; #find and store each of the pieces of info we care about for my $key (qw/on_off address