Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Array empty

by arno (Scribe)
on Oct 05, 2003 at 13:09 UTC ( #296694=note: print w/replies, xml ) Need Help??

in reply to Split on . (dot)

hi, In you code, split returns all fields found in $ip using '.' metacharacter as a delimiter. '.' metacharacter matches almost any character but newline. As a consequence,@t will contain invisible characters as NUL character and \n. When you do :
map { print ord $_,"\n" } split(/./, $ip);
You 'll print the ascii code of each element in the returned list by split function. Here's the output i get :
0 is the ascii NUL and 10 is the newline character. I hope you understand these explanations, Arnaud

Replies are listed 'Best First'.
Re: Re: Array empty
by bart (Canon) on Oct 05, 2003 at 14:11 UTC
    Close. But ord($_) returns 0 not because it contains a null byte, but because it is an empty string.
    print ord("");
    prints: 0
    (Where on earth would he be getting null bytes from?)

    Indeed, the resulting array he's getting after doing

    $ip = "21.23\n"; @t = split /./, $ip;
    ("", "", "", "", "", "\n")

    The explanation: every character in the input string, except the newline, is used as a split delimiter. Thus you get, as a result, the stuff between those characters, which is nothing every time, except at the last character.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://296694]
[marinersk]: Corion This DBA wants to smack others who like putting whitespace in column names.
[marinersk]: s/smack/whap/;
[talexb]: Wow, what hilariously bad form.
[SuicideJunkie]: Just wait; someday soon, you'll be given a DB with unicode emojis in the column names.
[Corion]: marinersk: Well, I have done select statements like select sum(foo) as "Total Amount", ..., but to have a table like that makes me shudder
[Corion]: SuicideJunkie: :-D
[marinersk]: SuicideJunkie LOL
[choroba]: Woohoo! Fixed a test that hasn't run for 3 years.

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (14)
As of 2017-05-25 15:00 GMT
Find Nodes?
    Voting Booth?