in reply to Re: File Processing
in thread File Processing

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

Replies are listed 'Best First'.
Re^3: File Processing
by thor (Priest) on Jun 09, 2004 at 20:33 UTC
    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.

    thor

Re^3: File Processing
by Anonymous Monk on Jun 09, 2004 at 21:09 UTC
    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:"))
Re^3: File Processing
by Anonymous Monk on Jun 09, 2004 at 20:31 UTC
    The text your are looking for 2W36164K, why not use a simple pattern regex?