Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6756121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:29:12+00:00 2026-05-26T13:29:12+00:00

I’ve got a simple perl subroutine that checks to see if google is still

  • 0

I’ve got a simple perl subroutine that checks to see if google is still hosting a copy of jquery 1.6 before deciding whether to print a script linking to it or to our locally hosted copy.

This is a copy of the code I’m using.

my $jquery_host = "http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js";
my $header = LWP::Simple::head($jquery_host);

if(defined $header) {
    return qq{<script type="text/javascript" src="$jquery_host"></script>};
}
else {
    return qq{<script type="text/javascript" src="$localPath"></script>};
}

When I run this code on this command line, I have no problem retrieving a response, and it properly prints out a script tag linking to google’s copy of jquery. However, when I actually call it from a perl script that is building an html page, it finds nothing every time and prints out a script tag linking to our own copy.

What permissions or other type of barrier could be halting this connection?

Thanks for your help.

NOTE: This has only run on our local test server so far. The command line is also running on the test server.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:29:12+00:00Added an answer on May 26, 2026 at 1:29 pm

    I can confirm that your code works in isolation. Try wrapping the assignment to header into the if statement; in fact inline the url string too. The only other thing that could be messing with you is that your server script is running on a machine that uses some proxy or tcp wrapper which isn’t letting you fetch jQuery from google.com. We can’t really help you with these very specific very local issues.

    If I were just guessing I’d say that the you have more than one Perl environment going on, and that your command line is using a nice version where things work, but your web server is calling out to another version, one that might have been hardened in ways that break what you’re doing, like what was proposed for use in AppEngine. But my suggestions above are based on the idea that the code around this snippet might be messing with the variables you’re using. It seems this kind of issue does come up though around the use of io sockets in mod_perl.

    Program snippet:

    $ perl -MLWP::Simple -e '
    if(head("http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js")) {
        print qq{<script type="text/javascript"
          src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js">
        </script>};
    } else {
        print qq{<script type="text/javascript" src="$localPath"></script>};
    }'
    

    Output:

    <script type="text/javascript"
      src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js">
    </script>
    

    I’d also write this so that some $scriptPath gets assigned to either the jQuery path or the $localPath, and then past the if statement I’d print the script tag only once using the now determined $scriptPath. But that’s just me perhaps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.