I have some Problem about the Splitting into an Array.
I want to split an empty line and save to an Array.
1.) First I read the File and save to a String ($configdata).
2.) Then I want split the String ($configdata) with the empty line.
My Script:
#!/usr/bin/perl
use strict;
my $pathconfigfile = 'config.conf';
my @configline;
open(my $configfile, "<", $pathconfigfile);
while(<$configfile>){
my $configdata = $_;
my @configdata = split /\n\n/, $configdata;
print @configdata[0] "\n";
print @configdata[1] "\n";
print @configdata[2] "\n";
}
close $configfile;
Configfile:
Testingtttttttttttttttttttttttt
############################################
0987654345678909876MN09uz6t56789oiuhgölkjhgfr
0987654323456789098765fgnloiuztlkjhgfrtzuiknb
MegaMixoiuzt
############################################
09876543457890098765NSUDlkjhzgtfr67899ztz9098
098765435678987t87656789876567898765679097658
TESTINGPARTS
############################################
0987654567890098765hzzasza654567uhgdjdjfacdaa
9876545678987654mchfuiaq754567898765434567876
My Wish Result:
print @configdata[0];
Testingtttttttttttttttttttttttt
############################################
0987654345678909876MN09uz6t56789oiuhgölkjhgfr
0987654323456789098765fgnloiuztlkjhgfrtzuiknb
print @configdata[1];
MegaMixoiuzt
############################################
09876543457890098765NSUDlkjhzgtfr67899ztz9098
098765435678987t87656789876567898765679097658
print @configdata[2];
TESTINGPARTS
############################################
0987654567890098765hzzasza654567uhgdjdjfacdaa
9876545678987654mchfuiaq754567898765434567876