Parsing a Log File

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • drushof
    New Member
    • Jun 2007
    • 12

    #16
    Originally posted by KevinADC
    use regular expressions to parse the data to get the results you want.
    mmh oke..but is my code wrong?
    or regular expression make it easier?

    Comment

    • KevinADC
      Recognized Expert Specialist
      • Jan 2007
      • 4092

      #17
      Originally posted by drushof
      mmh oke..but is my code wrong?
      or regular expression make it easier?

      There is no way for me to know if your code is wrong. That depends on how much perl you have learned already and how much you are expected to know at this point in your studies.

      Technically, if the code runs and poduces the correct results, it's good code. It may not be efficient code, but it's good. Your code is close to producing the results you want.

      Using regular expressions should make the job easier.

      Comment

      • drushof
        New Member
        • Jun 2007
        • 12

        #18
        thx so much
        another question,can you help me

        Recovering 10 files within C:\ABC\DEF\ into F:\XYZ\PQR\

        data i need C:\ABC\DEF\ and F:\XYZ\PQR\
        how regular expression solve this thing?

        Comment

        • KevinADC
          Recognized Expert Specialist
          • Jan 2007
          • 4092

          #19
          OK you beat some code out of me, but since this is your school work don't expect anymore code. This is one possible way to match the pattern you are interested in:

          Code:
          $line = 'Recovering 5 files within D:\X\Y\ into E:\restore';
          if ($line =~ /^Recovering \d+ files within (\S+) into (\S+)/ ) {
             print "$1 $2";
          }
          here are a couple of regexp tutorials:

          # perlrequick - Perl regular expressions quick start
          # perlretut - Perl regular expressions tutorial

          you can find them here:

          Comment

          • drushof
            New Member
            • Jun 2007
            • 12

            #20
            thx so much..
            im gonna try it =)

            Comment

            • drushof
              New Member
              • Jun 2007
              • 12

              #21
              Originally posted by KevinADC

              Code:
              $line = 'Recovering 5 files within D:\X\Y\ into E:\restore';
              if ($line =~ /^Recovering \d+ files within (\S+) into (\S+)/ ) {
                 print "$1 $2";
              }
              sorry but in other case like 'Recovering 10 files within D:\X Y's\Z into E:\restore'
              the code didnt work
              what should i supposed to do to avoid the space and '

              thx

              Comment

              • KevinADC
                Recognized Expert Specialist
                • Jan 2007
                • 4092

                #22
                You're going to have to read the tutorials I linked you to (or read whatever perl resource material you have). You will find the answers to your questions in those tutorials.

                Comment

                Working...