Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] question

Expand Messages
  • Offer Kaye
    ... Specifically: perlmod, perlmodlib, perlmodstyle. The CPAN module Module::Starter can also help you get started. -- Offer Kaye
    Message 1 of 17 , Apr 4, 2005
    • 0 Attachment
      On Apr 4, 2005 3:09 PM, Paul Archer wrote:
      >
      > Reading some documentation would be a good start.
      >

      Specifically: perlmod, perlmodlib, perlmodstyle.
      The CPAN module "Module::Starter" can also help you get started.

      --
      Offer Kaye
    • Bob Brown
      Hello, I have a Perl script below where I am trying to load log lines into an array (lines 9-15) so that I can scan them for particular error messages. I am
      Message 2 of 17 , Jun 14, 2006
      • 0 Attachment
        Hello,

        I have a Perl script below where I am trying to load
        log lines into an array (lines 9-15) so that I can
        scan them for particular error messages. I am running
        on a IBM AIX UNIX box. When I debug this script,
        nothing is getting loaded into variable @lnes.

        Can an array hold variable length space-delimited
        lines like this or just single words?

        1 #!/usr/bin/perl
        2 print "Which log do you want a report on: ";
        3 chomp($whichlog=<STDIN>);
        4 open(FILE,"/var/log/" . $whichlog) || die "Could not
        open $whichlog";
        5 $err=0;
        6 $lct=0;
        7 my @lnes=();
        8 print "Loading lines...\n";
        9 while($line=<FILE>){
        10 if ($line =~ /ERROR/ && $line =~ /failed/ &&
        $line !~ /Upload/ && $line !~ /Copy/ && $line !~
        /TranslateIn/ && $line !~ /Archive/){
        11 $lct++;
        12 push(@lnes,$line);
        13 print "$lnes[$lct]\n";
        14 }
        15 }
        16 for ($j=$#lnes;$j=0;$j--){
        17 @fields=split(" ",$lnes[$j]);
        18 $runid = $fields[5];
        19 $path = $fields[13];
        20 @region=split("/",$path);
        21 $reg=$region[2];
        22 $tp=$region[4];
        23 $err++;
        24 print "$err. $lines[$j]\n";
        25
        open(TRFILE,"/CFApps/$reg/log/TRACE/TR$runid.DAT") ||
        warn "Cannot 26open
        /CFApps/$reg/log/TRACE/TR$runid.DAT";

        open(BADFILE,"/CFApps/$reg/PostOffice/ALL/BAD/bad$runid.edi")
        || warn "Cannot open
        /CFApps/$reg/ALL/BAD/bad$runid.edi";
        27 28print
        "****************************************\n";
        29 print "* Runid = $runid\n";
        30 print "* Trace file name = TR$runid.DAT\n";
        31 print "* Bad file name = bad$runid.edi\n";
        32 print "* Region = $reg\n";
        33 print "* Trading Partner = $tp\n";
        34 35print
        "****************************************\n";
        36 $ct=0;
        37 my $first=1;
        38 my @tracerec=();
        39 while ($line2=<TRFILE>){
        40 chomp($line2);
        41 if ($line2 =~ /EDI Line:/){
        42 $ct++;
        43 if ($ct > 50){ last;}
        44 push(@tracerec,$line2);
        45 }
        46 }
        47 for ($i=0;$i<=$#tracerec;$i++){
        48 @dum=split(" ",$tracerec[$i]);
        49 print $tracerec[$i];
        50 if ($dum[$i] =~ "Line:"){
        51 $badline=$dum[$i+1];
        52 last;
        53 }
        54 if ($first == 1){
        55 $line3=<BADFILE>;
        56 $first=0;
        57 $delim=substr($line3,105,1);
        58 print "Segment delimiter is $delim\n";
        59 @bob=split($delim,$line3);
        60 print "Total lines in badfile is
        $#bob\n";
        61 }
        62 print " $badline==>
        $bob[$badline-1]\n";
        }
        63 close(BADFILE);
        64 close(TRFILE);

        Bob Brown

        __________________________________________________
        Do You Yahoo!?
        Tired of spam? Yahoo! Mail has the best spam protection around
        http://mail.yahoo.com
      • Mr. Shawn H. Corey
        ... An array is an array of scalars. It can hold an ordered list of the same things a scalar can, including strings of bytes (not just characters). ... This is
        Message 3 of 17 , Jun 14, 2006
        • 0 Attachment
          On Wed, 2006-14-06 at 11:05 -0700, Bob Brown wrote:
          > Hello,
          >
          > I have a Perl script below where I am trying to load
          > log lines into an array (lines 9-15) so that I can
          > scan them for particular error messages. I am running
          > on a IBM AIX UNIX box. When I debug this script,
          > nothing is getting loaded into variable @lnes.
          >
          > Can an array hold variable length space-delimited
          > lines like this or just single words?

          An array is an array of scalars. It can hold an ordered list of the same
          things a scalar can, including strings of bytes (not just characters).

          >
          > 1 #!/usr/bin/perl
          > 2 print "Which log do you want a report on: ";
          > 3 chomp($whichlog=<STDIN>);
          > 4 open(FILE,"/var/log/" . $whichlog) || die "Could not
          > open $whichlog";
          > 5 $err=0;
          > 6 $lct=0;
          > 7 my @lnes=();
          > 8 print "Loading lines...\n";
          > 9 while($line=<FILE>){
          > 10 if ($line =~ /ERROR/ && $line =~ /failed/ &&
          > $line !~ /Upload/ && $line !~ /Copy/ && $line !~
          > /TranslateIn/ && $line !~ /Archive/){

          This is rather complex. Are you sure the file has a line that will pass
          this test? Try starting with part of this test and add elements until it
          is complete:
          if ($line =~ /ERROR/) {
          if ($line =~ /ERROR/ && $line =~ /failed/ ){
          ...

          > 11 $lct++;
          > 12 push(@lnes,$line);
          > 13 print "$lnes[$lct]\n";

          Prints double-spaced. A better way would be:
          print $line;

          > 14 }
          > 15 }



          --
          __END__

          Just my 0.00000002 million dollars worth,
          --- Shawn

          "For the things we have to learn before we can do them, we learn by doing them."
          Aristotle

          * Perl tutorials at http://perlmonks.org/?node=Tutorials
          * A searchable perldoc is at http://perldoc.perl.org/
        • Chad Perrin
          ... Yes, an array can hold variable length space-delimited lines. Of course, I m not sure what you mean by that, necessarily, but none of those words in that
          Message 4 of 17 , Jun 14, 2006
          • 0 Attachment
            On Wed, Jun 14, 2006 at 11:05:43AM -0700, Bob Brown wrote:
            >
            > I have a Perl script below where I am trying to load
            > log lines into an array (lines 9-15) so that I can
            > scan them for particular error messages. I am running
            > on a IBM AIX UNIX box. When I debug this script,
            > nothing is getting loaded into variable @lnes.
            >
            > Can an array hold variable length space-delimited
            > lines like this or just single words?

            Yes, an array can hold variable length space-delimited lines. Of
            course, I'm not sure what you mean by that, necessarily, but none of
            those words in that sentence preclude using an array.


            >
            > 1 #!/usr/bin/perl

            Add these two lines after the shebang line:
            use strict;
            use warnings;

            They're indispensable debugging tools, and should be used for pretty
            much every script you write. Of course, you'll have to declare your
            variables (preferably with "my", potentially with "our") when using the
            strict pragma. You've already done this with @lnes, so I don't know why
            you don't do it with anything else.


            > 2 print "Which log do you want a report on: ";
            > 3 chomp($whichlog=<STDIN>);
            > 4 open(FILE,"/var/log/" . $whichlog) || die "Could not
            > open $whichlog";
            > 5 $err=0;
            > 6 $lct=0;
            > 7 my @lnes=();
            > 8 print "Loading lines...\n";
            > 9 while($line=<FILE>){
            > 10 if ($line =~ /ERROR/ && $line =~ /failed/ &&
            > $line !~ /Upload/ && $line !~ /Copy/ && $line !~
            > /TranslateIn/ && $line !~ /Archive/){

            If nothing is getting loaded into @lnes, chances are good that your
            conditional statement is never returning a true result. Perhaps you
            could provide some test data. First, though, use the strict and
            warnings pragmas and clean up the code a little bit.

            note: I haven't bothered to go through the rest of the script yet. The
            above two items need to be addressed. It would also be easier to work
            with this without the line numbers, but I can be flexible if I have to.


            > 11 $lct++;
            > 12 push(@lnes,$line);
            > 13 print "$lnes[$lct]\n";
            > 14 }
            > 15 }
            > 16 for ($j=$#lnes;$j=0;$j--){
            > 17 @fields=split(" ",$lnes[$j]);
            > 18 $runid = $fields[5];
            > 19 $path = $fields[13];
            > 20 @region=split("/",$path);
            > 21 $reg=$region[2];
            > 22 $tp=$region[4];
            > 23 $err++;
            > 24 print "$err. $lines[$j]\n";
            > 25
            > open(TRFILE,"/CFApps/$reg/log/TRACE/TR$runid.DAT") ||
            > warn "Cannot 26open
            > /CFApps/$reg/log/TRACE/TR$runid.DAT";
            >
            > open(BADFILE,"/CFApps/$reg/PostOffice/ALL/BAD/bad$runid.edi")
            > || warn "Cannot open
            > /CFApps/$reg/ALL/BAD/bad$runid.edi";
            > 27 28print
            > "****************************************\n";
            > 29 print "* Runid = $runid\n";
            > 30 print "* Trace file name = TR$runid.DAT\n";
            > 31 print "* Bad file name = bad$runid.edi\n";
            > 32 print "* Region = $reg\n";
            > 33 print "* Trading Partner = $tp\n";
            > 34 35print
            > "****************************************\n";
            > 36 $ct=0;
            > 37 my $first=1;
            > 38 my @tracerec=();
            > 39 while ($line2=<TRFILE>){
            > 40 chomp($line2);
            > 41 if ($line2 =~ /EDI Line:/){
            > 42 $ct++;
            > 43 if ($ct > 50){ last;}
            > 44 push(@tracerec,$line2);
            > 45 }
            > 46 }
            > 47 for ($i=0;$i<=$#tracerec;$i++){
            > 48 @dum=split(" ",$tracerec[$i]);
            > 49 print $tracerec[$i];
            > 50 if ($dum[$i] =~ "Line:"){
            > 51 $badline=$dum[$i+1];
            > 52 last;
            > 53 }
            > 54 if ($first == 1){
            > 55 $line3=<BADFILE>;
            > 56 $first=0;
            > 57 $delim=substr($line3,105,1);
            > 58 print "Segment delimiter is $delim\n";
            > 59 @bob=split($delim,$line3);
            > 60 print "Total lines in badfile is
            > $#bob\n";
            > 61 }
            > 62 print " $badline==>
            > $bob[$badline-1]\n";
            > }
            > 63 close(BADFILE);
            > 64 close(TRFILE);

            --
            CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
            print substr("Just another Perl hacker", 0, -2);
          • Prasanna Goupal
            Hi, How can i check charset / Encoding of any pdf file? If someone know about it then please let me know. Thanks in advanced. Regards, Prasanna A. Goupal
            Message 5 of 17 , Jun 15, 2006
            • 0 Attachment
              Hi,

              How can i check charset / Encoding of any pdf file?
              If someone know about it then please let me know.

              Thanks in advanced.

              Regards,
              Prasanna A. Goupal

              __________________________________________________
              Do You Yahoo!?
              Tired of spam? Yahoo! Mail has the best spam protection around
              http://mail.yahoo.com

              [Non-text portions of this message have been removed]
            • Latha M R
              Dear sir/ madam, Thank you for Inviting me to this group. I have one doubt in my project.Can u answer for the following question. 1. How can I call C functions
              Message 6 of 17 , Jan 22, 2007
              • 0 Attachment
                Dear sir/ madam,
                Thank you for Inviting me to this group.
                I have one doubt in my project.Can u answer for the following
                question.
                1. How can I call C functions or C libraries by using Perl script.
                thanks & regards ,
                latha


                ---------------------------------
                Here’s a new way to find what you're looking for - Yahoo! Answers

                [Non-text portions of this message have been removed]
              • merlyn@stonehenge.com
                ... Latha 1. How can I call C functions or C libraries by using Perl script. The simplest way is to install Inline::C from the CPAN, and follow the
                Message 7 of 17 , Jan 23, 2007
                • 0 Attachment
                  >>>>> "Latha" == Latha M R <lathamr_tc@...> writes:

                  Latha> 1. How can I call C functions or C libraries by using Perl script.

                  The simplest way is to install Inline::C from the CPAN, and follow
                  the instructions there.

                  --
                  Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
                  <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
                  Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
                  See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
                • Robert Brown
                  1. How does one do a form feed (ASCII Character 12) using printf or sprintf? My documentation in Perl by Example doesn t show this. I know about the format
                  Message 8 of 17 , Feb 22, 2007
                  • 0 Attachment
                    1. How does one do a form feed (ASCII Character 12) using printf or sprintf? My documentation in Perl by Example doesn't show this. I know about the format command but would rather use printf or sprintf.

                    Bob



                    ____________________________________________________________________________________
                    Never miss an email again!
                    Yahoo! Toolbar alerts you the instant new Mail arrives.
                    http://tools.search.yahoo.com/toolbar/features/mail/

                    [Non-text portions of this message have been removed]
                  • Roellig Eric-CCEL25
                    google search string: ascii form feed perl https://www.wikicontent.com/wiki/index.php/Perl_&_LWP:ASCII_Table google search string: ascii form feed perl
                    Message 9 of 17 , Feb 22, 2007
                    • 0 Attachment
                      google search string: ascii "form feed" perl
                      https://www.wikicontent.com/wiki/index.php/Perl_&_LWP:ASCII_Table

                      google search string: ascii "form feed" perl printf
                      http://www-gatago.com/comp/lang/perl/misc/34834558.html
                      http://www.ngbdigital.com/perl_escape.html



                      printf "\fReport Heading - Page %d\n", $page_number;

                      Eric


                      ________________________________

                      From: perl-beginner@yahoogroups.com
                      [mailto:perl-beginner@yahoogroups.com] On Behalf Of Robert Brown
                      Sent: Thursday, February 22, 2007 8:32 AM
                      To: perl-beginner@yahoogroups.com
                      Subject: [PBML] question



                      1. How does one do a form feed (ASCII Character 12) using printf or
                      sprintf? My documentation in Perl by Example doesn't show this. I know
                      about the format command but would rather use printf or sprintf.

                      Bob

                      __________________________________________________________
                      Never miss an email again!
                      Yahoo! Toolbar alerts you the instant new Mail arrives.
                      http://tools.search.yahoo.com/toolbar/features/mail/
                      <http://tools.search.yahoo.com/toolbar/features/mail/>

                      [Non-text portions of this message have been removed]






                      [Non-text portions of this message have been removed]
                    • merlyn@stonehenge.com
                      ... Robert 1. How does one do a form feed (ASCII Character 12) using printf or Robert sprintf? My documentation in Perl by Example doesn t show this. I know
                      Message 10 of 17 , Feb 22, 2007
                      • 0 Attachment
                        >>>>> "Robert" == Robert Brown <rdabman4@...> writes:

                        Robert> 1. How does one do a form feed (ASCII Character 12) using printf or
                        Robert> sprintf? My documentation in Perl by Example doesn't show this. I know
                        Robert> about the format command but would rather use printf or sprintf.

                        print chr(12); # will certainly do it
                        print "\f"; # will as well

                        --
                        Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
                        <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
                        Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
                        See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
                      Your message has been successfully submitted and would be delivered to recipients shortly.