ZxCv has asked for the wisdom of the Perl Monks concerning the following question:
any suggestions on how to actually accomplish what i'm going for would be greatly appreciated. :-)open (FIN, "<$ARGV[0]") || die "Input file: $!\n"; open (FOUT, ">$ARGV[0]-randomized") || die "Output file: $!\n"; $flag = 1; #set autoflush on output filehandle $oldfh = select(FOUT); $| = 1; select ($oldfh); while (<FIN>) { if ($flag) { seek (FOUT, 0, 0) || die "Seek to beginning: $!\n"; $flag = 0; } else { seek (FOUT, 0, 2) || die "Seek to end: $!\n"; $flag = 1; } print FOUT $_; } close (FOUT); close (FIN);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: rearrange lines in file
by Limbic~Region (Chancellor) on Mar 04, 2003 at 23:34 UTC | |
|
Re: rearrange lines in file
by tachyon (Chancellor) on Mar 04, 2003 at 23:34 UTC | |
|
Re: rearrange lines in file
by tachyon (Chancellor) on Mar 04, 2003 at 23:47 UTC | |
|
Re: rearrange lines in file
by jasonk (Parson) on Mar 04, 2003 at 23:42 UTC | |
|
Re: rearrange lines in file
by Dr. Mu (Hermit) on Mar 05, 2003 at 04:51 UTC |