Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Adding object identifiers corresponding to matched headers and sub-headers.

by Kiran Kumar K V N (Initiate)
on Jan 16, 2007 at 19:24 UTC ( #594963=perlquestion: print w/replies, xml ) Need Help??

Kiran Kumar K V N has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Adding object identifiers corresponding to matched headers and sub-headers.

Replies are listed 'Best First'.
Re: Adding object identifiers corresponding to matched headers and sub-headers.
by talexb (Chancellor) on Jan 16, 2007 at 20:01 UTC

    Kiran,

    This is a *Perl* site for *Perl* questions. In some cases the problem domain overlaps a little with Unix/Linux, Apache, SQL, mod_perl and networking areas of expertise -- that's OK. However, here you're asking us to write a complete answer, without having tried anything (well, anything that we can see here, anyways), and that's just not on.

    It seems you want to generate some kind of report, based in some input files. Well, in broad terms, the solution is

    • Read the data into some kind of hash or array data structure, making the appropriate connections between the data as necessary;
    • Make further appropriate connections, possibly simplifying the data structure; and
    • Dump out the data structure in some sort of suitable format.
    So good luck with that.

    And let us know when you have a Perl question that we can help with. ;)

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Adding object identifiers corresponding to matched headers and sub-headers.
by Tanktalus (Canon) on Jan 16, 2007 at 19:33 UTC

    Kiran - you need to learn to boil down your questions, use <readmore> and <code> tags where appropriate, and provide the code you've attempted to use (and how it is not fitting your requirements). And, preferably, concentrate on a single problem at a time - not a bunch of "operations". Your posts feel like an abuse of the monks. At the very least, scanning them has become an abuse on my eyes...

    My "Inputs" therefore are to read the PerlMonks FAQ thoroughly before posting anything further.

Re: Adding object identifiers corresponding to matched headers and sub-headers.
by ikegami (Patriarch) on Jan 16, 2007 at 19:50 UTC
    This again? Show us what you already have. People have provided code on this subject for you before, so you must have something to go on. You are either wasting our time by not showing what you already have, or wasting our time by ignoring our replies.
Re: Adding object identifiers corresponding to matched headers and sub-headers.
by NovMonk (Chaplain) on Jan 16, 2007 at 20:30 UTC
Re: Adding object identifiers corresponding to matched headers and sub-headers.
by talexb (Chancellor) on Jan 17, 2007 at 18:43 UTC

    If I wanted to produce the following result

    Header stuff 123456|987|12 Apples|9 Oranges|19 Bananas|4 Footer junk Header stuff 123456|987|34 Apples|7 Oranges|15 Bananas|11 Footer junk Header stuff 123456|987|56 Apples|3 Oranges|9 Bananas|8 Footer junk

    from the two input files fake1.dat

    Header stuff 123456|987|12 Apples|4 Oranges|12 Bananas|3 Footer junk Header stuff 123456|987|34 Apples|5 Oranges|7 Bananas|8 Footer junk Header stuff 123456|987|56 Apples|2 Oranges|1 Bananas|3 Footer junk

    and fake2.dat

    Header stuff 123456|987|12 Apples|5 Oranges|7 Bananas|1 Footer junk Header stuff 123456|987|34 Apples|2 Oranges|8 Bananas|3 Footer junk Header stuff 123456|987|56 Apples|1 Oranges|8 Bananas|5 Footer junk

    I would probably write a script like this to do it:

    See if that helps you.

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Re: Adding object identifiers corresponding to matched headers and sub-headers.
by Melly (Hermit) on Jan 19, 2007 at 23:30 UTC

    <update>I've fixed a potential bug since the original posting - btw you don't specify what should happen if the header+subheader+object only appears in one file (either file 1 or file 2) - currently, they will still be reported.</update>

    Kiran, try the following code. A couple of things (since I can't believe that this will be the end of it).

    1. You have some lines that look like sub-headers, but the first set of digits is an ip address, not a simple numeric-string - how should these be treated?
    2. You haven't really specified your output format.

    BTW I doubt I'm doing you any favours writing your code - I don't know whether you are over your head at school or in a job, but you're digging yourself in deeper. Unless you're in management, or training for management, in which case you're doing fine. That said, learn to write better specifications (unless you're shooting for the golden ring, and going for upper management).

    Here's the latest code...

    map{$a=1-$_/10;map{$d=$a;$e=$b=$_/20-2;map{($d,$e)=(2*$d*$e+$a,$e**2 -$d**2+$b);$c=$d**2+$e**2>4?$d=8:_}1..50;print$c}0..59;print$/}0..20
    Tom Melly, pm@tomandlu.co.uk
      I doubt I'm doing you any favours writing your code

      You're certainly not doing PerlMonks any favors... which I would hope, at this point, would be of more concern to you.

      A word spoken in Mind will reach its own level, in the objective world, by its own weight

        I'm not entirely sure how this impacts on PM in a negative way - can you elaborate?

        map{$a=1-$_/10;map{$d=$a;$e=$b=$_/20-2;map{($d,$e)=(2*$d*$e+$a,$e**2 -$d**2+$b);$c=$d**2+$e**2>4?$d=8:_}1..50;print$c}0..59;print$/}0..20
        Tom Melly, pm@tomandlu.co.uk

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2023-12-11 19:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (41 votes). Check out past polls.

    Notices?