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



gintoddic
New User

Dec 13, 2012, 9:24 AM


Views: 1477
match string from file

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


Views: 1471
Re: [gintoddic] match string from file


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

Good Luck,
Bill


rovf
Veteran

Dec 14, 2012, 4:26 AM


Views: 1464
Re: [gintoddic] match string from file

Alternative solution to the one presented by Bill:


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