Note that there are some explanatory texts on larger screens.

plurals
  1. POPerl WWW::Mechanize Comparing the response header content length of different urls
    primarykey
    data
    text
    <p><strong>I have a question I'm hoping you could help with?</strong></p> <p>I have two text files containing the following:</p> <p><strong>FILE1.txt</strong></p> <pre><code>http://www.dog.com/ http://www.cat.com/ http://www.antelope.com/ </code></pre> <p><strong>FILE2.txt</strong></p> <pre><code>1 2 Barry </code></pre> <p><strong>The output I correctly achieve is as follows:</strong></p> <pre><code>http://www.dog.com/1 http://www.dog.com/2 http://www.dog.com/Barry http://www.cat.com/1 http://www.cat.com/2 http://www.cat.com/Barry http://www.antelope.com/1 http://www.antelope.com/2 http://www.antelope.com/Barry </code></pre> <p><strong>Code to do the above</strong></p> <pre><code> open my $animalUrls, '&lt;', 'FILE1.txt' or die "Can't open: $!"; open my $directory, '&lt;', 'FILE2.txt' or die "Can't open: $!"; my @directory = &lt;$directory&gt;; #each line of the file into an array close $directory or die "Can't close: $!"; while (my $line = &lt;$animalUrls&gt;) { chomp $line; print $line.$_ foreach (@directory); push (@newListOfUrls, $line.$_) foreach (@directory); #put each new url into array } </code></pre> <p><strong>Now the problem I am having:</strong></p> <p>I need to get the Content Length of the original urls (File1.txt) and compare the Content-Length of each of the new urls with the <strong>corresponding</strong> original one to see if they are the same or different, for example:</p> <ul> <li>I need to compare the Content-Length of <a href="http://www.dog.com/1" rel="nofollow">http://www.dog.com/1</a> with the Content-Length of original url <a href="http://www.dog.com/" rel="nofollow">http://www.dog.com/</a> to see if there is a difference.</li> <li>Then I need to compare the Content-Length of <a href="http://www.dog.com/2" rel="nofollow">http://www.dog.com/2</a> with the Content-Length of the original url <a href="http://www.dog.com/" rel="nofollow">http://www.dog.com/</a> to see if there is a difference.</li> <li>Then I need to compare the Content-Length of <a href="http://www.dog.com/Barry" rel="nofollow">http://www.dog.com/Barry</a> with the Content-Length of the original url <a href="http://www.dog.com/" rel="nofollow">http://www.dog.com/</a> to see if there is a difference.</li> <li>Then I need to compare the Content-Length of <a href="http://www.cat.com/1" rel="nofollow">http://www.cat.com/1</a> with the Content-Length of the original url <a href="http://www.cat.com/" rel="nofollow">http://www.cat.com/</a> to see if there is a difference.</li> <li>Then I need to compare the Content-Length of <a href="http://www.cat.com/2" rel="nofollow">http://www.cat.com/2</a> with the Content-Length of the original url <a href="http://www.cat.com/" rel="nofollow">http://www.cat.com/</a> to see if there is a difference.</li> <li>And so on........</li> </ul> <p><strong>Code to get the Content-Length:</strong></p> <pre><code>print $mech-&gt;response-&gt;header('Content-Length'); #returns the content length </code></pre> <p>What I am having trouble with is how to compare each new url with the <strong>correct corresponding original one? (i.e not accidently comparing the Content-Length of <a href="http://www.cat.com/Barry" rel="nofollow">http://www.cat.com/Barry</a> with the Content-Length of <a href="http://www.dog.com/" rel="nofollow">http://www.dog.com/</a>)</strong> Should I use a hash maybe and how would I go about that?</p> <p>Your help with this would be much appreciated, Many Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload