We help IT Professionals succeed at work.

Adding a line in a $_ system that is pattern matched to another variable?

teksavers
teksavers asked
on
290 Views
Last Modified: 2010-04-17
I have a system variable $_ that includes multiple lines of text.

One of the lines of text in the $_ variable reads:

                      Pattern: This is the line I want to assign to my variable.

The line includes several blank spaces or tabs before the start of the text, but I don't want these spaces to be assigned to my variable.

I can perform a pattern match and print the desired result with:

#/^(Pattern):\s+/i && print $_, "\n";

The result of this line of code is:

Pattern: This is the line I want to assign to my variable.

-----------------

I am simply trying to assign the result to another variable and am having a hard time finding the right code.  

I want to end up with $variable = "Pattern: This is the line I want to assign to my variable";

Regards,

Juan S.

 
Comment
Watch Question

Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.