in reply to How do I split a file into parts
Hi,
If you want to split one file into lot of files use that pattern as your record separator, that is $/.
Try this one ...
If you want to split one file into lot of files use that pattern as your record separator, that is $/.
Try this one ...
#! /usr/bin/perl -w my $infil = $0; my $separator = "XXFFDDF"; local $/ = $separator; sysopen(INFIL,$infil,O_RDONLY) || die "Can't open $infil: $!.\n"; while(<INFIL>){ my $out_file = "$infil.$."; # s/$separator//; ### if you want to remove your file separator also, uncomment above li +ne ..... sysopen(OUT,$file,O_RDWR|O_CREAT|O_EXCL) || die "Can't open for wri +te tst.$.: $!.\n"; print OUT $_; } close(INFIL);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Answer: How do I split a file into parts
by repson (Chaplain) on Nov 23, 2000 at 17:55 UTC |
In Section
Seekers of Perl Wisdom