Tugger the SLUGger!SLUG Mailing List Archives

[SLUG] Re: Perl splitting help


On Sat, Jul 22, 2000 at 05:52:42PM +1000, George Vieira wrote:
> I have a problem as I don't know Perl very well and need to do the
> following:
> 
> 1. Grab a file containing a list of people and phone numbers seperated by a
> | .eg.
> 
> --- playlist.txt---
> George Vieira|0410123123
> Another Person|0414321321
> 
> 2. Split the lines into fields so I can print each field into a cell in a
> table.

for such a simple task, i'd go with awk (see herbert's post).

and just to show that you can use sed to write scripts too:
(give data file as an argument or stdin)

--begin--
#! /bin/sed -f

# header
1i\
<html><head><title>heh</title></head>\
<body>\
 <table>

# footer
$a\
 </table>\
</html>

# per line stuff
 # change separator
 s,|,</td><td>,g

 # change beginning and end of line
 s,^,   <tr><td>,
 s,$,</td></tr>,
--end--

-- 
 - Gus