in reply to Re: Re: Split an array -> store contents into a scalar up till a certain character
in thread Split an array -> store contents into a scalar up till a certain character
Then later, you can use it just as you would a regular scalar:my $addr = "25.255.2.0"; my @scalar = split(/\./, $addr);
print "The address is $scalar[0].$scalar[1].$scalar[2].$scalar[3]\n";There are many advantages to using an array instead of multiple scalars, a simple one being that this could also be expressed more simply as:
print "The address is ",join('.',@scalar),"\n";There are few differences between $scalar[1] and $scalar_2 otherwise.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re^3: Split an array and store contents into a scalar up till a certain character
by FireBird34 (Pilgrim) on Oct 21, 2002 at 02:08 UTC |