Q: Analyse data and provide a report - Arrays?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Troll

    #31
    Re: Q: Analyse data and provide a report - Arrays?

    Back again...
    I have to say that I'm now in possession of a mostly working script - thanks
    to the both of you and some Google links.

    How can I get the total number of items that has been passed here?
    $UDP6LocalAddre sses{$UDP6Local Address}++;




    "Troll" <abuse@microsof t.com> wrote in message
    news:oCp5b.8049 0$bo1.23838@new s-server.bigpond. net.au...[color=blue]
    > John and Greg,
    > Thanks for the help today [again].
    >
    > I'm sure to have some more Qs tomorrow but right now I need to rewrite the
    > code from my laptop to an external Solaris box. This will also mean my
    > variable definions will change. This little task will take me some time
    > especially that the vi editor I have to use is a less friendly version[/color]
    than[color=blue]
    > the one which comes with my RH9. I then need to test the code on the
    > external system so I don't see myself posting anymore today until same[/color]
    time[color=blue]
    > tomorrow.
    >
    > Cheers,
    > T
    >
    >
    >
    > "John Bokma" <postmaster@cas tleamber.com> wrote in message
    > news:3f5622c2$0 $203$58c7af7e@n ews.kabelfoon.n l...[color=green]
    > > Troll wrote:
    > >[color=darkred]
    > > > Sorry. I tried to improve the visibility a bit as the thread was[/color][/color]
    > scrolling[color=green][color=darkred]
    > > > but I see you point.
    > > > A NG etiquette refresher needed...
    > > > Will keep things in order now and *snip* [what does that stand for?][/color][/color]
    > them[color=green][color=darkred]
    > > > when necessary[/color]
    > >
    > > cut. It is quite common when a large part is removed to state what was
    > > removed, e.g.:
    > >
    > > [cut perl example]
    > >
    > > or
    > >
    > > [snip perl example]
    > >
    > > Sometimes <> is used instead of []. Or even ...
    > >
    > > Most newsreaders provide scrolling by pressing the space bar. Reading a
    > > top post and scrolling down to understand to what it is referring (and
    > > back up and down etc) is always harder than reading bottom down. Most
    > > postings fit on a screen after careful cutting.
    > >
    > > --
    > > Kind regards, feel free to mail: mail(at)johnbok ma.com (or reply)
    > > virtual home: http://johnbokma.com/ ICQ: 218175426
    > > John web site hints: http://johnbokma.com/websitedesign/
    > >[/color]
    >
    >[/color]


    Comment

    • John Bokma

      #32
      Re: Q: Analyse data and provide a report - Arrays?

      Troll wrote:
      [color=blue]
      > Back again...
      > I have to say that I'm now in possession of a mostly working script - thanks
      > to the both of you and some Google links.
      >
      > How can I get the total number of items that has been passed here?
      > $UDP6LocalAddre sses{$UDP6Local Address}++;[/color]

      print "$UDP6LocalAddr esses{$UDP6Loca lAddress}\n";

      or do you mean all?

      There are two ways: summing all hash values or keeping an additional
      counter. The latter means: before your loop:

      my $total_count = 0;

      and after each $UDP6LocalAddre sses{$UDP6Local Address}++; do

      $total_count++;


      --
      Kind regards, feel free to mail: mail(at)johnbok ma.com (or reply)
      virtual home: http://johnbokma.com/ ICQ: 218175426
      John web site hints: http://johnbokma.com/websitedesign/

      Comment

      • Troll

        #33
        Re: Q: Analyse data and provide a report - Arrays?

        Yeah, I was trying this but kept on getting a Global parameter error of some sort:
        Global symbol "" requires explicit package name

        If I use the total_count method it unfortunately counts my section headings as well
        [I ended up simplifying the section searches a bit]


        "John Bokma" <postmaster@cas tleamber.com> wrote in message news:3f5759d8$0 $198$58c7af7e@n ews.kabelfoon.n l...[color=blue]
        > Troll wrote:
        > [color=green]
        > > Back again...
        > > I have to say that I'm now in possession of a mostly working script - thanks
        > > to the both of you and some Google links.
        > >
        > > How can I get the total number of items that has been passed here?
        > > $UDP6LocalAddre sses{$UDP6Local Address}++;[/color]
        >
        > print "$UDP6LocalAddr esses{$UDP6Loca lAddress}\n";
        >
        > or do you mean all?
        >
        > There are two ways: summing all hash values or keeping an additional
        > counter. The latter means: before your loop:
        >
        > my $total_count = 0;
        >
        > and after each $UDP6LocalAddre sses{$UDP6Local Address}++; do
        >
        > $total_count++;
        >
        >
        > --
        > Kind regards, feel free to mail: mail(at)johnbok ma.com (or reply)
        > virtual home: http://johnbokma.com/ ICQ: 218175426
        > John web site hints: http://johnbokma.com/websitedesign/
        >[/color]

        Comment

        • John Bokma

          #34
          Re: Q: Analyse data and provide a report - Arrays?

          Troll wrote:
          [color=blue]
          > Yeah, I was trying this but kept on getting a Global parameter error of some sort:
          >
          > Global symbol "" requires explicit package name
          >
          > If I use the total_count method it unfortunately counts my section headings as well
          > [I ended up simplifying the section searches a bit][/color]

          my $sum = 0;
          foreach my $value (values %UDP6LocalAddre sses) {

          $sum += $value;
          }

          --
          Kind regards, feel free to mail: mail(at)johnbok ma.com (or reply)
          virtual home: http://johnbokma.com/ ICQ: 218175426
          John web site hints: http://johnbokma.com/websitedesign/

          Comment

          • Troll

            #35
            Re: Q: Analyse data and provide a report - Arrays?


            "Troll" <abuse@microsof t.com> wrote in message news:%iJ5b.8299 9$bo1.51458@new s-server.bigpond. net.au...
            Yeah, I was trying this but kept on getting a Global parameter error of some sort:
            Global symbol "" requires explicit package name

            If I use the total_count method it unfortunately counts my section headings as well
            [I ended up simplifying the section searches a bit]


            "John Bokma" <postmaster@cas tleamber.com> wrote in message news:3f5759d8$0 $198$58c7af7e@n ews.kabelfoon.n l...[color=blue]
            > Troll wrote:
            > [color=green]
            > > Back again...
            > > I have to say that I'm now in possession of a mostly working script - thanks
            > > to the both of you and some Google links.
            > >
            > > How can I get the total number of items that has been passed here?
            > > $UDP6LocalAddre sses{$UDP6Local Address}++;[/color]
            >
            > print "$UDP6LocalAddr esses{$UDP6Loca lAddress}\n";
            >
            > or do you mean all?
            >
            > There are two ways: summing all hash values or keeping an additional
            > counter. The latter means: before your loop:
            >
            > my $total_count = 0;
            >
            > and after each $UDP6LocalAddre sses{$UDP6Local Address}++; do
            >
            > $total_count++;
            >
            >
            > --
            > Kind regards, feel free to mail: mail(at)johnbok ma.com (or reply)
            > virtual home: http://johnbokma.com/ ICQ: 218175426
            > John web site hints: http://johnbokma.com/websitedesign/
            > [/color]

            OK, I fixed it.
            It ain't the most pretty of solutions but it works.

            if (/UDP: IPv6/../^$/) {
            my($UDP6LocalAd dress)=
            /^\s+(\S+)/;
            $UDP6LocalAddre sses{$UDP6Local Address}++;
            if (/^$/ || /UDP: IPv6/ || /Local Address/ || /-------/) {
            #do nothing
            } else {
            $AddressCount++ ;
            }
            }


            The following is now totally obsolete but I might leave it in anyway - maybe I'll sort this out later when I'll do some more reading?:
            my($UDP6LocalAd dress)=
            /^\s+(\S+)/;
            $UDP6LocalAddre sses{$UDP6Local Address}++;


            Comment

            • Troll

              #36
              Re: Q: Analyse data and provide a report - Arrays?

              Thanks John - will give it a try.


              "John Bokma" <postmaster@cas tleamber.com> wrote in message
              news:3f57631b$0 $196$58c7af7e@n ews.kabelfoon.n l...[color=blue]
              > Troll wrote:
              >[color=green]
              > > Yeah, I was trying this but kept on getting a Global parameter error of[/color][/color]
              some sort:[color=blue][color=green]
              > >
              > > Global symbol "" requires explicit package name
              > >
              > > If I use the total_count method it unfortunately counts my section[/color][/color]
              headings as well[color=blue][color=green]
              > > [I ended up simplifying the section searches a bit][/color]
              >
              > my $sum = 0;
              > foreach my $value (values %UDP6LocalAddre sses) {
              >
              > $sum += $value;
              > }
              >
              > --
              > Kind regards, feel free to mail: mail(at)johnbok ma.com (or reply)
              > virtual home: http://johnbokma.com/ ICQ: 218175426
              > John web site hints: http://johnbokma.com/websitedesign/
              >[/color]


              Comment

              Working...