Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
What I am doing wrong?
If have a flat file that is | delimited
% cat flatfile.pipe COL1 | someother data|122343221|blahbalhbalh
other times I get flat files that are : delimited
% cat flatfile.colon COL1 : someother data:122343221:blahbalhbalh
so ...
I wrote a perl script that does something like this ...
% cat splitit.pl #!/sur/bin/perl use Getopt::Std; getopts( 'c:' ); while(<>) { chomp; (@columns) = split /$opt_c/; } foreach $col (@columns) { print "[$col]\n"; }
so ... when I do ...
% ./splitit.pl -c':' < flatfile.colons
... it get output ...
[COL1 ] [ someother data] [122343221] [blahbalhbalh]
... which is good. But when I do ...
% ./splitit.pl -c'|' < flatfile.pipes
... I get output ...
[C] [O] [L] [1] [ ] [ ] [ ] [ ] [|] [ ] [s]
... you get the idea I hope because I sure don't! :)
Thanks
Edit ar0n -- fixed formatting
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: split $c
by japhy (Canon) on Dec 07, 2001 at 04:38 UTC | |
by Anonymous Monk on Dec 08, 2001 at 02:30 UTC | |
|
Re: split $c
by belg4mit (Prior) on Dec 07, 2001 at 04:40 UTC | |
|
Re: split $c
by Masem (Monsignor) on Dec 07, 2001 at 04:40 UTC | |
|
Re: split $c
by hopes (Friar) on Dec 07, 2001 at 04:44 UTC | |
|
(tye)Re: split $c
by tye (Sage) on Dec 07, 2001 at 19:56 UTC | |
|
Re: split $c
by dru145 (Friar) on Dec 07, 2001 at 21:49 UTC |