On Wednesday 03 January 2001 00:24, Tollef Fog Heen wrote: > | My lilo configuration scripts need to be able to infer the correct > | location for the MBR. I am currently using the following algorithm: > | take root fs device from /etc/fstab and do the following: > | s/[0-9]*// > | s/part$/disc/ > > What is the use of the first s/? Unless your first letter is a digit, > it will just remove the zero-width string '' between the first / and > the beginning of the string. > > A better solution will probably be to > > s/[0-9]$// > > which will remove 5 from /dev/hda5.
Correct. In my code I have s/[0-9]*$//. That part of my email was re-typed from memory and I missed a character. The discussion this generated was enlightening though. On Wednesday 03 January 2001 01:00, Bart Schuller wrote: > However, stylistically s/[0-9]*// is better written as s/[0-9]+// > because the case where no digits match is better classified as > "not a match". Good point! I have changed my code accordingly. On Wednesday 03 January 2001 02:33, Tollef Fog Heen wrote: > s/\d+// on devfs devices is dangerous, you'll get rid of the host > number: > > perl -e '$_ = "/dev/ide/host0/bus0/target0/lun0/part1"; s/[0-9]+//; print > $_,"\n"' /dev/ide/host/bus0/target0/lun0/part1 Right. The s/[0-9]+$// should do it. Now does anyone have suggestions about what file name I should give to my mini-perl program or what else I should do to make it generally usable? -- http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/projects.html Projects I am working on http://www.coker.com.au/~russell/ My home page