Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

davorg (18)

Yahoo! ID: daveorguk (Add User, Send Message)

Hacker, author, trainer

Technorati Profile []

Journal of davorg (18)

Sunday March 31, 2002
10:57 AM

We Like Perl

[ #3886 ]

Every once in a while I come across something that reminds me why I love Perl so much. This happened to me again this morning.

I had a file that needed to be split into a number of files. The start of each new file was indicated with a line that looked like:

==== file.ext ====

where "file.ext" is the name of the new file.

The Perl code to split the file looks like this:

while (<>) {
  if (/==== (.*) ====/) {
    close STDOUT;
    open STDOUT, ">$1" or die "Can't open $1: $!\n";
  } else {

Which is a lot simpler than I was expecting when I started to write it.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Ooh, cute.
    It does have something to it.

    Esli epei eto cumprenan, shris soa Sfaha.
    Aettot ibrec epesecoth, spakhea scrifeteis.