#!/usr/bin/perl ############################################################################ # misc/concat-lines # # Part of the STXXL. See http://stxxl.sourceforge.net # # Copyright (C) 2007 Johannes Singler # Copyright (C) 2010 Andreas Beckmann # # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) ############################################################################ # Concatenate the lines of file $ARGV[0] which both satisfy regular expression $ARGV[1] $regex = $ARGV[0]; shift; $former = ''; while($line = <>) { if(!($line =~ /$regex/) || !($former =~ /$regex/)) { print("\n"); } else { print("\t"); } chomp($line); print($line); $former = $line; } print("\n");