[go: up one dir, main page]

Menu

[b9e44f]: / misc / concat-lines  Maximize  Restore  History

Download this file

36 lines (32 with data), 865 Bytes

#!/usr/bin/perl

############################################################################
#  misc/concat-lines
#
#  Part of the STXXL. See http://stxxl.sourceforge.net
#
#  Copyright (C) 2007 Johannes Singler <singler@ira.uka.de>
#  Copyright (C) 2010 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
#
#  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");