Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Building up a string from a text file

by linuxer (Deacon)
on May 22, 2009 at 14:36 UTC ( #765688=note: print w/ replies, xml ) Need Help??


in reply to Building up a string from a text file

Hi, what about this solution:

#! /usr/bin/perl -l use strict; use warnings; my @parameters; my @operators; my @value1; my @value2; while ( my $line = <DATA> ) { my ( $param, $operator, $value1, $value2 ) = split /\s/, $line; push @parameters, $param; push @operators, $operator; push @value1, $value1; push @value2, defined $value2 ? $value2 : ''; # if $operator is not 'between' $value2 shouldn't be defined, so j +ust add empty string # maybe you want to check $operator additionally } # fill your variables instead of printing print join '|', @parameters; print join '|', @operators; print join '|', @value1; print join '|', @value2; __DATA__ ID1 > 66 ID2 < 7 ID3 between 6 10


Comment on Re: Building up a string from a text file
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://765688]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2015-07-30 01:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls