Hi All~

 

I'm trying to get my head around local $/ = ''; #enable paragraph mode. 

 

If I have a tab delimited file that looks like this: 

 

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.

 

and code that looks like this:

 

    local $/ = '';

    while (<OLD>) {

    

    my @rows = split /\n/;

        

    print SAVESTDOUT join("\t", @rows), "\n";

 

    }

 

which produces an output file that looks like this: (exactly what I want)

 

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.

 

I understand that $/ uses a blank line as a record separator but is it
correct in saying that $_ is being assigned to every line in the original
file?  And if so, why is my @rows = split /\n/; only splitting on the blank
line (record separator) and not after each line in the file?  I guess I
don't understand the magic that is happening... could someone pls explain
this in beginners' terms?  :~)

 

Thank you!

 

brian volk

 

Reply via email to