thanks, now I am not clear on how this part works?
What is the $socket=IO::Socket::INET ->new(%host) part doing??
And what does ${host}:${port} represent??, Are these aliases??
if($socket = IO::Socket::INET->new(%host)){
print "Connected to $host on port $port\n";
print...
How would you do the same thing in checking several IP addresses??
I tried putting the $host variable in an array but couldnt get it to work.
@host = "111.111.111.111 454.333.335.333 334.333.334.333"; # or an IP address
Greg,
I tried running your script and got the following messages:
Checking File Systems
Mount Total Used Free Used% Test
diskmon: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xx: not found
awk: syntax...
I got the output I wanted and was wondering it this is the best way to do it??
$db = 'aaa.txt';
open(FILE, "$db") or die "File does not open: $!";
while(<FILE>)
{
if ($weight = (/\b(weight)(\s+)(\d+)/))
{
print $1 . $2 . $3;
}
}
close FILE;
Still no luck I tried:
print $weight;
print $_;
print FILE;
and none of the above printed out weight 2.
MOst of the print outs were of the whole file such as:
--- Garbage Line ---
and has weight 2kg with blah blah
--- Garbage Line ---
Any other suggestions??
Please advise how I would print results to the screen?
I can only get it to print the whole file contents instead of
printing out the variable and number 2.
$db = 'tex.doc';
open(FILE, "<$db") or die "File does not open: $!";
#@data = (<DATA>);
#close (DATA)...
1 012345 Literature Book Pkged with Audio
$var =~ s/\A(\d+) +(.*)\Z/$1\t$2/;
Please explain what this is doing?
It is starting with beginning of string (which is the number 1?) and then what is the
+(.*) doing? I know the \Z is ending the string. But what part of the string is it ending??
Can you advise what the $a and $b represent in this script. I understand the splitting up of data and sorting but I am lost with these two variables. Are you storing the three fields in each one?
@field1 = split (/\s+/,$a);
@field2 = split (/\s+/,$b);
Thanks for explaining the details about C++ and Perl. I am just learning both and just wondering what other Perl and C++ books you recommend? Also how many years did it take for you to get comfortable with both languages? I tried the Learning perl and perl cookbook but want something with...
I am in the process of learning Perl and C++. Can you use Perl alot with Windows?
And can you use C++ and Perl in Unix environment. If so how would the two differ?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.