Err...come again? As far as perl is concerned, it doesn't matter that all of the files begin with a tab. In your scenario, how does one identify the "particular line"? Line number? Other words on the same line? Voodoo? Throw us a bone and we'll throw you one.
| [reply] |
The info looks like this, and I want to extract 2W36164K and write it to another file... I am identifying the line using
if ((substr($line,1,12)) eq ("Trunk Group:"))
Trunk Group: 2W36164K CLEAR_CHANNEL_TR
01/05/04 MON 12:00 48 194 1,556
01/09/04 FRI 10:00 48 192 1,560
| [reply] |
Okay, that's a start. What you're doing isn't technically wrong, but it's not very perl-ish. perl has a wonderful pattern matching facility; you may as well take advantage of it. If I'm understanding your problem, you could approach it like this:
if ($line =~ m/Trunk Group: (\w+)/) {
my $match = $1;
#do things with $match
}
I suggest you do a 'perldoc perlre' and read up on regular expressions. I think you'll be pleasantly surprised by what you find there.
| [reply] [d/l] |
Regex is a better solution, but to answer your original question you would use a \t to represent a tab character.
if ((substr($line,1,13)) eq ("\tTrunk Group:"))
| [reply] [d/l] |
The text your are looking for 2W36164K, why not use a simple pattern regex?
| [reply] |