Question

I have a problem about perl. What I want is that I want to read my configuration file and display it in a table. Here is my configuration file looks like:

VID1
VID2
VID3
VID4

After I read all the line in the configuration file, I want it to be displayed in a table. How can I achieve this? I know I have to use loop to get all the line. Is that correct? Can anybody help me with this? Any help would be much appreciated. By the way, I'm new in perl. The read part is not the problem. The problem is on how to display them into a table.

UPDATED

Example

I want it be like this and so on. The border is 0 by the way. How can I read all those line and print it out like these?

UPDATED

Here is the output that I'm trying to get. The table is in a loop and display all the value after it reads from the configuration file.

Example2

Was it helpful?

Solution

Try

sub print_line {
  my $source = shift;
  my $port = shift;
  my $ip = shift;
  format TABLE_FORMAT =
  Name of Video Source: @<<<<<<<<<<<<<<<
                        $source
     Local Port Number: @<<<<<<<<<<<<<<<
                        $port
Destination IP address: @<<<<<<<<<<<<<<<
                        $ip
.
  $~ = 'TABLE_FORMAT';
  write;
}

while (<>) {
  chomp;
  print_line($_, 'example', 'example');
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top