in reply to Substring problem

Your problem is here:

while (<FILEHANDLE>) { my $ServerName = <FILEHANDLE>;

The while(<FILEHANDLE>) reads a value and puts it in $_. Then the next line reads another value and puts it in $ServerName. Try this instead:

while (my $ServerName=<FILEHANDLE>) {
$,=' ';$\=',';$_=[qw,Just another Perl hacker,];print@$_;

Replies are listed 'Best First'.
Re^2: Substring problem
by keith_kauai (Initiate) on Aug 26, 2009 at 20:26 UTC
    Thanks. Is there a way to determine the end of the file? I added a extra return and the end of the file as a workaround...however initially, the while loop would not read the last line. ie..
    server1234 server3444 server5555
    The output would read the first two lines, however the last line server5555 would just display as a blank, until i added a return to the end of the file.

      No need to. The <> operator knows to stop on EOF. You had the problem before because each iteration of the loop had two read ops, so you needed an even number of lines in the file to get it to terminate.

      $,=' ';$\=',';$_=[qw,Just another Perl hacker,];print@$_;