Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
laziness, impatience, and hubris
 
PerlMonks  

(ar0n) Re: Storing Info

by ar0n (Priest)
on Jan 21, 2002 at 10:08 UTC ( #140322=note: print w/ replies, xml ) Need Help??


in reply to Storing Info

Homework. Just like this one.

Take a look at map and grep. Otherwise, go away.


Update: c has been courteous enough to explain to me this is not homework. For the bluntness, I apologize. The advice to read the documentation still stands, however.


[ ar0n -- want job (boston) ]


Comment on (ar0n) Re: Storing Info
Re: (ar0n) Re: Storing Info
by sickboy on Jan 21, 2002 at 10:19 UTC
    Hey tough guy let's see how u would grep :
    1. The number of people with brown hair and firstnames starting with "j"?

    Look at the problem, don't just throw out grep and map.
    I'm sure i won't hear from you again, and thanks for the reputation points

    Good luck with the job hunt.
      Hey tough guy let's see how u would grep : 1. The number of people with brown hair and firstnames starting with "j"?

      If there's one thing I'm not, it's tough. Girls have won arm-wrestling contests with me.

      Look at the problem, don't just throw out grep and map.
      I did. I know the solution, I am simply not giving it to you, as you seem to be unwilling to put any effort into finding the solution.
      I'm sure i won't hear from you again,

      You appear to be wrong.

      Good luck with the job hunt.

      Thank you.

      [ ar0n -- want job (boston) ]

        you have issues. You must be awful in real life
        Now just go away ar0n, unless you have an answer in code
        You don't...

      Um, ar0n's actually being nice. You should see him on a bad day.

      Normally, your post would have been considered, reaped, and forgotten with no replies to speak of.

      However, it's a weekend, so things are a little slow.

      In any event, this isn't a place where people solve your problems for you. It's a place where you show them what you've tried and they point out places where you might look for the next step.

      I can't speak for ar0n, but I'd probably start by going perldoc -f map and perldoc -f grep.

      That done, I might even try perldoc -q sort hash and see if there's anything in the Friendly Manual provided with the language. (There certainly seems to be one or two things that apply. Have you tried them?)

      Naturally, one can also try the same query on perldoc or (heck, why not live a little?) even here.

      IOW, the Monastery best helps those willing to first help themselves. *That's* why you're getting some insubstantial answers.

      For best results, take what you've been given so far, write some code, and then--if still stuck--post what you have and the specific problem you're working through. We'll help you through problems, but we won't do your [home]work for you.

      --f

        @routes=grep /$line/, @ {$rec->{'ADV'}};
        i want to grep the entire %friends. Every $rec
        For all people with brown hair and name starting with "j".
        Either answer or go away. You think I haven't looked around?

      Reason: (dws) personal attack -- delete

      For more information on this node visit: this

Re: (ar0n) Re: Storing Info
by jepri (Parson) on Jan 21, 2002 at 11:24 UTC
    I thought the general consensus was that we would help people if they had a try at it. He posted code that works, and asked for a better way to do it. I don't see what's so bad about teaching him to do it better (as opposed to at all). map and grep aren't immediately intuitive unless you are already seeped in lisp.

    Why not just tell him to put the conditional into a grep statement and it will spit out the right hashes? It hardly takes more effort than blowing him off. As an added bonus, less people will think that you are a grumpy loser monk.

    ____________________
    Jeremy
    I didn't believe in evil until I dated it.

      He posted code that works,

      Err, actually, he didn't. See dvergin's post.

      I don't see what's so bad about teaching him to do it better (as opposed to at all). map and grep aren't immediately intuitive unless you are already seeped in lisp.

      That's why I told him to take a look at map and grep (implying, "Read the documentation"). I am not 'seeped in Lisp'. In fact, I have just started learning some Common Lisp, yet I've been using map and grep in Perl for quite some time now. I assume he's intelligent enough to understand the definition of grep:

          grep - locate elements in a list test true against a given criterion
        
      And, using that definition, construct something like
      my @matches = grep { ... } keys %friends
      as he is apparently already able to retrieve hash keys.

      Why not just tell him to put the conditional into a grep statement and it will spit out the right hashes?

      Because he can deduce that from reading the documentation on grep. One of Perl's great resources is its extensive documentation. Learning to read the documentation is a good thing, in my opinion.

      As an added bonus, less people will think that you are a grumpy loser.

      So I'm a grumpy loser now?

      [ ar0n -- want job (boston) ]

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2014-04-21 00:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (489 votes), past polls