Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Array empty

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


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
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-03-29 07:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found