On Thu, Apr 25, 2002 at 02:34:55PM +0200, [EMAIL PROTECTED] wrote:
> hi,
> 
> i have a data file test1.txt as follows:
> 
> 551356835||1|7684940|47534900|0
> ......
> 
>  my code should open test1.txt, read in the data, convert it an print it into 
> test2.txt :
> 
>       ($nodeid, $nameid, $type, $longitude, $latitude, $altitude) =
> split ("|", $line);

THAT ====^^^ is your problem.

    ---------- perldoc -f split ----------
    split /PATTERN/,EXPR,LIMIT
    split /PATTERN/,EXPR
    split /PATTERN/
    ...
    ---------- perldoc -f split ----------

See the '/' around PATTERN?  That means that we're dealing with a
regular expression, and '|' is a special char for regexps.  Your split
says "Split at NOTHING OR NOTHING", since that '|' basically means "OR".
Since NOTHING can't be matched you split after each character.

If you write it like "split /\|/, $line" it'll work.

More information can be found in

    perldoc perlrequick
    
or 

    perldoc perlretut
    
The section you're looking for starts with 'Matching this or that' in
both documents.

Take a look at 'perldoc -f quotemeta' if you're running into similar
problems when using more complex matching and generated search
expressions.

-- 
                       If we fail, we will lose the war.

Michael Lamertz                        |      +49 221 445420 / +49 171 6900 310
Nordstr. 49                            |                       [EMAIL PROTECTED]
50733 Cologne                          |                 http://www.lamertz.net
Germany                                |               http://www.perl-ronin.de 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to