gavintokyo has asked for the wisdom of the Perl Monks concerning the following question:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Match into scalar
by shmem (Chancellor) on Jun 08, 2007 at 09:13 UTC | |
raises a question. What is your backtick mminfo command giving back? a bunch of lines? If so, they are a single long string which you assign to $call. Then you iterate over that string, which gets aliased as $_ inside the loop, do a match and output just all the stuff your backtick command returned. The foreach loop is executed once. Want to iterate over the lines your mminfo yields? Break that string up with split. Then your code would look like
<update> You can also say @calls = `cmd`, the output of cmd will be split with $/ (see perlvar).</update> Another way to do that is using a pipe open:
Use captures if you don't want the whole line but part of it, e.g.
And append updates to your post, don't change the original content without a proper note, since you render the replies already given to you useless. Read the PerlMonks FAQ, section Posting on PerlMonks, there How do I change/delete my post?. --shmem
| [reply] [d/l] [select] |
|
Re: Match into scalar
by blazar (Canon) on Jun 08, 2007 at 08:44 UTC | |
I Trying to do a match on a scalar and put only the matching words into another scalar, I'm skipping your code because it doesn't seem to bear any relation to your actual question. However I notice an issue here... you talk about "matching words" which is a plural and putting them into "another scalar" which is a singular. Now, this is somewhat odd. Of course you may join the matched words on spaces and assign the resulting string to a scalar. Otherwise just use an array instead. For example, suppose you want to match "words" beginning with "a":
or, as hinted above:
Else, I don't know how to help you further without you giving us any further detail. | [reply] [d/l] [select] |
|
Re: Match into scalar
by johngg (Canon) on Jun 08, 2007 at 08:58 UTC | |
to
and change the loop so that you are matching against each line returned which will be in $_, not $call.
I hope this is of use. Cheers, JohnGG Update: The OP seems to be a work in progress with silent updates occurring willy-nilly. The code problems I addressed in this reply no longer appear in the OP. | [reply] [d/l] [select] |
|
Re: Match into scalar
by GrandFather (Saint) on Jun 08, 2007 at 07:06 UTC | |
Show us some code, some output, and what you expect/desire to see. Read I know what I mean. Why don't you?. DWIM is Perl's answer to Gödel | [reply] |
|
Re: Match into scalar
by naikonta (Curate) on Jun 08, 2007 at 07:47 UTC | |
If you have a question on how to do something in Perl, or you need a Perl solution to an actual real-life problem, or you're unsure why something you've tried just isn't working... then this is the place to ask.Well, I can see you seem to have a problem, but you don't have a question, so I don't know what kind of solution do you expect. Because you probably know what you mean, but I don't. Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy! | [reply] |
|
Re: Match into scalar
by shandor (Monk) on Jun 08, 2007 at 18:36 UTC | |
There is a great Listserv forum for NetWorker where you can get all sorts of help with NetWorker and how to use programming languages around it. Check out these listserv archives for more information. | [reply] [d/l] |
|
Re: Match into scalar
by Moron (Curate) on Jun 08, 2007 at 12:50 UTC | |
__________________________________________________________________________________
^M Free your mind!
| [reply] [d/l] |