Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Extracting text from a line

by nvivek (Vicar)
on Jul 12, 2010 at 04:23 UTC ( #848920=note: print w/ replies, xml ) Need Help??


in reply to Extracting text from a line

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;


Comment on Re: Extracting text from a line
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://848920]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2015-07-29 10:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls