in reply to Help:getting parts of the strings from a file into managable variables

I think this problem is a little advanced for someone "very new" to Perl. Do you understand the basic data structures of perl (perldoc perldata)? Do you have a fair understanding of regular expressions (perldoc perlretut)? How about references (perldoc perlreftut)? If you have a pretty good grasp of those concepts, you should be able to take a stab at this problem.

Generally, it's recommended that you use a module to parse XML type data files, but a quick and dirty solution might go like this:

use strict; use warnings; my %info; my $thisuser; while (<DATA>) { my ($var, $val) = /<([^>]+)>([^<]+)/; if ($var eq 'UserID') { $thisuser = $val; } else { $info{$thisuser}{$var} = $val; } } use Data::Dumper; print Dumper(\%info), "\n"; __DATA__ <UserID>46786<UserID> <start>2004-10-21TO09:57:25Z</start> <dev>Some Text</dev> <var1>some string</var1> <var2>some string</var2> <USerID>57864</UserID> <start>2004-10-25TO09:57:25Z</start> <dev>Some Text</dev> <var1>some string</var1> <UserID>46786<UserID> <var3>some string</var3> <var4>some string</var4> <UserID>98766</UserID> <start>2004-10-21TO09:57:25Z</start> <dev>Some Text</dev> <var1>some string</var1> <var2>some string</var2> <var5>some string</var5> <var6>some string</var6> <USerID>57864</UserID> <var4>some string</var4> <var6>some string</var6>

Caution: Contents may have been coded under pressure.