[mercury-users] Perl split, assign, retrieve in Mercury

Terrence Brannon tmbranno at oracle.com
Sat Jul 14 04:41:06 AEST 2001


A very common and easy thing to do in Perl is to read a file and split
each line on a delimiter and assign each element of the line to a
member of a hash and then obtain some member of the hash for
processing of some sort. A typical Perl program for this task is
included below. How would this be done in Mercury?

while (<DATA>) {

    @split{letters, numbers, junk} = split /:/;
    print $split{numbers};
}

__DATA__
abc:123:@#$#@
def:456:@!#@
hij:789:%$%$

--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list