in reply to Re: text parsing
in thread text parsing

Hi Thank you for the very useful tips. i would love to show/explain the algorithm to you.
1.open a text file 2.if the text file contains alphabets then create a (test1.txt) file w +ith the name and telnet to the devices(34.56.67.78) mentioned under t +he test1 and execute the commands and store command output in the sam +e test1.txt file and telnet to device2(65.45.76.343)and run the same +commands.and if found next text (peak) then create peak.txt and so on... test1 34.56.67.78 65.45.76.343 peak 34.56.56.45 23.65.766.76 sdsd 45.65.76.56 343.45.45.453 435.65.67.878

Replies are listed 'Best First'.
Re^3: text parsing
by Moron (Curate) on Jul 10, 2006 at 10:07 UTC
    To get alphabetics, use the POSIX IsAlpha class, also it is usually easier and more maintainable to make loops into functional (based on key logic) rather than technical blocks (e.g. based on fh open state instead), for example:
    use strict; use warnings; use ... etc.; my $filename = 'filename'; my $msgfront = 'MESSAGE FROM SAT: '; my $path = $ENV{ PATHNAME } . "/$filename"; open my $ifh "<$path" or die $msgfront . "$!: $filename\n"; # 'group' loop for ( $_ = <$ifh>; $_ = <$ifh> and /:IsAlpha:/; ) { chop; my ( $group, @address ) = ( $_, () ); # 'address' loop for ( $_ = <$ifh> ; $_ = <$ifh> and !/:IsAlpha:/ ) { chop and push @address, $_; } # process $group with its @address -es here } close $ifh;

    -M

    Free your mind