Not totally sure what you're wanting from this... but if I'm reading correctly then this should work:
while (<DATA>) { /\/([^\/]+)\d$/; print $1."bot\n"; } __DATA__ ## /loc1/loc2/loc3/848xxxxxB01_d_1 ## /loc1/loc2/loc3/loc4/848xxxxxB01_d_1 ## /loc1/848xxxxxB01_d_1
Obviously here I'm replacing your input file with the __DATA__ block for ease of example and naturally you could change the print $1."bot\n"; to print MYOUTFILE $1."bot\n";.
All code is untested unless otherwise stated.
In reply to Re: extracting data from a line
by gothic_mallard
in thread extracting data from a line
by RCP
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |