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

RE: [PBML] LWP module, saving file as one continious line..

Expand Messages
  • frankie
    its not a variable, $file is a designation of a real file... like so: my $file = D:/Inetpub/Scripts/fetchtest/images/url.txt ; so that won t work... (wish it
    Message 1 of 10 , Aug 6, 2002
    • 0 Attachment
      its not a variable,

      $file is a designation of a real file... like so:

      my $file = 'D:/Inetpub/Scripts/fetchtest/images/url.txt';

      so that won't work... (wish it was that easy :-)

      I'm looking at something like this right now unless someone has a more
      effiient idea...

      my $line;
      open FILE, "< $file"
      or die "Can't open receipt page html file: $!\n";
      foreach my $Single_line (<FILE>){
      chomp $Single_line;
      $line .= $Single_line;
      }
      print FILE $line;
      close (FILE);

      I think that would work....

      any other ideas????


      regards

      Franki



      -----Original Message-----
      From: Wright, William [mailto:William_Wright@...]
      Sent: Wednesday, August 07, 2002 1:56 AM
      To: perl-beginner@yahoogroups.com
      Subject: RE: [PBML] LWP module, saving file as one continious line..


      if you have the result document in a single variable then try just using a
      substitution match to replace all the \n's with something else

      e.g.

      $lwp_results =~ s/\n/ /g; # replaces all the newlines with spaces
      or
      $lwp_results =~ tr/\n/ /; # different way of saying the same...



      my 0.02 cents..

      Bill

      -----Original Message-----
      From: frankie [mailto:frankieh@...]
      Sent: Tuesday, August 06, 2002 1:42 PM
      To: perl-beginner@yahoogroups.com
      Subject: [PBML] LWP module, saving file as one continious line..


      Hi all,

      Just a quick question...

      I am using the LWP module to grab a page and save it locally (as $file)...

      using this:

      my $return_query = "$return_URL?$query_string";
      my $result = getstore( $return_query, $file);
      unless ($result == 200) {
      print "Cannot download $return_URL : HTTP Status =
      $result\n";
      }

      My question is,, is there any way to get LWP to save that file as one
      line???

      I want to have the entire file made as a long single line, so I can use
      simple regex to seach the file and not have stuff missed because its over
      multiple lines..

      I know I can do it with a foreach loop.. but I was hoping that there was a
      way to avoid the extra step.


      Does anyone know of anything that would be useful to me here? or should I
      just go ahead and make it a single line buy using a foreach loop, chomping
      off the newline and appending each line to the last one...


      any tips would as always be fantastic and much appreciated.


      rgds

      Franki



      Unsubscribing info is here:
      http://help.yahoo.com/help/us/groups/groups-32.html

      Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



      Unsubscribing info is here:
      http://help.yahoo.com/help/us/groups/groups-32.html

      Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    • Wright, William
      Yea that would work if you wanted to eliminate the loop try.. undef $/; # enable slurp mode $file = ; # whole file now here $file =~ s/ n/ /g; # now
      Message 2 of 10 , Aug 6, 2002
      • 0 Attachment
        Yea that would work if you wanted to eliminate the loop try..

        undef $/; # enable "slurp" mode
        $file = <FILE>; # whole file now here
        $file =~ s/\n/ /g; # now strip out the new line characters...
        # or use '$file =~ tr/\n/ /;' whichever is
        your fancy...

        http://www.perldoc.com/perl5.6/pod/perlvar.html and look for '$/'

        -----Original Message-----
        From: frankie [mailto:frankieh@...]
        Sent: Tuesday, August 06, 2002 2:27 PM
        To: perl-beginner@yahoogroups.com
        Subject: RE: [PBML] LWP module, saving file as one continious line..


        its not a variable,

        $file is a designation of a real file... like so:

        my $file = 'D:/Inetpub/Scripts/fetchtest/images/url.txt';

        so that won't work... (wish it was that easy :-)

        I'm looking at something like this right now unless someone has a more
        effiient idea...

        my $line;
        open FILE, "< $file"
        or die "Can't open receipt page html file: $!\n";
        foreach my $Single_line (<FILE>){
        chomp $Single_line;
        $line .= $Single_line;
        }
        print FILE $line;
        close (FILE);

        I think that would work....

        any other ideas????


        regards

        Franki



        -----Original Message-----
        From: Wright, William [mailto:William_Wright@...]
        Sent: Wednesday, August 07, 2002 1:56 AM
        To: perl-beginner@yahoogroups.com
        Subject: RE: [PBML] LWP module, saving file as one continious line..


        if you have the result document in a single variable then try just using a
        substitution match to replace all the \n's with something else

        e.g.

        $lwp_results =~ s/\n/ /g; # replaces all the newlines with spaces
        or
        $lwp_results =~ tr/\n/ /; # different way of saying the same...



        my 0.02 cents..

        Bill

        -----Original Message-----
        From: frankie [mailto:frankieh@...]
        Sent: Tuesday, August 06, 2002 1:42 PM
        To: perl-beginner@yahoogroups.com
        Subject: [PBML] LWP module, saving file as one continious line..


        Hi all,

        Just a quick question...

        I am using the LWP module to grab a page and save it locally (as $file)...

        using this:

        my $return_query = "$return_URL?$query_string";
        my $result = getstore( $return_query, $file);
        unless ($result == 200) {
        print "Cannot download $return_URL : HTTP Status =
        $result\n";
        }

        My question is,, is there any way to get LWP to save that file as one
        line???

        I want to have the entire file made as a long single line, so I can use
        simple regex to seach the file and not have stuff missed because its over
        multiple lines..

        I know I can do it with a foreach loop.. but I was hoping that there was a
        way to avoid the extra step.


        Does anyone know of anything that would be useful to me here? or should I
        just go ahead and make it a single line buy using a foreach loop, chomping
        off the newline and appending each line to the last one...


        any tips would as always be fantastic and much appreciated.


        rgds

        Franki



        Unsubscribing info is here:
        http://help.yahoo.com/help/us/groups/groups-32.html

        Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



        Unsubscribing info is here:
        http://help.yahoo.com/help/us/groups/groups-32.html

        Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/





        Unsubscribing info is here:
        http://help.yahoo.com/help/us/groups/groups-32.html

        Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
      • frankie
        cool, thanks for that.... any idea which is more efficient??? (I mean faster, ram usage is of no concern, we have heaps of ram) rgds Frank ... From: Wright,
        Message 3 of 10 , Aug 6, 2002
        • 0 Attachment
          cool,

          thanks for that.... any idea which is more efficient??? (I mean faster, ram
          usage is of no concern, we have heaps of ram)

          rgds

          Frank

          -----Original Message-----
          From: Wright, William [mailto:William_Wright@...]
          Sent: Wednesday, August 07, 2002 2:46 AM
          To: perl-beginner@yahoogroups.com
          Subject: RE: [PBML] LWP module, saving file as one continious line..


          Yea that would work if you wanted to eliminate the loop try..

          undef $/; # enable "slurp" mode
          $file = <FILE>; # whole file now here
          $file =~ s/\n/ /g; # now strip out the new line characters...
          # or use '$file =~ tr/\n/ /;' whichever is
          your fancy...

          http://www.perldoc.com/perl5.6/pod/perlvar.html and look for '$/'

          -----Original Message-----
          From: frankie [mailto:frankieh@...]
          Sent: Tuesday, August 06, 2002 2:27 PM
          To: perl-beginner@yahoogroups.com
          Subject: RE: [PBML] LWP module, saving file as one continious line..


          its not a variable,

          $file is a designation of a real file... like so:

          my $file = 'D:/Inetpub/Scripts/fetchtest/images/url.txt';

          so that won't work... (wish it was that easy :-)

          I'm looking at something like this right now unless someone has a more
          effiient idea...

          my $line;
          open FILE, "< $file"
          or die "Can't open receipt page html file: $!\n";
          foreach my $Single_line (<FILE>){
          chomp $Single_line;
          $line .= $Single_line;
          }
          print FILE $line;
          close (FILE);

          I think that would work....

          any other ideas????


          regards

          Franki



          -----Original Message-----
          From: Wright, William [mailto:William_Wright@...]
          Sent: Wednesday, August 07, 2002 1:56 AM
          To: perl-beginner@yahoogroups.com
          Subject: RE: [PBML] LWP module, saving file as one continious line..


          if you have the result document in a single variable then try just using a
          substitution match to replace all the \n's with something else

          e.g.

          $lwp_results =~ s/\n/ /g; # replaces all the newlines with spaces
          or
          $lwp_results =~ tr/\n/ /; # different way of saying the same...



          my 0.02 cents..

          Bill

          -----Original Message-----
          From: frankie [mailto:frankieh@...]
          Sent: Tuesday, August 06, 2002 1:42 PM
          To: perl-beginner@yahoogroups.com
          Subject: [PBML] LWP module, saving file as one continious line..


          Hi all,

          Just a quick question...

          I am using the LWP module to grab a page and save it locally (as $file)...

          using this:

          my $return_query = "$return_URL?$query_string";
          my $result = getstore( $return_query, $file);
          unless ($result == 200) {
          print "Cannot download $return_URL : HTTP Status =
          $result\n";
          }

          My question is,, is there any way to get LWP to save that file as one
          line???

          I want to have the entire file made as a long single line, so I can use
          simple regex to seach the file and not have stuff missed because its over
          multiple lines..

          I know I can do it with a foreach loop.. but I was hoping that there was a
          way to avoid the extra step.


          Does anyone know of anything that would be useful to me here? or should I
          just go ahead and make it a single line buy using a foreach loop, chomping
          off the newline and appending each line to the last one...


          any tips would as always be fantastic and much appreciated.


          rgds

          Franki



          Unsubscribing info is here:
          http://help.yahoo.com/help/us/groups/groups-32.html

          Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



          Unsubscribing info is here:
          http://help.yahoo.com/help/us/groups/groups-32.html

          Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/





          Unsubscribing info is here:
          http://help.yahoo.com/help/us/groups/groups-32.html

          Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



          Unsubscribing info is here:
          http://help.yahoo.com/help/us/groups/groups-32.html

          Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
        • Wright, William
          I d suspect the one with less lines of code is faster but its probally better to benchmark the options. see perldoc Benchmark for info on how to measure the
          Message 4 of 10 , Aug 6, 2002
          • 0 Attachment
            I'd suspect the one with less lines of code is faster but its probally
            better to benchmark the options.

            see 'perldoc Benchmark' for info on how to measure the 2 approaches..

            Bill

            -----Original Message-----
            From: frankie [mailto:frankieh@...]
            Sent: Tuesday, August 06, 2002 3:07 PM
            To: perl-beginner@yahoogroups.com
            Subject: RE: [PBML] LWP module, saving file as one continious line..


            cool,

            thanks for that.... any idea which is more efficient??? (I mean faster, ram
            usage is of no concern, we have heaps of ram)

            rgds

            Frank

            -----Original Message-----
            From: Wright, William [mailto:William_Wright@...]
            Sent: Wednesday, August 07, 2002 2:46 AM
            To: perl-beginner@yahoogroups.com
            Subject: RE: [PBML] LWP module, saving file as one continious line..


            Yea that would work if you wanted to eliminate the loop try..

            undef $/; # enable "slurp" mode
            $file = <FILE>; # whole file now here
            $file =~ s/\n/ /g; # now strip out the new line characters...
            # or use '$file =~ tr/\n/ /;' whichever is
            your fancy...

            http://www.perldoc.com/perl5.6/pod/perlvar.html and look for '$/'

            -----Original Message-----
            From: frankie [mailto:frankieh@...]
            Sent: Tuesday, August 06, 2002 2:27 PM
            To: perl-beginner@yahoogroups.com
            Subject: RE: [PBML] LWP module, saving file as one continious line..


            its not a variable,

            $file is a designation of a real file... like so:

            my $file = 'D:/Inetpub/Scripts/fetchtest/images/url.txt';

            so that won't work... (wish it was that easy :-)

            I'm looking at something like this right now unless someone has a more
            effiient idea...

            my $line;
            open FILE, "< $file"
            or die "Can't open receipt page html file: $!\n";
            foreach my $Single_line (<FILE>){
            chomp $Single_line;
            $line .= $Single_line;
            }
            print FILE $line;
            close (FILE);

            I think that would work....

            any other ideas????


            regards

            Franki



            -----Original Message-----
            From: Wright, William [mailto:William_Wright@...]
            Sent: Wednesday, August 07, 2002 1:56 AM
            To: perl-beginner@yahoogroups.com
            Subject: RE: [PBML] LWP module, saving file as one continious line..


            if you have the result document in a single variable then try just using a
            substitution match to replace all the \n's with something else

            e.g.

            $lwp_results =~ s/\n/ /g; # replaces all the newlines with spaces
            or
            $lwp_results =~ tr/\n/ /; # different way of saying the same...



            my 0.02 cents..

            Bill

            -----Original Message-----
            From: frankie [mailto:frankieh@...]
            Sent: Tuesday, August 06, 2002 1:42 PM
            To: perl-beginner@yahoogroups.com
            Subject: [PBML] LWP module, saving file as one continious line..


            Hi all,

            Just a quick question...

            I am using the LWP module to grab a page and save it locally (as $file)...

            using this:

            my $return_query = "$return_URL?$query_string";
            my $result = getstore( $return_query, $file);
            unless ($result == 200) {
            print "Cannot download $return_URL : HTTP Status =
            $result\n";
            }

            My question is,, is there any way to get LWP to save that file as one
            line???

            I want to have the entire file made as a long single line, so I can use
            simple regex to seach the file and not have stuff missed because its over
            multiple lines..

            I know I can do it with a foreach loop.. but I was hoping that there was a
            way to avoid the extra step.


            Does anyone know of anything that would be useful to me here? or should I
            just go ahead and make it a single line buy using a foreach loop, chomping
            off the newline and appending each line to the last one...


            any tips would as always be fantastic and much appreciated.


            rgds

            Franki



            Unsubscribing info is here:
            http://help.yahoo.com/help/us/groups/groups-32.html

            Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



            Unsubscribing info is here:
            http://help.yahoo.com/help/us/groups/groups-32.html

            Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/





            Unsubscribing info is here:
            http://help.yahoo.com/help/us/groups/groups-32.html

            Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



            Unsubscribing info is here:
            http://help.yahoo.com/help/us/groups/groups-32.html

            Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/





            Unsubscribing info is here:
            http://help.yahoo.com/help/us/groups/groups-32.html

            Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
          • Wright, William
            I was curious .... # ----- code ------- use Benchmark; my $count = 1000; timethese($count, { loop = open F, tst_file.txt ; while ( ) { $line.=$_ } close
            Message 5 of 10 , Aug 6, 2002
            • 0 Attachment
              I was curious ....

              # ----- code -------
              use Benchmark;
              my $count = 1000;
              timethese($count, {
              'loop' => 'open F, "tst_file.txt"; while (<F>) { $line.=$_ } close F;',
              'slurp' => 'undef $/; open F, "tst_file.txt"; $line = <F>; close F;',
              });
              # ----- cut ------

              # output
              Benchmark: timing 1000 iterations of loop, slurp...
              loop: 3 wallclock secs ( 2.06 usr + 0.58 sys = 2.64 CPU) @ 378.64/s
              (n=1000)
              slurp: 0 wallclock secs ( 0.19 usr + 0.41 sys = 0.59 CPU) @
              1683.50/s (n=1000)

              -----Original Message-----
              From: Wright, William [mailto:William_Wright@...]
              Sent: Tuesday, August 06, 2002 3:16 PM
              To: perl-beginner@yahoogroups.com
              Subject: RE: [PBML] LWP module, saving file as one continious line..


              I'd suspect the one with less lines of code is faster but its probally
              better to benchmark the options.

              see 'perldoc Benchmark' for info on how to measure the 2 approaches..

              Bill

              -----Original Message-----
              From: frankie [mailto:frankieh@...]
              Sent: Tuesday, August 06, 2002 3:07 PM
              To: perl-beginner@yahoogroups.com
              Subject: RE: [PBML] LWP module, saving file as one continious line..


              cool,

              thanks for that.... any idea which is more efficient??? (I mean faster, ram
              usage is of no concern, we have heaps of ram)

              rgds

              Frank

              -----Original Message-----
              From: Wright, William [mailto:William_Wright@...]
              Sent: Wednesday, August 07, 2002 2:46 AM
              To: perl-beginner@yahoogroups.com
              Subject: RE: [PBML] LWP module, saving file as one continious line..


              Yea that would work if you wanted to eliminate the loop try..

              undef $/; # enable "slurp" mode
              $file = <FILE>; # whole file now here
              $file =~ s/\n/ /g; # now strip out the new line characters...
              # or use '$file =~ tr/\n/ /;' whichever is
              your fancy...

              http://www.perldoc.com/perl5.6/pod/perlvar.html and look for '$/'

              -----Original Message-----
              From: frankie [mailto:frankieh@...]
              Sent: Tuesday, August 06, 2002 2:27 PM
              To: perl-beginner@yahoogroups.com
              Subject: RE: [PBML] LWP module, saving file as one continious line..


              its not a variable,

              $file is a designation of a real file... like so:

              my $file = 'D:/Inetpub/Scripts/fetchtest/images/url.txt';

              so that won't work... (wish it was that easy :-)

              I'm looking at something like this right now unless someone has a more
              effiient idea...

              my $line;
              open FILE, "< $file"
              or die "Can't open receipt page html file: $!\n";
              foreach my $Single_line (<FILE>){
              chomp $Single_line;
              $line .= $Single_line;
              }
              print FILE $line;
              close (FILE);

              I think that would work....

              any other ideas????


              regards

              Franki



              -----Original Message-----
              From: Wright, William [mailto:William_Wright@...]
              Sent: Wednesday, August 07, 2002 1:56 AM
              To: perl-beginner@yahoogroups.com
              Subject: RE: [PBML] LWP module, saving file as one continious line..


              if you have the result document in a single variable then try just using a
              substitution match to replace all the \n's with something else

              e.g.

              $lwp_results =~ s/\n/ /g; # replaces all the newlines with spaces
              or
              $lwp_results =~ tr/\n/ /; # different way of saying the same...



              my 0.02 cents..

              Bill

              -----Original Message-----
              From: frankie [mailto:frankieh@...]
              Sent: Tuesday, August 06, 2002 1:42 PM
              To: perl-beginner@yahoogroups.com
              Subject: [PBML] LWP module, saving file as one continious line..


              Hi all,

              Just a quick question...

              I am using the LWP module to grab a page and save it locally (as $file)...

              using this:

              my $return_query = "$return_URL?$query_string";
              my $result = getstore( $return_query, $file);
              unless ($result == 200) {
              print "Cannot download $return_URL : HTTP Status =
              $result\n";
              }

              My question is,, is there any way to get LWP to save that file as one
              line???

              I want to have the entire file made as a long single line, so I can use
              simple regex to seach the file and not have stuff missed because its over
              multiple lines..

              I know I can do it with a foreach loop.. but I was hoping that there was a
              way to avoid the extra step.


              Does anyone know of anything that would be useful to me here? or should I
              just go ahead and make it a single line buy using a foreach loop, chomping
              off the newline and appending each line to the last one...


              any tips would as always be fantastic and much appreciated.


              rgds

              Franki



              Unsubscribing info is here:
              http://help.yahoo.com/help/us/groups/groups-32.html

              Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



              Unsubscribing info is here:
              http://help.yahoo.com/help/us/groups/groups-32.html

              Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/





              Unsubscribing info is here:
              http://help.yahoo.com/help/us/groups/groups-32.html

              Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



              Unsubscribing info is here:
              http://help.yahoo.com/help/us/groups/groups-32.html

              Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/





              Unsubscribing info is here:
              http://help.yahoo.com/help/us/groups/groups-32.html

              Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



              Unsubscribing info is here:
              http://help.yahoo.com/help/us/groups/groups-32.html

              Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
            • frankie
              so the slurp kicks butt... cool stuff... thankyou.. ... From: Wright, William [mailto:William_Wright@WrightExpress.com] Sent: Wednesday, August 07, 2002 3:23
              Message 6 of 10 , Aug 6, 2002
              • 0 Attachment
                so the slurp kicks butt... cool stuff...

                thankyou..




                -----Original Message-----
                From: Wright, William [mailto:William_Wright@...]
                Sent: Wednesday, August 07, 2002 3:23 AM
                To: perl-beginner@yahoogroups.com
                Subject: RE: [PBML] LWP module, saving file as one continious line..


                I was curious ....

                # ----- code -------
                use Benchmark;
                my $count = 1000;
                timethese($count, {
                'loop' => 'open F, "tst_file.txt"; while (<F>) { $line.=$_ } close F;',
                'slurp' => 'undef $/; open F, "tst_file.txt"; $line = <F>; close F;',
                });
                # ----- cut ------

                # output
                Benchmark: timing 1000 iterations of loop, slurp...
                loop: 3 wallclock secs ( 2.06 usr + 0.58 sys = 2.64 CPU) @ 378.64/s
                (n=1000)
                slurp: 0 wallclock secs ( 0.19 usr + 0.41 sys = 0.59 CPU) @
                1683.50/s (n=1000)

                -----Original Message-----
                From: Wright, William [mailto:William_Wright@...]
                Sent: Tuesday, August 06, 2002 3:16 PM
                To: perl-beginner@yahoogroups.com
                Subject: RE: [PBML] LWP module, saving file as one continious line..


                I'd suspect the one with less lines of code is faster but its probally
                better to benchmark the options.

                see 'perldoc Benchmark' for info on how to measure the 2 approaches..

                Bill

                -----Original Message-----
                From: frankie [mailto:frankieh@...]
                Sent: Tuesday, August 06, 2002 3:07 PM
                To: perl-beginner@yahoogroups.com
                Subject: RE: [PBML] LWP module, saving file as one continious line..


                cool,

                thanks for that.... any idea which is more efficient??? (I mean faster, ram
                usage is of no concern, we have heaps of ram)

                rgds

                Frank

                -----Original Message-----
                From: Wright, William [mailto:William_Wright@...]
                Sent: Wednesday, August 07, 2002 2:46 AM
                To: perl-beginner@yahoogroups.com
                Subject: RE: [PBML] LWP module, saving file as one continious line..


                Yea that would work if you wanted to eliminate the loop try..

                undef $/; # enable "slurp" mode
                $file = <FILE>; # whole file now here
                $file =~ s/\n/ /g; # now strip out the new line characters...
                # or use '$file =~ tr/\n/ /;' whichever is
                your fancy...

                http://www.perldoc.com/perl5.6/pod/perlvar.html and look for '$/'

                -----Original Message-----
                From: frankie [mailto:frankieh@...]
                Sent: Tuesday, August 06, 2002 2:27 PM
                To: perl-beginner@yahoogroups.com
                Subject: RE: [PBML] LWP module, saving file as one continious line..


                its not a variable,

                $file is a designation of a real file... like so:

                my $file = 'D:/Inetpub/Scripts/fetchtest/images/url.txt';

                so that won't work... (wish it was that easy :-)

                I'm looking at something like this right now unless someone has a more
                effiient idea...

                my $line;
                open FILE, "< $file"
                or die "Can't open receipt page html file: $!\n";
                foreach my $Single_line (<FILE>){
                chomp $Single_line;
                $line .= $Single_line;
                }
                print FILE $line;
                close (FILE);

                I think that would work....

                any other ideas????


                regards

                Franki



                -----Original Message-----
                From: Wright, William [mailto:William_Wright@...]
                Sent: Wednesday, August 07, 2002 1:56 AM
                To: perl-beginner@yahoogroups.com
                Subject: RE: [PBML] LWP module, saving file as one continious line..


                if you have the result document in a single variable then try just using a
                substitution match to replace all the \n's with something else

                e.g.

                $lwp_results =~ s/\n/ /g; # replaces all the newlines with spaces
                or
                $lwp_results =~ tr/\n/ /; # different way of saying the same...



                my 0.02 cents..

                Bill

                -----Original Message-----
                From: frankie [mailto:frankieh@...]
                Sent: Tuesday, August 06, 2002 1:42 PM
                To: perl-beginner@yahoogroups.com
                Subject: [PBML] LWP module, saving file as one continious line..


                Hi all,

                Just a quick question...

                I am using the LWP module to grab a page and save it locally (as $file)...

                using this:

                my $return_query = "$return_URL?$query_string";
                my $result = getstore( $return_query, $file);
                unless ($result == 200) {
                print "Cannot download $return_URL : HTTP Status =
                $result\n";
                }

                My question is,, is there any way to get LWP to save that file as one
                line???

                I want to have the entire file made as a long single line, so I can use
                simple regex to seach the file and not have stuff missed because its over
                multiple lines..

                I know I can do it with a foreach loop.. but I was hoping that there was a
                way to avoid the extra step.


                Does anyone know of anything that would be useful to me here? or should I
                just go ahead and make it a single line buy using a foreach loop, chomping
                off the newline and appending each line to the last one...


                any tips would as always be fantastic and much appreciated.


                rgds

                Franki



                Unsubscribing info is here:
                http://help.yahoo.com/help/us/groups/groups-32.html

                Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



                Unsubscribing info is here:
                http://help.yahoo.com/help/us/groups/groups-32.html

                Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/





                Unsubscribing info is here:
                http://help.yahoo.com/help/us/groups/groups-32.html

                Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



                Unsubscribing info is here:
                http://help.yahoo.com/help/us/groups/groups-32.html

                Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/





                Unsubscribing info is here:
                http://help.yahoo.com/help/us/groups/groups-32.html

                Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



                Unsubscribing info is here:
                http://help.yahoo.com/help/us/groups/groups-32.html

                Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



                Unsubscribing info is here:
                http://help.yahoo.com/help/us/groups/groups-32.html

                Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
              • franki
                Hi again.... so I got my html saved as one big long line.. now I want to extract any image url s into an array so I can use a foreach on it to retrieve them..
                Message 7 of 10 , Aug 6, 2002
                • 0 Attachment
                  Hi again....


                  so I got my html saved as one big long line..

                  now I want to extract any image url's into an array so I can use a foreach
                  on it to retrieve them..

                  but I am completely lost on how to do that..

                  I thought a foreach based on a regex would work, but after 4 hours of
                  seaching the web and trying stuff, I've gotten nowhere.. I can get the first
                  image, but thats it...


                  If I have a big string, and I want to get all instances of a image url in
                  that string into an array,

                  how would I go about it?

                  any tips?

                  is there a standard module that can help me here???


                  rgds

                  Frank
                • Jenda Krynicky
                  From: franki ... perldoc HTML::Parser Jenda =========== Jenda@Krynicky.cz == http://Jenda.Krynicky.cz ========== There is a reason
                  Message 8 of 10 , Aug 6, 2002
                  • 0 Attachment
                    From: "franki" <frankieh@...>
                    > so I got my html saved as one big long line..
                    >
                    > now I want to extract any image url's into an array so I can use a
                    > foreach on it to retrieve them..
                    >
                    > but I am completely lost on how to do that..
                    >
                    > I thought a foreach based on a regex would work, but after 4 hours of
                    > seaching the web and trying stuff, I've gotten nowhere.. I can get the
                    > first image, but thats it...

                    perldoc HTML::Parser

                    Jenda
                    =========== Jenda@... == http://Jenda.Krynicky.cz ==========
                    There is a reason for living. There must be. I've seen it somewhere.
                    It's just that in the mess on my table ... and in my brain
                    I can't find it.
                    --- me
                  • frankie
                    Thankyou Jenda and Jeff, at least I have some stuff to research now.. I did fine the getimage module.. http://search.cpan.org/search?dist=HTTP-GetImages but it
                    Message 9 of 10 , Aug 6, 2002
                    • 0 Attachment
                      Thankyou Jenda and Jeff, at least I have some stuff to research now..

                      I did fine the getimage module..

                      http://search.cpan.org/search?dist=HTTP-GetImages

                      but it doesn't appear to be very popular, as there is precious little
                      documentation on the net about it...

                      Thanks heaps guys, really really appreciated..


                      rgds

                      Frank

                      -----Original Message-----
                      From: Jenda Krynicky [mailto:Jenda@...]
                      Sent: Wednesday, August 07, 2002 5:51 AM
                      To: perl-beginner@yahoogroups.com
                      Subject: Re: [PBML] Now I am lost... :-(


                      From: "franki" <frankieh@...>
                      > so I got my html saved as one big long line..
                      >
                      > now I want to extract any image url's into an array so I can use a
                      > foreach on it to retrieve them..
                      >
                      > but I am completely lost on how to do that..
                      >
                      > I thought a foreach based on a regex would work, but after 4 hours of
                      > seaching the web and trying stuff, I've gotten nowhere.. I can get the
                      > first image, but thats it...

                      perldoc HTML::Parser

                      Jenda
                      =========== Jenda@... == http://Jenda.Krynicky.cz ==========
                      There is a reason for living. There must be. I've seen it somewhere.
                      It's just that in the mess on my table ... and in my brain
                      I can't find it.
                      --- me



                      Unsubscribing info is here:
                      http://help.yahoo.com/help/us/groups/groups-32.html

                      Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
                    Your message has been successfully submitted and would be delivered to recipients shortly.