Hello All. Thank you for reading my email :) I am trying to get this code to write the variables in a specific order, even if they are undefined or blank. I would like each row seperated by newline. I am running into a problem with the scope of the variable being limited to the block of code it is in.
Can anyone help. Here is the code [code] #!/perl -w use strict; my $directory = "C:/documents and settings/administrator/my documents/"; my $file = "rentals April 6 2004 mesquite"; my $ext = ".txt"; my $outfile = "$file.parse"; open(FILE, "<$directory$file$ext") or die "Can't open $file \n\n$!"; #open(OUT, ">$directory$outfile") or die "Can't open $outfile \n\n$!"; while(<FILE>){ if(m/(\$+\d+)/g) { my $price = $1; $price =~ s/^\s+//; #remove leading spaces $price =~ s/\s+$//; #remove trailing spaces $price =~ s/(\d)\W(\d\d\d)/$1$2/; print "\"\nprice: $price\","; } if(m/BD:*\s+(\d+)/g) { my $bd = $1; $bd =~ s/^\s+//; #remove leading spaces $bd =~ s/\s+$//; #remove trailing spaces print "\"beds: $bd\","; } if(m/BA:*\s+(\d+)/g) { my $ba = $1; $ba =~ s/^\s+//; #remove leading spaces $ba =~ s/\s+$//; #remove trailing spaces print "\"baths: $ba\","; } if(m/LA:*\s+(\d+)/g) { my $la = $1; $la =~ s/^\s+//; #remove leading spaces $la =~ s/\s+$//; #remove trailing spaces print "\"la: $la\","; } if(m/(\d\d\d-\d\d\d-\d\d\d\d)/g){ my $phone = $1; print "\"phone: $phone\","; } if(m/(\d\w+\W\d\w+\W\d\s+)/g){ my $arrangement = $1; print "\"arrangement: $arrangement\","; # print ("\n"); } if(m/(\w+[\W\s]?\w+[\W\s]?)\s+\W\s+(\w+\s\w+\s\w+\s\w+)\s+\W\s+(\d+\W\d+\W\d +)/g){ my $location = $1; my $paper = $2; my $date = $3; print "\"location: $location\","; print "\"paper: $paper\","; print "\"date: $date\","; } if(m/(\d\d\d+\s\w+[\W\s]?\w+)/g){ my $address = $1; print "\"address: $address\","; # print "\n"; } }#end while [/code] Here is the result price: $725","beds: 3","baths: 1"," price: $725","phone: 972-289-2098","location: Mesquite ","paper: The Dallas Morning News","date: 04/08/2004"," price: $950","beds: 3","baths: 1"," price: $950","phone: 469-525-0204","address: 1620 Summitt","location: Mesquite ","paper: The Dallas Morning News","date: 04/08/2004"," price: $1100","beds: 4","baths: 2","la: 2"," price: $1100","phone: 214-566-6106","location: Mesquite ","paper: The Dallas Morning News","date: 04/08/2004"," price: $995","beds: 3","baths: 2","address: 995 mo"," price: $995","arrangement: 11/2ba/1 ","address: 995 mo","location: Mesquite ","paper: The Dallas Morning News","date: 04/08/2004"," price: $850","beds: 3","baths: 1"," price: $850","phone: 972-216-0999","address: 3621 Edgebrook-3bd","location: Mesquite ","paper: The Dallas Morning News","date: 04/08/2004"," price: $995","beds: 4","baths: 1"," price: $995","phone: 972-303-5134","address: 3528 Statler","location: Mesquite ","paper: The Dallas Morning News","date: 04/08/2004","beds: 4","baths: 2","phone: 214-356-2120","location: Mesquite ","paper: The Dallas Morning News","date: 04/08/2004","beds: 3","baths: 1","phone: 214-417-6453","address: 2428 Vickie 214","location: Mesquite ","paper: The Dallas Morning News","date: 04/08/2004"," price: $1050","beds: 3","baths: 2","arrangement: 3bd/2ba/2 "," price: $1050","phone: 972-754-0214","location: Mesquite ","paper: The Dallas Morning News","date: 04/05/2004"," price: $1250","beds: 3","baths: 2"," price: $1250","address: 1617 Colborne","phone: 214-236-8717","location: Mesquite ","paper: The Dallas Morning News","date: 04/05/2004","beds: 3","baths: 2","phone: 214-478-9139","location: Mesquite ","paper: The Dallas Morning News","date: 04/05/2004"," price: $895","beds: 3","baths: 2"," price: $895","phone: 972-240-7503","address: 7503 972-226","location: Mesquite ","paper: The Dallas Morning News","date: 04/04/2004"," price: $750","beds: 3","baths: 1","arrangement: 3bd/1ba/1 "," price: $750","location: Mesquite ","paper: The Dallas Morning News","date: 04/04/2004"," price: $795","beds: 3","baths: 2"," price: $795","phone: 972-216-4988","location: Mesquite ","paper: The Dallas Morning News","date: 04/04/2004"," price: $1025","beds: 3","baths: 2"," price: $1025","address: 224 Overland Trail","location: Mesquite ","paper: The Dallas Morning News","date: 04/04/2004"," price: $995","beds: 3","baths: 2"," price: $995","phone: 972-681-4502","address: 800 dep","location: Mesquite ","paper: The Dallas Morning News","date: 04/04/2004"," price: $975","beds: 3","baths: 2","la: 2"," price: $975","phone: 214-343-4618","address: 1509 Liberty Ln","location: Mesquite ","paper: The Dallas Morning News","date: 04/04/2004"," price: $925","beds: 3","baths: 2"," price: $925","phone: 972-288-1495","address: 2309 Ithaca","location: Mesquite ","paper: The Dallas Morning News","date: 04/04/2004"," price: $1150","beds: 3","baths: 2"," price: $1150","phone: 214-827-7777","address: 4109 Aralia","location: Mesquite ","paper: The Dallas Morning News","date: 04/04/2004"," price: $1150","beds: 3","baths: 1"," price: $1150","phone: 214-755-3922","address: 800 dep sect","location: Mesquite ","paper: The Dallas Morning News","date: 04/04/2004"," price: $1025","beds: 3","baths: 2"," price: $1025","address: 224 Overland Trail","location: Mesquite ","paper: The Dallas Morning News","date: 04/02/2004", Here is the data file I am working on Click here to go back to Residential Real Estate for Rent. Your search for Mesquite returned the following ads: *If your search did not return as many ads as you'd like, simply go back and search again using fewer search criteria. ---------------------------------------------------------------------------- ---- Ads basket. Check to add. Uncheck to remove. Price: $725 BD: 3 BA: 1 LA: Home 3bd-1ba-1,ch/a new carpet & paint fence stove $725+dep. 972-289-2098 Mesquite - The Dallas Morning News - 04/08/2004 ---------------------------------------------------------------------------- ---- Ads basket. Check to add. Uncheck to remove. Price: $950 BD: 3 BA: 1.5 LA: Home 3bd/1.5ba/2 1620 Summitt $950+dep Sec 8ok 469-525-0204; 214-957-8176 Mesquite - The Dallas Morning News - 04/08/2004 ---------------------------------------------------------------------------- ---- Ads basket. Check to add. Uncheck to remove. Price: $1100/mo BD: 4 BA: 2 LA: 2 Home 4bd/2ba/2/2la close to schl/mall avail now $1100/mo+$1000/dep Sec. 8 ok welcome 214-566-6106 Mesquite - The Dallas Morning News - 04/08/2004 ---------------------------------------------------------------------------- ---- Ads basket. Check to add. Uncheck to remove. Price: $995 mo BD: 3 BA: 2 LA: Home-$995 mo/$600 dep. Beautiful 3br/11/2ba/1 gar near schl (214) 755-2861 Mesquite - The Dallas Morning News - 04/08/2004 ---------------------------------------------------------------------------- ---- Ads basket. Check to add. Uncheck to remove. Price: $850mo BD: 3 BA: 1.5 LA: Home-3621 Edgebrook-3bd-1.5ba-1gar-$850mo-$850dp-no pets-tel.972-216-0999 Mesquite - The Dallas Morning News - 04/08/2004 ---------------------------------------------------------------------------- ---- Ads basket. Check to add. Uncheck to remove. Price: $995 BD: 4 BA: 1.5 LA: Home-4bd/1.5ba/den: 3528 Statler, $995+$1000dep I-30/Eastfield area. 972-303-5134 Mesquite - The Dallas Morning News - 04/08/2004 ---------------------------------------------------------------------------- ---- Ads basket. Check to add. Uncheck to remove. Price: BD: 4 BA: 2.5 LA: Home-4bd/2.5ba/2cp, remodeled, strg bldg, rent to own. 2100sf. 214-356-2120 Mesquite - The Dallas Morning News - 04/08/2004 ---------------------------------------------------------------------------- ---- Ads basket. Check to add. Uncheck to remove. Price: BD: 3 BA: 1 LA: Home-Sec 8. 3bd/1ba remodeled. Open Sat & Sun, 2-4. 2428 Vickie 214-417-6453 Mesquite - The Dallas Morning News - 04/08/2004 ---------------------------------------------------------------------------- ---- Ads basket. Check to add. Uncheck to remove. Price: $1050/mo BD: 3 BA: 2 LA: Home 3bd/2ba/2 brick ch/a fp $1050/mo $900/dep 972-754-0214 Mesquite - The Dallas Morning News - 04/05/2004 ---------------------------------------------------------------------------- ---- Ads basket. Check to add. Uncheck to remove. Price: $1250/mo BD: 3 BA: 2 LA: Home Rent To Own 3bd/2ba/2gar 1617 Colborne $1250/mo. Bad Credit OK 214-236-8717 HappyHouseSellers.com Mesquite - The Dallas Morning News - 04/05/2004 ---------------------------------------------------------------------------- ---- Ads basket. Check to add. Uncheck to remove. Price: BD: 3 BA: 2 LA: Home-gorgeous 4-3bd/2ba/gar, all new, must see. Sec 8 ok. Avail 214-478-9139 Mesquite - The Dallas Morning News - 04/05/2004 ---------------------------------------------------------------------------- ---- Ads basket. Check to add. Uncheck to remove. Price: $895/mo BD: 3 BA: 2 LA: Dup. 3bd/2ba, $895/mo. Owner/Agent. Section 8! 972-240-7503 972-226-4446 Mesquite - The Dallas Morning News - 04/04/2004 ---------------------------------------------------------------------------- ---- Ads basket. Check to add. Uncheck to remove. Price: $750/mo BD: 3 BA: 1 LA: Home 3bd/1ba/1 ch/a $750/mo + $600/dep (972) 285-2090 Mesquite - The Dallas Morning News - 04/04/2004 ---------------------------------------------------------------------------- ---- Ads basket. Check to add. Uncheck to remove. Price: $795/mo BD: 3 BA: 2 LA: Home 3bd/2ba/den, brick, CH/A, new crpt, appls, $795/mo+dep. 972-216-4988 Mesquite - The Dallas Morning News - 04/04/2004 ---------------------------------------------------------------------------- ---- Ads basket. Check to add. Uncheck to remove. Price: $1025/mo BD: 3 BA: 2 LA: Home-224 Overland Trail 3bd/2ba/2gar $1025/mo, Sec 8 ok. (972) 554-8833 Mesquite - The Dallas Morning News - 04/04/2004 ---------------------------------------------------------------------------- ---- Ads basket. Check to add. Uncheck to remove. Price: $995/mo BD: 3 BA: 2 LA: Home-3bd/2ba/2, fp, $995/mo, $800 dep, 2426 Beverly Hills Lane, exc cond, credit check. 972-681-4502 Mesquite - The Dallas Morning News - 04/04/2004 ---------------------------------------------------------------------------- ---- Ads basket. Check to add. Uncheck to remove. Price: $975. BD: 3 BA: 2 LA: 2 Home-3bd/2ba/2cp/2la, sec & sprnklr, no pets, no Sec 8. 1509 Liberty Ln. Hwy 80/Beltline. $975. 214-343-4618 Mesquite - The Dallas Morning News - 04/04/2004 ---------------------------------------------------------------------------- ---- Ads basket. Check to add. Uncheck to remove. Price: $925/mo BD: 3 BA: 2 LA: Home-3bd/2ba/2ga, $925/mo + dep, very clean, 2309 Ithaca, 972-288-1495 Mesquite - The Dallas Morning News - 04/04/2004 ---------------------------------------------------------------------------- ---- Ads basket. Check to add. Uncheck to remove. Price: $1150/mo BD: 3 BA: 2 LA: Home-Poteet Schools! 3bd/2ba/2ga, 1900sf, WBFP, very nice, 4109 Aralia, no pets. $1150/mo. 214-827-7777 Mesquite - The Dallas Morning News - 04/04/2004 ---------------------------------------------------------------------------- ---- Ads basket. Check to add. Uncheck to remove. Price: $1150/mo BD: 3 BA: 1.5 LA: Home: 3bd/1.5ba near school $1150/mo + $800 dep sect. 8 ok 214-755-3922. Mesquite - The Dallas Morning News - 04/04/2004 ---------------------------------------------------------------------------- ---- Ads basket. Check to add. Uncheck to remove. Price: $1025/mo BD: 3 BA: 2 LA: Home-224 Overland Trail 3bd/2ba/2gar $1025/mo, Sec 8 ok. (972) 554-8833 Mesquite - The Dallas Morning News - 04/02/2004 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>