I have file, which is called map_file. According to map_file's last column data, i need a output file, which has repeats as like the map_file's last column name.
In your output file the first directory is repeating, do you want first directory name only, if yes then how many times you want to repeat the same thing ?
As per the final coumn data of map_file, output_file need repeats.(i.e Number of repeats will be the number of data's in final column of the map_file data.)
#!/usr/bin/perl
use warnings;
my ($line,$lastfield);
open (FILE,"map_file.txt") || die "canot open file:$!";
while ($line = <FILE>)
{
chomp ($line);
@arr=split(/\s+/,$line);
$lastfield=$arr[$#arr];
print "$lastfield\n";
print "RFG {\n\tNAME=$lastfield\n\tDG=warn\n\tACCESS=\n\t}"
}