#!/usr/bin/perluse strict;use warnings;my $csv_file="@ARGV";my %struct_hash;##### functionssub read_csv { my @csv; open my $fh, "$csv_file" or die "bad file: \"$csv_file\" - can't open\n"; push(@csv, "$_") while(<$fh>); close $fh; return @csv;};## builds %struct_hash with following inside:## `$struct_hash{$_}->{'str'}` is utf8 string decr## `$struct_hash{$_}->{'parent'}` full parent addrress## `$struct_hash{$_}->{'plen'} = $len_par;` parent's length### here we go first with initializing $struct_hash and adding 'str'sub build_struct_hash { my %struct_hash; foreach(read_csv()) { my($pos_xy, $pos_str) = split(/;/, "$_"); $pos_xy =~ s/\D//g; my $len = length($pos_xy); $pos_str =~ s/\r//g; chomp($pos_str); $struct_hash{$pos_xy} = {}; $struct_hash{$pos_xy}->{'str'} = $pos_str; $struct_hash{$pos_xy}->{'parent'} = substr($pos_xy, 0, ($len - (sqrt(4*$len+1)-1))); $struct_hash{$pos_xy}->{'plen'} = length($struct_hash{$pos_xy}->{'parent'}); }; return %struct_hash;};########### main body:%struct_hash = build_struct_hash();########## user body:## example# for work with all keys we need to do it like this:foreach(sort {$a <=> $b} keys(%struct_hash)) { print "$_ ", length, " $struct_hash{$_}->{'str'}"; print "\r\t\t\t\t\t\t\t\t\t\t\t\t\t$struct_hash{$_}->{'parent'} $struct_hash{$_}->{'plen'} $struct_hash{$struct_hash{$_}->{'parent'}}->{'str'}\n";};exit;