Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I'm trying to use this URL

Define use...

Where it says $sku, that will change constantly via a database

Then you probably want to interact with the database in any way: use DBI

my @sku = ('CODE TO THE DATABASE')

Good try...

my %code = 'CODE TO SOLVE YOUR PROBLEM HERE'; ;-)

Aha, question updated with some real code, let's see...

looks like a work for a hash... my @sku = ('NUMBER') is not what you want probably; first of all because @ mean a list of elements, not a single number, and also because a %hash is much better here. If you define @sku as an array you could have by mistake the same number for two products (and this is a BIG problem), but a hash will not permit you to do this. The number $sku is the key (unique) and the catalog ref is the value.

so the first thing that you should try to fix is these two lines.

my @sku = ('NUMBER'); for my $sku (@sku) {...

Instead connect to the database and prepare something like: select field2 for mytable where field1 = ? and fill the gap with the correct number sku with execute($sku). Read the manual of DBI for the details

finally when you have your hash you could write something like this

https...partnumber=$sku...catalog_number=$hash{$sku}&inE=1&highlight...

In reply to Re: Script for a URL that constantly changes by pvaldes
in thread Script for a URL that constantly changes by semrich

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-24 20:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found