Discussion Locked

perl script

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I have a log file of 10 MB size in which i have to find mac- address and there response status.what i do is first search through the file get all the mac -address and response status in a hash table . then i ask input from user for the mac address for which he want to see the response- status. the place where i require help is that how can i compare mac address and also how do i remove single quotes around a string

2 replies

by solrak29

# removing single quotes from a string

# here are some options depending on what you want
# removes all quotes
$quotedstring =~ s/\'//g;

# removes beginning and end quotes
$quotedstring =~ s/^\'//;
$quotedstring =~ s/$\'//;

# comparing mac addresses

# I believe there is a better command
# called exists or something like that.
# but defined should work.
if ( defined $machash{$userrequest} )
{
return $machash{$userrequest};
}

This discussion is closed to new replies.