Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
 Discussion Forums
 HTML, XML, JavaScript...
 Software Reviews
 Editors,Others...
 Top100
 JavaScript Tutorials, ...
 Tutorials
 ASP, CSS, Databases...
 Discussion List
 FAQ, Roundup, Configure ...
 Authoring
 HTML, JavaScript, CSS...
 Design
 Layout, Navigation,...
 Graphics
 Tools, Colors, Images...
 Software
 Browsers, Editors, XML...
 Internet
 Domains, E-Commerce, ...
 WDVL Resources
  Intermdiate, Tutorials,...
 WDVL
 Discussion Lists, Top 100,...
 Technology Jobs


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us
Imprinted Promotions
Desktop Computers
Promotional Items
Online Education
Home Improvement
Shop Online
Boat Donations
Memory Upgrades
GPS
Phone Cards
Memory
Disney World Tickets
Web Hosting Directory
Cell Phones

Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers



Quality Management ROI Calculator - Focus on Test Automation
The Rational Quality Management ROI calculator is intended to give you an idea of what return you can garner from implementing our functional testing solutions. Our quality management solutions offer tools to develop a continuous process, powered by automation to govern software delivery. »

Gartner MarketScope: Application Quality Management Solutions, 1Q 08
This Gartner MarketScope provides guidance for enterprises seeking to purchase tools to manage risk and software quality. We focus on tools fit for large-scale enterprise use and that are ready out of the box to manage quality requirements and functional testing. »

Whitepaper: Tips for Writing Good Use Cases
Writing a good use case isnt easy, but, fortunately, our experience can be your guide. The concepts and principles assembled here represent the works of many people at IBM, and they form a foundation of proven best practices. »

Whitepaper: The Role of Integrated Requirements Management in Software Delivery
Learn about the critical role integrated requirements management can play in helping ensure your business goals and IT projects are continuously aligned-whether you are sourcing, integrat-ing, building or maintaining your software. It also looks at ways that integration and automation can help ensure managing projects and the required changes can be executed using manageable processes that satisfy stakeholders and development teams. »
Top 10 Articles
  1. Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
  2. JavaScript Tutorial for Programmers
  3. Design
  4. JavaScript Tutorial for Programmers - Objects
  5. JavaScript Tutorial for Programmers - JavaScript Grammar
  6. JavaScript Tutorial for Programmers - Versions of JavaScript
  7. Cascading Style Sheets
  8. JavaScript Tutorial for Programmers - Embedding JavaScript
  9. JavaScript Tutorial for Programmers - Functions
  10. Authoring JavaScript
Domain Name Lookup
Search to find the availability of a domain name. Just enter the complete domain name with extension (.com, .net, .edu)

Tracking FedEx and UPS Packages Online - Page 25

January 21, 2002

The script in this article will keep your customers on your site and provide self-service package tracking capabilities for Federal Express and/or UPS.

Overview

Both UPS and Federal Express provide package tracking information on their Web sites. When customers purchase a product from your e-commerce site, it's preferable, however, to keep them on your site instead of forcing them to go off-site to track their package. You can provide this valuable service to your customers on your site with a Perl script. Users enter the order number, which is assigned by you and stored in a comma delimited CSV file which can originate from a database or spreadsheet. The order number cross-references the corresponding tracking number for either Federal Express or UPS. The script then uses the tracking number to look up the latest tracking data from FedEx or UPS and prints the results to the user's browser.

To get this script to work on your site, put the tracker.pl script in the cgi-bin directory on your Web server. You will need a recent version of Perl installed. If you are running a Windows platform, you can download Perl from Activestate; otherwise, you can download Perl from CPAN. You will also need to download tracker.csv and place the file somewhere on your system.

In addition to Perl, you will need the Business::UPS and Text::CSV_XS modules, also available from CPAN. If you are running Perl on a Windows server with Activestate Perl, you can install the module by typing the following commands from within a DOS prompt:

ppm install Business-UPS
ppm install Text-CSV_XS ppm
install LWP-Simple

With a regular installation of Perl, you can install the module by typing the following on the command line:

perl -MCPAN -e 'install Business::UPS'
perl -MCPAN -e 'install Text::CSV_XS
perl -MCPAN -e 'install LWP::Simple

Throughout this article, I will be referring to the numbered source code, so you might want to open this source in a separate window for reference as we step through the code.

Looking up Tracking Numbers

When a customer places an order, you probably track that customer's order with a unique number that originates from a database or e-commerce application. The tracker.pl application uses this number as a key in the tracker.csv file. This is the number that the customer will enter on the package tracking form. You will need to export this unique order number along with the tracking number for the FedEx or UPS package. The CSV file should contain 3 fields. The first field is the unique order number. The second and third fields are the FedEx and UPS tracking numbers respectively. Either the FedEx or UPS field will contain a value depending on which carrier you used to ship the package. Below is a sample tracker.csv file:

"123","830271123988",""
"321","","1Z 644 23W 02 4675 385 5"

The first line of the sample CSV file is order number 123. The package was shipped via FedEx and the tracking number is 830271123988. The second order number is 321 and was shipped via UPS; its tracking number is 1Z 644 23W 02 4675 385 5.

The location of this CSV file is set in the $csv_file variable on line 12 of tracker.pl. When the customer submits their order number to the Perl script, we need to parse the CSV file and lookup the tracking number. To accomplish this, I created the &get_tracking_num subroutine located on lines 41-58. Line 43 opens the CSV file and line 44 creates a new instance of the Text::CSV_XS module. This module provides the function to easily parse almost any type of CSV file, whether it was created by a database export or a spreadsheet program. On line 46, we loop over each line of the program, parse the line on line 47 with the parse() method, and grab the fields for the record with the fields() method on line 48. If the order number that we are searching for matches the order number in the record on line 49, we return the FedEx (or UPS) tracking number to the caller.

Keeping this CSV file is beyond the scope of this article and will be maintained automatically or manually by you. This script only reads from it to determine what the tracking number is for the order.

Saving The New Index Image - Page 24
Weaving Magic With Regular Expressions
Tracking The Packages - Page 26


Up to => Home / Authoring / Languages / Perl / Weave




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers