Hi, what have you tried, and how did it not work for you?
Update: ahh, what's the use? Don't copy this:
Output:use strict; use warnings; use feature 'say'; use Path::Tiny; my %file_map = ( tag1 => Path::Tiny->tempfile, tag2 => Path::Tiny->tem +pfile ); chomp( my @lines = <DATA> ); for ( @lines ) { my ( $txt, $tag ) = split / : /; path( $file_map{ $tag } )->append("$txt\n"); } for ( keys %file_map ) { say $file_map{ $_ }; say $file_map{ $_ }->slurp; } __END__ test/foo/bar : tag1 test/abc/xyz : tag1 test/def/abc : tag2 test/bar/foo : tag2 test/dummy/foo : tag1
perl 1206430.pl /tmp/k6iEPAjgjR test/def/abc test/bar/foo /tmp/aFliecLlJN test/foo/bar test/abc/xyz test/dummy/foo
In reply to Re: Break a file into seperate files based on string match
by 1nickt
in thread Break a file into seperate files based on string match
by hvirani
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |