For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > October 2006 > matching FORTRAN hollerith constants









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author matching FORTRAN hollerith constants
Ancient_Hacker

2006-10-30, 7:03 pm

Some folks still use good-old Fortran

Some old Fortran programs have those old "Hollerith constants". A
mediocre idea, but there you are.

In case you're of a tender age and have never used Fortran, here are a
gfew examples:

28HHORRORS OF OLD PROGRAM CODE
4LCPMP ! Left justified in a word
2Rqw ! Right justified

Now how would you match one of these dinosaurs using a Perl regular
expression?

sure, you can match the first part pretty easily: ([0-9]+[HLR])

but how do you match the variable length rest?


Any hints appreciated.

usenet@DavidFilmer.com

2006-10-30, 7:03 pm

Ancient_Hacker wrote:
> sure, you can match the first part pretty easily: ([0-9]+[HLR])
> but how do you match the variable length rest?


/([0-9]+[HLR]\w*)/;

That says:

Match one or more of the character class 0-9 (though most folks would
just use \d+ instead)

Followed by one instance of an uppercase letter H, L, or R

followed by zero or more occurances of any alphanumeric characters
(including '_')

And put whatever was matched into $1

--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com