brad_nov has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I have script like below:
When I am executing I am getting output as follows:#!/usr/local/bin/perl use strict; use warnings; while (<DATA>) { ( my ($s_id) = /^\d+\|(\d+?)\|/ ) ; if ( $s_id == 1 ){ s/^(.*\|)*.*ABC\.pi=([\d.]+|[\w.]+)*.*ABC\.id=(\d+|[\w.]+).*$/$1$2 +|$3/s; print "$1$2|$3\n"; } } __DATA__ 123|1|456464|645646|4546|654~abc~dhghga~ABC.pi=112.33.44.55.66~ABC.id= +789137136770 123|1|456464|645646|4546|654~abc~dhghga~ABC.pi=112.33.44.55.67~ABC.id= +789134713670 123|1|456464|645646|4546|654~abc~dhghga~ABC.pi=112.33.44.55.68~ABC.id= +789137213670 123|1|456464|645646|4546|654~abc~dhghga~ABC.pi=112.33.44.55.69~ABC.id= +78913713670 123|1|456464|645646|4546|654~abc~dhghga~12.33.44.55.70~3713670 123|1|456464|645646|4546|654~abc~dhghga~ABC.pi=112.33.44.55.70~ABC.id= +78913713670 123|1|456464|645646|4546|654~abc~dhghga~ABC.pi=112.33.44.55.70~ABC.id= +78913713670 123|1|456464|645646|4546|654~abc~dhghga~ABC.pi=112.33.44.55.70~ABC.id= +789137135670 123|1|456464|645646|4546|654~abc~dhghga~ABC.pi=112.33.44.55.70~ABC.id= +789137153670 123|1|456464|645646|4546|654~abc~dhghga~12.33.44.55.70~3713670 123|1|456464|645646|4546|654~abc~dhghga~121322~456466874~8796896 123|2|456464|645646|4546|654~abc~dhghga~121322~456466874~6788708 123|2|456464|645646|4546|654~abc~dhghga~121322~456466874~6806
I am looking to get rid off the error. How can I do it? ANd I want to write the exceptions to new file.123|1|456464|645646|4546|112.33.44.55.66|789137136770 123|1|456464|645646|4546|112.33.44.55.67|789134713670 123|1|456464|645646|4546|112.33.44.55.68|789137213670 123|1|456464|645646|4546|112.33.44.55.69|78913713670 Use of uninitialized value $2 in concatenation (.) or string at split_ +test.pl line 14, <DATA> line 5. Use of uninitialized value $3 in concatenation (.) or string at split_ +test.pl line 14, <DATA> line 5. 1| 123|1|456464|645646|4546|112.33.44.55.70|78913713670 123|1|456464|645646|4546|112.33.44.55.70|78913713670 123|1|456464|645646|4546|112.33.44.55.70|789137135670 123|1|456464|645646|4546|112.33.44.55.70|789137153670
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Print only if pattern matches
by Kenosis (Priest) on Jan 24, 2013 at 06:37 UTC | |
Re: Print only if pattern matches
by vinoth.ree (Monsignor) on Jan 24, 2013 at 06:42 UTC | |
Re: Print only if pattern matches
by 2teez (Vicar) on Jan 24, 2013 at 06:52 UTC | |
Re: Print only if pattern matches
by Athanasius (Archbishop) on Jan 24, 2013 at 07:00 UTC | |
Re: Print only if pattern matches
by LanX (Saint) on Jan 24, 2013 at 07:04 UTC |
Back to
Seekers of Perl Wisdom