CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
match string from file

 



gintoddic
New User

Dec 13, 2012, 9:24 AM

Post #1 of 3 (746 views)
match string from file Can't Post

I am trying to match a string in a file up to an "=" sign.
I opened the file, matched a certain line in the file, but than I want to output the string in the line only up to "=".

Example from file.
process13=1|2|3

I want to match only the word process13 after finding it contains the number 3.


BillKSmith
Veteran

Dec 13, 2012, 10:38 AM

Post #2 of 3 (740 views)
Re: [gintoddic] match string from file [In reply to] Can't Post


Code
perl -pe"($_)=(/^(.*)=/)" data_file.txt

Good Luck,
Bill


rovf
Veteran

Dec 14, 2012, 4:26 AM

Post #3 of 3 (733 views)
Re: [gintoddic] match string from file [In reply to] Can't Post

Alternative solution to the one presented by Bill:


Code
(split(/=/,$your_string))[0]


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives