in reply to How to generate files based on some special character?
Just for fun ;)
#!/usr/bin/perl -w use strict; use autodie qw(open close); { undef $/; my %file = ($1 => split /<\s*(.+)\n/ , <DATA>); map { $_ and open my $fh, q{>}, $_; select $fh; print $file{$_} and close; } keys %file; } __DATA__ < file1.txt line1 of file1 line2 of file1 line3 of file1 line4 of file1 < file2.txt line1 of file2 line2 of file2 line3 of file2 < file3.txt line1 of file3 line2 of file3 line3 of file3 line4 of file3
hth,
PooLpi
'Ebry haffa hoe hab im tik a bush'.
Jamaican proverb
|
---|
In Section
Seekers of Perl Wisdom