in reply to text parsing

some hints

- terminate argument to die with "\n" if you want to suppress the traceback information

- while( my $line = <inFile> ) {

- it is a good habit to always specify full path names rather than just filenames

- you might want to try running with 'perl -d <scriptfile>' when debugging. The command 'h' will give a full set of debug commands available.

Update: also recommendable:

- declare all variables with 'my' and insert the following controls at the top of the program:

use strict; use warnings;

-M

Free your mind

Replies are listed 'Best First'.
Re^2: text parsing
by Anonymous Monk on Jul 10, 2006 at 05:00 UTC
    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
      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