in reply to Re^3: How to fetch the value of unix command result
in thread How to fetch the value of unix command result
I also tired the below one....
my $r = `gunzip -c $file|cut -f3 -d'|'|sort|uniq -c`; my $c1 = substr( $r, 16,-2); my $c2 = substr( $, 9,-9);This gives me the output as...
<code> $c1 = 4 $c1 = 6 <code>I have a question to experts, was this correct method
In a word, no. It might (and I emphasize, might) work for your current input. What happens, though, when:
Maybe you'll be ridiculously lucky and not ever encounter any of the above scenarios. But I guarantee, if you continue writing code that takes inherently variable width text input and parses it with fixed offsets, it will blow up horribly at some point.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: How to fetch the value of unix command result
by rajsai28 (Novice) on Jun 30, 2013 at 13:07 UTC | |
by poj (Abbot) on Jun 30, 2013 at 13:42 UTC | |
by rajsai28 (Novice) on Jun 30, 2013 at 14:14 UTC | |
by poj (Abbot) on Jun 30, 2013 at 14:31 UTC | |
by rajsai28 (Novice) on Jun 30, 2013 at 14:43 UTC | |
|