The following script works, reading from the DATA section:

#! /usr/bin/perl -C255 use strict; use warnings; use LWP::Simple; use Encode 'decode'; use URL::Encode ':all'; use feature 'unicode_strings'; use utf8; use open ':encoding(UTF-8)'; open INFIL, "<:encoding(UTF-8)", "temp.txt" or die; #This line generat +es a warning. #while (<INFIL>) { while (<DATA>) { chomp; my $title = $_; $title =~ s/\/.*//; $title =~ s/\[by.*//; print "Title Searched: $title\n"; $title = url_encode_utf8($title); my $html = getprint("https://clio.columbia.edu/catalog?q=$title&se +arch_field=title_starts_with&f%5B-format%5D%5B%5D=Online&commit=Searc +h") or die; } exit; __DATA__ How to conduct your own survey / Priscilla Salant and Don A. Dillman.

But, if I change it to read from a file, like so:

#! /usr/bin/perl -C255 use strict; use warnings; use LWP::Simple; use Encode 'decode'; use URL::Encode ':all'; use feature 'unicode_strings'; use utf8; use open ':encoding(UTF-8)'; open INFIL, "<:encoding(UTF-8)", "temp.txt" or die; #while (<DATA>) { ###CHANGE HERE### while (<INFIL>) { chomp; my $title = $_; $title =~ s/\/.*//; $title =~ s/\[by.*//; print "Title Searched: $title\n"; $title = url_encode_utf8($title); my $html = getprint("https://clio.columbia.edu/catalog?q=$title&se +arch_field=title_starts_with&f%5B-format%5D%5B%5D=Online&commit=Searc +h") or die; } exit; __DATA__ How to conduct your own survey / Priscilla Salant and Don A. Dillman.

I get the error: 501 Protocol scheme 'https' is not supported (LWP::Protocol::https not installed) <URL:https://clio.columbia.edu/catalog?q=How+to+conduct+your+own+survey+&search_field=title_starts_with&f%5B-format%5D%5B%5D=Online&commit=Search>

The input file contains only a single line, the same as the DATA section.

I've tried this on both Strawberry Perl 5.24.1 and Cygwin Perl 5.22.3

All feedback appreciated.

Thanks, Michael


In reply to Odd LWP Problem by mdkoehn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.