Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Array empty

by barrd (Canon)
on Oct 05, 2003 at 09:04 UTC ( [id://296691]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Split on . (dot)

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://296691]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.