Thread Datei in einen Hash einlesen (20 answers)
Opened by crojay at 2011-04-14 01:34

FIFO
 2011-04-20 10:50
#147878 #147878
User since
2005-06-01
469 articles
BenutzerIn

user image
2011-04-20T06:58:13 crojay
Hi,
%exportHash = map { chomp; split /=/, $_, 2; } <HASHFILE>;

wobei ich ein Problem habe mit leerzeichen.


Whitespace ums '=' mit in die RegEx nehmen:
Code (perl): (dl )
%exportHash = map { chomp; split /\s*=\s*/, $_, 2; } <HASHFILE>;


Gruß FIFO

[Edit] Erklärung: Dein Muster macht aus "page1 = 12" Folgendes: $exportHash{'page1 '} = ' 12'
Last edited: 2011-04-20 11:10:54 +0200 (CEST)
Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it? -- Brian Kernighan: "The Elements of Programming Style"

View full thread Datei in einen Hash einlesen