-----Original Message----- From: Tom Allison [mailto:[EMAIL PROTECTED] Sent: Saturday, November 19, 2005 4:43 PM To: Brian Volk Cc: 'beginners@perl.org' Subject: Re: local $/ = '';
Brian Volk wrote: > Hi All~ > > > > I'm trying to get my head around local $/ = ''; #enable paragraph mode. > > This will match everytime it encounters a match like /^$/ in regex terms. Unfortunately, I can't seem to repeat your output. But if I change it to the following it works just find. BTW -- learn to use 'perl -d' to help sort these things out. How do I use perl -d and what does it do? I tried Google'ing and searching perldoc but I didn't luck. Using my example you have the DATA in a format more like this: ^1311001\n$ ^Aed Motorsports\n$ ^5373 W 86th St\n$ ^Indianapolis, Indiana 46268 U.S.A.\n$ ^$ when you set $/='' it will only match on the ^$ lines making $_ the entire address (all four lines). When you split on /\n/ you tear up $_ into a four element array. At a trap to keep mind of when doing this, your data cannot contain a line like ^ $ or it won't match the $/='' test. Thank you very much for explaining! I understand how its working now. #!/usr/bin/perl use strict; use warnings; $/ = ''; while (<DATA>) { my @rows = split/\n/; print "@rows\n"; } __DATA__ 1311001 Aed Motorsports 5373 W 86th St Indianapolis, Indiana 46268 U.S.A. 7069210 Bird Electronic 30303 Aurora Rd Solon, Ohio 44139 U.S.A. 1020700 Charis Disk Golf Ste 160-135 4000 W 106th St Carmel, Indiana 46032 U.S.A. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>