Re: Text file splitter, date/time field



originals@xxxxxxxxx wrote:
>
> I need to split an archive of a discussion forum saved as one huge txt
> file into individual txt files--one per message.
>
> Posts are stamped with a date and time, messages can be of any length.
> Posters are sometimes address by their time (as it was an anon forum)
> but the full time/date stamp is always unique to the start of a
> message.
>
> New to perl but have installed activeperl and can run a .pl script from
> the command line.
>
> If anyone could provide a script for this job, I'd really appreciate
> it.

#!/usr/bin/perl
use warnings;
use strict;

while ( <> ) {

if ( /^\d{2}\.\d{2}\.\d{2} \d{2}:\d{2} [AP]M$/ ) {
chomp;
tr/ /_/;
open OUT, '>', $_ or die "Cannot open $_: $!";
next;
}

print OUT if fileno OUT;
}

__END__



John
--
use Perl;
program
fulfillment
.



Relevant Pages

  • Obtaining complete Unix command line that evoked script as string
    ... If there is a more appropriate list for this, let me know; the other perl lists I've seen seem to specialised for this. ... Note this is not just the arguments of the call to the script, but everything including pipes and redirects, etc., e.g. ... Ideally the perl interpreter would grab the complete command line as its evoked and I'd access this via a variable. ...
    (perl.beginners)
  • Re: Displaying a users group memberships
    ... The user's username is passed to the script via the command line and captured with ARGV. ... I want to determine the group memberships (much like executing `groups` from the command line) and run those through a loop for processing. ... I'm very new to Perl so maybe I'm just looking for the wrong terms or something. ... The format of the command is simple: `test.pl username`, where username is a real username on the system in question. ...
    (perl.beginners)
  • Re: "register" (in perl scripts)
    ... scripted gimp. ... This is a Perl problem, not a GIMP problem so you would probably ... it looks to me like you're trying to execute a command ... By the way, your script doesn't appear to use any CGI, etc. - at ...
    (comp.graphics.apps.gimp)
  • Re: Linux
    ... You almost certainly have Perl already installed. ... But the actual command line interpreter should be the same between them. ... put the shebang line as the first line of the script. ... You can then execute the program ...
    (perl.beginners)
  • 2005-10-23 [de.comp.lang.perl.cgi] FAQ
    ... Programmiersprache Perl in CGI-Scripten. ... Wo gibt es Dokumentation über Perl und CGI? ... Hilfe zum Programm perldoc kann man mit 'perldoc perldoc' ... Mein Script läuft nicht bei meinem Provider. ...
    (de.comp.lang.perl.cgi)