#! /usr/bin/perl -w use strict; use Data::Dumper; my @fields = qw/ inc_albums inc_genres /; my %record; my $content = "inc_albums=asdf\n"; foreach my $field (@fields) { ($record{$field}) = $content=~/${field}=(.*?)\n/; } print Dumper(\%record);
$VAR1 = { 'inc_genres' => undef, 'inc_albums' => 'asdf' };
In reply to Re: Changing variable names in a loop
by superfrink
in thread Changing variable names in a loop
by Mad_Mac
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |