RCP has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to extract a specific data from a
one line file that contains the below information:
## /loc1/loc2/loc3/848xxxxxB01_d_1
while I was able to do it with the code below,
how do I get the same information if the line
had looked like:
## /loc1/loc2/loc3/loc4/848xxxxxB01_d_1
or
## /loc1/848xxxxxB01_d_1
OUTPUT would look like this:
848xxxxxB01_d_bot
#! perl -w open(MYOUTFILE, ">/tmp/design_name_bot"); open (FILEH, "/tmp/strfile") +;while (<FILEH>) { chomp; if ( /848*/i ) { tr/\// /; tr/_/ /; ($board,$iss) = (split)[4,5]; ($line) = "_"; ($side) = "bot"; open(MYOUTFILE, ">>/tmp/design_name_bot"); print MYOUTFILE "$board$line$iss$line$side\n"; } } close(MYOUTFILE);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: extracting data from a line
by duff (Parson) on Oct 22, 2004 at 15:46 UTC | |
|
Re: extracting data from a line
by gothic_mallard (Pilgrim) on Oct 22, 2004 at 15:55 UTC | |
by RCP (Acolyte) on Oct 27, 2004 at 14:19 UTC | |
by gothic_mallard (Pilgrim) on Oct 28, 2004 at 07:10 UTC | |
by RCP (Acolyte) on Nov 02, 2004 at 16:59 UTC | |
|
Re: extracting data from a line
by Random_Walk (Prior) on Oct 22, 2004 at 16:11 UTC | |
by TedPride (Priest) on Oct 22, 2004 at 17:03 UTC | |
by Random_Walk (Prior) on Oct 23, 2004 at 10:36 UTC |