You try this.It is similar to almut's answer but we don't know whether there will be space between UID: and string.Following will solve that problem and it works.
#!usr/bin/perl use strict; use warnings; my @input = ("Supervisor UID: plbaerr4", "UID:dlsmith3", "Peon UID: jklmn2"); open FH,">output.txt" or die "can't open file for writing:$!"; for my $string (@input) { print FH $1 if($string=~/^UID:\s*(\w+)/); } close FH;
In reply to Re: Extracting text from a line
by nvivek
in thread Extracting text from a line
by kirkbrown
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |