greetings.

cool beans!  What perldoc has ###- -### in it?
...marked with...?    for me is not enough of an explanation.  sorry.


yes as I read in programming perl as well lead me to this solution.  On pg.
93 it states

" =~ binds a string expression to a pattern match, substitution, or
translation.  These operations would otherwise search or modify the string
contained in $_.  The string you want to bind is on the left while the
operator is put on the right.  The return value indicates the success or
failure of the operator on the right, since the binding operator doesn't
really do anything on its own."


thanks, !
derek



                                                                       
             John Doe                                                  
             <security.departm                                         
             [EMAIL PROTECTED]>                                              To
                                       beginners@perl.org              
             03/06/2005 07:43                                           cc
             PM                        [EMAIL PROTECTED]          
                                                                   Subject
                                       Re: reg exp                     
             Please respond to                                         
             security.departme                                         
                [EMAIL PROTECTED]                                            
                                                                       
                                                                       
                                                                       




Hello Derek

Am Sonntag, 6. März 2005 23.10 schrieb [EMAIL PROTECTED]:
> I took everyone's advise and understood.  thank you!   The code

...marked with...?

> ###- - -###  solved it!


> [cut alot away]

> and these lines were still printed.  So my solution was  if ( $_ !~
"ANR*"
> or $_ !~ "ANS*" ).
>
> I think this code is really cool and seems to be some type of trick?  I
> looked in my learning perl and programming perl books and did not find
this
> code as below.

I spent now one and a half hour, nearly getting crazy, over this
if-condition
and the use of double quoted regexes... never saw this anywhere...
endless tests, and "the thing" behaved as a regex should...

and finally found this hint in perldoc perlop:

[[
Binding Operators

Binary "=~" binds a scalar expression to a pattern match.  [...]

If the right argument is an expression rather than a search pattern,
substitution, or transliteration, it is interpreted as a search pattern at
run time.

Binary "!~" is just like "=~" except the return value is negated in the
logical sense.
]]


> I then noticed in another email thread that  ##*##  was
> used.  Are these related?  Where can I find documentation on these?

This was likely just a comment
(although I don't know which thread you're talking about)


greetings joe

(thinking that it would be better if I got into the really dirty deep
details
of perl first before answering questions of others on this list again)


[nothing new below]

> An explanation of the line marked with ###--###:
>
> The regex searches for lines beginning with space(s), followed by at
least
> one
> number before the line end. If this matches, the part after "and" is
> executed, which sums up the number read into $total.
>
> thank you,
> derek
>
> Derek B. Smith
> OhioHealth IT
> UNIX / TSM / EDM Teams
>
>
>
>
>
>              John Doe
>              <security.departm
>              [EMAIL PROTECTED]>
To
>                                        beginners@perl.org
>              03/05/2005 01:25
cc
>              PM                        [EMAIL PROTECTED]
>
Subject
>                                        Re: reg exp
>              Please respond to
>              security.departme
>                 [EMAIL PROTECTED]
>
>
>
>
>
>
>
> Hi Derek
>
> > #!/usr/bin/perl
> >
> > ## Set pragmas (LC) and modules (UC)
> >
> > $^W = 1;
> > use strict;
> > use strict 'subs';
> >
> > ## Begin Logic
> >
> > $ENV{"PATH"} = qq(/home/root:/usr/bin:/usr/sbin);
> >
> > my $w="40";
> > my $total="0";
> > my $outfile1 = qq(/home/root/tsm2_clients.out);
> > my $outfile2 = qq(/home/root/tsm2_clients.plout);
> > open (FF, "+<$outfile1") || die "could not open file: $outfile1 $!";
> > open (FFF, "+<$outfile2") || die "could not open file: $outfile2 $!";
> > system qq(dsmadmc -id=admin -password=st0rm "tsm:select node_name from
> > nodes > $outfile1"
> > );
> > system qq(dsmadmc -id=admin -password=st0rm "tsm:select count(*)
>
> node_name
>
> > from nodes >> $
> > outfile1" );
>
> I don't know exactly what you want to achieve.
>
> Maybe your code above produces the outputfile "tsm2_clients.plout"
> mentioned
> in the top post (i have no idea about dsmadmc; if this is important, i
cant
>
> help you), and now you want to trie to sum up the two numbers at the end
of
>
> this file ("tsm2_clients.plout")
>
> If so,
>
> > # what happens when more nodes get added?
>
> John Krahn's code (cited under the next code snippet) does exactly that,
> independent from the number of nodes/lines in "tsm2_clients.plout".
>
> >         while (<FF>) {
> >             if ( $. > 6 ) {
> >                 if ( $_ !~ "ANR*" or $_ !~ "ANS*" ) {
> >                         print FFF $_;
> >                          /^s+(\d+) $/ and $total +=$1;
> >                 }
> >             }
> >         }
> >         print "Total Nodes on TSM1 and TSM2: $total\n";
>
> Still, line 3 in the above code looks strange.
>
> > close (FF) or warn "error closing $outfile1: $!";
> > close (FFF) or warn "error closing $outfile2: $!";
> >
> >
> > I tried the code give by John Krahn as hightlighted and this did not
>
> work.
>
> > Thanks though... any other ideas?
>
> I ran John's code:
>
> bash-2.05b$ perl
> use strict;
> use warnings;
> open FF, "<", "tsm2_clients.plout" or die $!;
>
> my $total;
> while ( <FF> ) {
>      /^\s+(\d+)$/ and $total += $1; ###--###
>      }
> print "Total = $total\n";
>
> close (FF) or warn $!;
>
>
> # output:
>
> Total = 460
>
>
> An explanation of the line marked with ###--###:
>
> The regex searches for lines beginning with space(s), followed by at
least
> one
> number before the line end. If this matches, the part after "and" is
> executed, which sums up the number read into $total.
>
> maybe $total could be initialized while declared, just for the case that
> the
> file is empty (which would produce a warning "Use of uninitialized value
in
>
> print...":
> my $total=0; # instead of just my $total;
>
>
> I just saw Charles's anwer with a bunch of good tips I did not mention to
> keep
> short.
>
> greetings joe
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to