Professional Web Applications Themes

keeping the file name while checking w/ LWP - PERL Beginners

Hi All, Can someone please point me in the right direction... maybe a module..? I have a file that contains the file name and the url. I need to separate the url so I can use LWP::Simple; to check the link, however, I need to keep the file name in tact so I can trace it back to my website. Anyone have any suggestions? Thanks for your help. Below is what I am using to check the links. #!/usr/local/bin/perl -w use strict; use LWP::Simple; my $file = "/Program Files/OptiPerl/results.txt"; open (LINKS, $file) or die "Can't open $file: $!"; # ------------ ...

  1. #1

    Default keeping the file name while checking w/ LWP

    Hi All,

    Can someone please point me in the right direction... maybe a module..?

    I have a file that contains the file name and the url. I need to separate
    the url so I can use LWP::Simple; to check the link, however, I need to keep
    the file name in tact so I can trace it back to my website. Anyone have any
    suggestions?

    Thanks for your help.

    Below is what I am using to check the links.

    #!/usr/local/bin/perl -w

    use strict;
    use LWP::Simple;

    my $file = "/Program Files/OptiPerl/results.txt";
    open (LINKS, $file) or die "Can't open $file: $!";

    # ------------ slurp the file -------------------------
    my urls = <LINKS>;
    # ----------- remove line endings ---------------------
    chomp urls;
    # --------- check each url in file --------------------
    foreach my $url (urls)
    {
    print "$url\n";
    my ($type) = head($url);
    # ---------- broken links go into bad.txt -------------
    unless (defined $type) {
    open (BAD, ">>bad.txt");
    print (BAD "$url\n");
    # print "Couldn't get $url\n";
    next;
    }
    # --------- good links go into good.txt ---------------
    if ($type) {
    open (GOOD, ">>good.txt");
    print (GOOD "$url\n");
    # print "Got it! \n$url\n";
    }
    }
    # --------- close all file handles --------------------
    close LINKS;
    close GOOD;
    close BAD;

    Brian Volk


    Brian Guest

  2. #2

    Default Re: keeping the file name while checking w/ LWP

    Brian Volk wrote: 

    Use map() together with split() to populate a hash.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Guest

  3. #3

    Default RE: keeping the file name while checking w/ LWP

    thank you... I was just reading about Grep vs. Loops :-)

    Thanks again!

    Brian

    -----Original Message-----
    From: Gunnar Hjalmarsson [mailto:cc]
    Sent: Friday, July 16, 2004 4:39 PM
    To: org
    Subject: Re: keeping the file name while checking w/ LWP


    Brian Volk wrote: 

    Use map() together with split() to populate a hash.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl

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


    Brian Guest

Similar Threads

  1. Checking if a file is corrupted
    By greenemike@adobeforums.com in forum Adobe Acrobat SDK
    Replies: 1
    Last Post: September 10th, 04:17 AM
  2. HELP: checking if a file exists
    By Kalimero in forum Macromedia Flash
    Replies: 0
    Last Post: December 21st, 11:04 PM
  3. checking for an existing file
    By Urme webforumsuser@macromedia.com in forum Macromedia Director Lingo
    Replies: 1
    Last Post: December 3rd, 08:20 PM
  4. Adding firework file to HTML page and keeping behaviours
    By Saulo in forum Macromedia Fireworks
    Replies: 2
    Last Post: October 22nd, 04:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139