Hi
foO,
If I understand you correctly you guessed right why
@t is empty because you needed to escape the fullstop (dot ".") in
split. Try something like this:
#!/usr/bin/perl -w
use strict;
my $ip = "192.168.2.34";
my @t = split(/\./, $ip);
my $x = @t;
print "Number of elements in array: $x\n";
print "Content of array: @t\n";
As a beginner now would be a good time to learn to
use strict and
warnings (
-w flag after shebang). These are handy tools for debugging your future scripts.
update: changed text slightly because the node got retitled.