Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: How to: Use LWP / HTTP::Request:Simple; TO->>>>>>

by 2teez (Vicar)
on Jan 08, 2013 at 02:57 UTC ( #1012146=note: print w/replies, xml ) Need Help??

in reply to How to: Use LWP / HTTP::Request:Simple; TO->>>>>>

Hi ProgrammerJutsu and welcome to the Monastery.

"...i can share with you my fail code on the read file => my Regex, if you can help......Any help is much appreciated"
You have come to the right place where you can get help, if you can post your question effectively.
Please see How do I post a question effectively?

" seems like code sharing is difficult to do within this web site.."
No, not at all. Just place your code to share within a <code> and </code> tags

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me

Replies are listed 'Best First'.
Re^2: How to: Use LWP / HTTP::Request:Simple; TO->>>>>>
by AnomalousMonk (Chancellor) on Jan 08, 2013 at 03:09 UTC
Re^2: How to: Use LWP / HTTP::Request:Simple; TO->>>>>>
by ProgrammerJutsu on Jan 08, 2013 at 06:47 UTC

    Thanks for the response: 2teez

    So far: I have 2 different codes that i will eventually merge but for developing purposes I'm testing them separately. Also there is a txt file that I'm pulling the addresses from and an html source file from USPS zip code verification web site.

    I will share HTTP:Request::Simple; .pl code I am working with and the URL for the USPS Zip verify site:!input.action

    I'm fairly new to PERL and interning on a learning curve basis for a tax software company. I'm getting very little assistance from the senior programmer, due to the busy tax season, so i come to the monastery looking for help =D

    For this post i will focus on my questions about the HTTP::Request::Simple; Module.

    This is the code i have sofar: Updated 1/8/2013 9:53 AM
    Part 1:
    #!/usr/bin/perl use LWP::Simple; use HTTP::Request::Common; print "\n"; my $filename = ('Random addresses.txt'); my $txtContent = ""; open(IN, '<', $filename); while(my $line = <IN>){ $txtContent .= $line; } close(IN); my @address =split (m/\r+$/, $txtContent); my $val = 0; foreach($val(@address)){ print $val . "\n"; print "end Val\n"; }
    I am having trouble with the regular expression, I'm getting a ridiculous output for my split.
    Basically my code is underdeveloped. I'm aware there are some errors, and ill fix them tomorrow.

    How do you suggest i write my split(/\r$/ ,$txtContent ); regular expression to get rid of errors? I tried many ways of writing it and got bad results.

    Things I'm working on:
    I need to learn how to submit the address hash into the web page, so that i can then verify whether they are valid addresses.
    (It's not easy to find examples about the Http: module that are relevant to my project on google. ) =(

    I really need to study some examples of working code that use the Http:: module to submit html form data from a hash and how to save hash values to an array

    I'm also having trouble debugging my regular expression and saving the values from the txt document to the proper location.

    I will be working on this all day today!
    If anyone can contribute in any way it would be much appreciated

    Happy coding!

    Currently reading :

    Broken address grabber:
    #!/usr/bin/perl use LWP::Simple; use HTTP::Request::Common; use Data::Dumper; print "\n"; my %address =( 'Address' => "", 'City' =>"", 'State' =>"", 'Zip' => "", '9-Digit Zip' => "", ); my $filename = ('addresses.txt'); my $txtContent = ""; open(IN, '<', $filename); while(my $line = <IN>){ $txtContent .= $line; } close(IN); my @address = split(/\r{2,2}/, $txtContent); foreach my $val(@address){ print "$val\n"; print "EXIT line\n" }

    Alabama Alabama Bureau of Tourism & Travel PO Box 4927 Montgomery, AL 36103 Alaska Alaska Division of Tourism PO Box 110801 Juneau, AK 99811-0801 Arizona Arizona Office of Tourism 1110 W. Washington Street, Suite 155 Phoenix, AZ 85007 Arkansas Arkansas Department of Parks and Tourism One Capitol Mall Little Rock, AR 72201 California California Division of Tourism PO Box 1499 Dept TIA Sacramento, CA 95812 Colorado Colorado Tourism Office 1625 Broadway Suite 2700 Denver, CO 80202 Connecticut Connecticut Commission on Culture & Tourism One Financial Plaza 755 Main Street Hartford, CT 06103 Delaware Delaware Tourism Office 99 Kings Highway PO Box 1401 Dover, DE 19903 Florida Florida Office of Tourism PO Box 1100 Tallahassee, FL 32302 Georgia Georgia Department of Economic Development 75 Fifth Street, N.W., Suite 1200 Atlanta, GA 30308 Hawaii Hawaii Department of Business, Economic Development and Tour +ism PO Box 2359 Honolulu, HI 96804 Idaho Idaho Department of Commerce, Travel, Leisure and Tourism 700 West State St. PO Box 83720 Boise, ID 83720-0093 Illinois Illinois Dept. of Commerce and Community Affairs 620 E. Adams Springfield, IL 62701 Indiana Indiana Department of Tourism One North Capitol Suite 700 Indianapolis, IN 46204 Iowa Iowa Dept. of Economic Development 200 East Grand Ave. Des Moines, IA 50309 Kansas Kansas Dept. of Commerce Travel And Tourism Div. 1000 S.W. Jackson Street Suite 100 Topeka, KS 66612 Kentucky Kentucky Department of Travel 500 Mero St. #2200 Frankfurt, KY 40601 Louisiana Louisiana Dept. of Culture, Recreation and Tourism PO Box 94291 Baton Rouge, LA 70804-9291 Maine Maine Office of Tourism #59 State House Station Augusta, ME 04333-0059 Maryland Maryland Office of Tourism Development 217 Redwood St Baltimore, MD 21202 Massachusetts Massachusetts Office of Travel and Tourism 10 Park Plaza Suite 4510 Boston, MA 02116 Michigan Michigan Economic Development 300 N. Washington Sq. Lansing, MI 48913 Minnesota Minnesota Office of Tourism 500 Metro Square 121-7th PL East St. Paul, MN 55101 Mississippi Mississippi Dept. of Economic and Community Development Division of Tourism Development PO Box 849 Jackson, MS 39205 Missouri Missouri Division of Tourism PO Box 1055 Jefferson City, MO 65102 Montana Montana Department of Commerce 1424 9th Ave. PO Box 200533 Helena, MT 59620-0533 Nebraska Nebraska Tourism Office PO Box 98907 Dept. 9INT Lincoln, NE 68509-8907 Nevada Nevada Commission on Tourism 401 North Carson St. Carson City, NV 89701 New Hampshire New Hampshire Office of Tourism PO Box 1856 Concord, NH 03302 New Jersey New Jersey Commerce and Economic Growth Commission PO Box 820 20 W. State St. Trenton, NJ 08625 New Mexico New Mexico Department of Tourism 491 Old Santa Fe Trail PO Box 20002 Santa Fe, NM 87501 New York New York Department of Tourism PO Box 2603 Albany, NY 12220-0603 North Carolina North Carolina Department of Commerce 301 N. Wilmington St. Raleigh, NC 27601 North Dakota North Dakota Tourism Liberty Memorial Building 604 East Boulevard Bismark, ND 58505-0825 Ohio Ohio Department of Commerce 77 South High St 23rd Floor Columbus, OH 43266-0544 Oklahoma Oklahoma Department of Tourism and Recreation 20 N. Robinson Avenue, 6th Floor PO Box 52002 Oklahoma City, OK 73152-2002 Oregon Oregon Toursim Commission 775 Summer St, NE Salem, OR 97310 Pennsylvania Pennsylvania Tourism Office Dept. of Community & Economic Development 4th Floor, Commonwealth Keystone Building 400 North Street Harrisburg, PA 17120 Rhode Island Rhode Island Economic Development Corporation Tourism Division One West Exchange St. Providence, RI 02903 South Carolina South Carolina Department of Parks, Recreation and T +ourism 1205 Pendleton St Suite 106 Columbia, SC 29201 South Dakota South Dakota Department of Tourism 711 East Wells Ave. c/o 500 East Capitol Ave. Pierre, SD 57501-5070 Tennessee Tennessee Department of Tourist Development Rachel Jackson State Office Building 320 Sixth Ave., 5th Floor Nashville, TN 37243 Texas Texas Dept. of Economic Development PO Box 12728 Austin, TX 78711 Utah Utah Travel Council Council Hall Capitol Hill Salt Lake City, UT 84114 Vermont Vermont Agency of Commerce and Community Development Department of Tourism and Marketing 6 Baldwin St., Drawer 33 Montpelier, VT 05603-1301 Virginia Virginia Tourism Corporation 901 E. Byrd St. Richmond, VA 23219 Washington Washington State Community, Trade and Economic Developme +nt 906 Coumbia St. SW PO Box 48300 Olympia, WA 98504-8300 West Virginia West Virginia Division of Tourism 2101 Washington St., E. Charleston, WV 25305 Wisconsin Wisconsin Department of Tourism 201 W. Washington Ave. PO Box 8690 Madison, WI 53708-8690 Wyoming Wyoming Travel & Tourism I-25 at College Dr. Cheyenne, WY 82002

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1012146]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2018-08-16 07:56 GMT
Find Nodes?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:

    Results (167 votes). Check out past polls.