Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Getting string value after = operator

by Bilbo (Pilgrim)
on Feb 12, 2003 at 11:56 UTC ( [id://234656]=note: print w/replies, xml ) Need Help??


in reply to Getting string value after = operator

I'm not quite sure what you're asking. Example input and output and your script as it is at the moment are generally helpful to clarify the question.

I assume from your title and first part of your question that given a string you want to get any text after an equals sign, and that then you know how to put it in a file, or whatever you want to do with it. If so then this might help:

#!/usr/bin/perl -w use strict; my $string = "name = arrunich"; if ($string =~ m/= \s* (\S+)/x) { print "$1 \n"; }

This uses a regular expression which looks for an = sign followed by zero or more spaces, followed by one or more non-spaces. If it finds it then it puts the non-spaces in $1.

You might find String matching and Regular Expressions useful.

Update: First paragraphs added

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-03-29 00:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found