[Sderby] PERL
David Jolley
dave at lucien.cx
Thu Nov 13 15:45:40 GMT 2003
Mike Hemstock wrote:
>Folks,
>
>A quick question. I am trying to write a PERL script to open a file, read
>values from it and rebuild those vaules into another file to be used by a
>piece of software. An extract from the file is below:
>
>a.adams.DADIESO SEC. SCH. - DADIESO.
>a.adigah.ACHISCO.
>a.agyapong-ntra.OPON MEM SEC. SCH..
>a.amoah.EFUTU SEC. TECH.
>
>
>
You mean something like:
#!/usr/bin/perl
while(<>) {
($initial, $surname, $school) = ( $_ =~ /(.{1})\.(.*?)\.(.*)\.$/ );
print "$initial $surname $school\n";
}
?
It should do the trick, but please take note that this was cobbled
together very quickly, tested and worked for me - and is probably very
close to write only code :)
Note that this uses stdin as it's file source, so you need to redirect
this script's stdin from the file required - I'm not doing *all* your
homework for you :)
Cheers
Dave
More information about the Sderby
mailing list