Gary,

split uses the first argument as a regex, and the period is a
metacharacter, and needs to be backslashed. Take a look at this snippet,
which works:

$test = 'L.svc.I.039558';
($dealer, $system) = split /\./,$test;
print "$dealer\n$system\n";

Steven Spears



                                                                                       
                          
                    Gary Stainburn                                                     
                          
                    <gary.stainburn@ringw        To:     Perl Beginners 
<[EMAIL PROTECTED]>                     
                    ays.co.uk>                   cc:                                   
                          
                                                 Subject:     missing something 
obvious                          
                    04/25/01 10:26 AM                                                  
                          
                                                                                       
                          
                                                                                       
                          



I know this is gonna be a daft one, but can anyone explain why the
following code generates the output below.

print "argv=$ARGV[0]\n";
my($dealer,$system,$dtype,$ref)=split(".",$ARGV[0]);
print"dealer=${dealer}\nsystem=${system}\ndtype=${dtype}\nref=${ref}\n";

I've tried 1st without the braces, but it made no difference.
Here's the output

[docs@eddie docs]$ ./import L.svc.I.039558
argv=L.svc.I.039558
dealer=
system=
dtype=
ref=
[docs@eddie docs]$
--
Gary Stainburn

This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000





Reply via email to