#!/usr/bin/env perl use warnings; use strict; while () { print $2 . "\n" if /(\d)\st=(\w+)/; } __DATA__ 0 1 t=something 2 t=3foo7bar