LF has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w # Sort out the input and output files my ($infile, $dir) = @ARGV; defined($infile) && defined($dir) || usage(); $infile && $dir || usage(); $record_count = 0; $record_element = 'rdfescription'; $filename_element = 'dc:identifier'; #Create Infile if (@ARGV > 0) { open(INFILE, "<$ARGV[0]") || die "Failed to open $ARGV[0]\n"; $infile = "INFILE"; } else { $infile = "STDIN"; } #Create Outfile if (@ARGV > 1) { open(OUTFILE, ">$ARGV[1]/$record_count.xml") || die "Failed to open $A +RGV[1]/$record_count.xml\n"; $outfile = "OUTFILE"; } else { $outfile = "STDOUT"; } else print OUTFILE ("New Information"); #$stop = ((INFILE == $record_element) || (INFILE == eof)); #if ($stop) close (INFILE); close (OUTFILE); sub msg { print @_, "\n"; } sub usage { msg("Usage: $0 <file> <directory>"); exit(1); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Script to Parse 1 large xml file to many smaller files
by edan (Curate) on Aug 09, 2004 at 19:03 UTC | |
|
Re: Script to Parse 1 large xml file to many smaller files
by murugu (Curate) on Aug 10, 2004 at 04:30 UTC |