Question: I would like to print the output into CSV file instead of in the command prompt itself.
Here is the piece of code in perl:
#!/usr/bin/perl
use strict;
use warnings;
use HTML::TokeParser::Simple;
my $url = '<some URL>';
my $parser = HTML::TokeParser::Simple->new( url => $url );
my %tags;
while ( my $tag = $parser->get_tag('input') ) {
my $id = $tag->get_attr('id'); # get id attribute value
my $value = $tag->get_attr('value'); # get value attribute value
$tags{$id} = $value;
}
for (keys %tags) {
print "$_ => $tags{$_} \n";
}
Output in command prompt
ConnectionTime => 03:20:59:46
signalstrength => Good
ulCurrentDataRate => 2.48 Kbps
batterystatus => Fully Charged
Required Output in CSV file
ConnectionTime signalstrength ulCurrentDataRate batterystatus
03:20:59:46 Good 2.48 Kbps Fully Charged