#!/usr/bin/perl local $/; open(DAT, "output1.txt") || die("Could not open file!"); my $line = ; my $product; if ( $line =~ m/Users of/ ) { $line =~ m@Product(\d+):@; $product = $1; print $product; }