#!/usr/bin/perl use strict; use IO::Handle; open(OUT,">>posoutfile.txt"); #open output file for appending so multi writes can happen open(IN, "posfile.txt"); ## this file will be growing open input for reading while (<IN>){ # read each line of posfile.txt ($line) = split(/\|/,$_); # split each line with the | print OUT $line if ($line =~ //); # match using a regex to capture what ur lookin for and print to OUT } close IN; close OUT;