Hi to all Here is my problem . I'm trying to export this data to SQL database . Here is example data.Don't pay attention on encoding. Every new record is starting --=NewRecord=-- delimiter between fields and data is = . Contact=АГППМП-СЪНИМЕД-ООД Manager= Region=РЗОК Бургас Municipality= НЕСЕБЪР Settlement=ГР.НЕСЕБЪР Address=ул.Рибарска 11 каб.1-2 Phone=43058 Name=Людмил Николов Стаменов - Общопрактикуващ лекар --=NewRecord=-- Contact=АИППМП д-р Р.ДимитровЕООД Manager= Region=РЗОК Бургас Municipality= БУРГАС Settlement=ГР.БУРГАС Address=ул.Хан Крум №28 ет.2 ст.209 Phone= Name=Румен Николаев Димитров - Общопрактикуващ лекар
I was try to adapt some code that i see here and some people are helped me with other things. Here is my code . It's seems that %hashrecord is not after firs asaing to array is not changing anymore . If i try to iniatilze the hash it's seem that i initialize the reference and everything becomes empty. Can anybody give advice how to fill this array of hashes and generate SQL. use strict; use warnings; open FILE,"<TOTAL.txt" or die $!; open OUT,">insert.sql" or die $!; my @data; my $sql; my %hashrecord; my %columns; while(<FILE>){ if(! /--=NewRecord=--/){ my ($fname,$fvalue) = split/=/; $hashrecord{$fname} = $fvalue; } if (/--=NewRecord=--/){push @data, \%hashrecord}; } foreach my $rec (@data) { $columns{$_}++ foreach keys %$rec; } foreach my $rec (@data) { $sql = sprintf "insert into doctors (%s)\nvalues(%s)", join(",", map qq( $_), keys %$rec), join(",", map qq( '$_'), values %$rec); print OUT $sql, "\n"; } Thanks a lot. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/