For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > January 2007 > I need to fetch the data from the fixed columns









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author I need to fetch the data from the fixed columns
Subra

2007-01-24, 4:04 am

I have lines like the one below.

PSCNThread 186092 ?D PSCN -> NasPdu: *** 00000000H [0ECF6442H]:
08120000 211A517C 027076CD 40433D24 ....!.Q|.pv.@C=$

I have to extract the numbers 08120000 211A517C 027076CD 40433D24
from the line. Every line will have the numbers at the same column. So
I need to fetch the data from the fixed columns. Please let me know how
to do it in perl.

Best Regards,
Subramanya M

jeevs

2007-01-24, 8:02 am



On Jan 24, 10:58 am, "Subra" <mailursu...@gmail.com> wrote:
> I have lines like the one below.
>
> PSCNThread 186092 ?D PSCN -> NasPdu: *** 00000000H [0ECF6442H]:
> 08120000 211A517C 027076CD 40433D24 ....!.Q|.pv.@C=$
>
> I have to extract the numbers 08120000 211A517C 027076CD 40433D24
> from the line. Every line will have the numbers at the same column. So
> I need to fetch the data from the fixed columns. Please let me know how
> to do it in perl.
>
> Best Regards,
> Subramanya


have you tried it.....

1)Try using regular expressions if you can.
2) Try to split the line into the specific colums and use the array
indexes to get the specific values...


The 2nd option seems to be less professional tho. :)

Purl Gurl

2007-01-24, 8:02 am

Subra wrote:

> PSCNThread 186092 ?D PSCN -> NasPdu: *** 00000000H [0ECF6442H]: 08120000 211A517C 027076CD 40433D24 ....!.Q|.pv.@C=$


> I have to extract the numbers 08120000 211A517C 027076CD 40433D24



$sub_string = substr ($string, rindex ($string, ":") + 2, 35);

Purl Gurl

nobull67@gmail.com

2007-01-24, 7:00 pm

On Jan 24, 1:01 pm, Purl Gurl <purlg...@purlgurl.net> wrote:

> $sub_string = substr ($string, rindex ($string, ":") + 2, 35);


Since the subject of this thread is fetching data from _fixed_ columns
it would be better off without the rindex().

The OP has told us that the sought data will always start at the same
position.

The OP has _not_ told us that there could never be another colon later
in the record.

The last bit of the record looks like the ASCII interpretation of
binary data so (assuming uniformly distributed values) the Gurl's
solution would mis-parse approximately a 6% of the data.

usenet@DavidFilmer.com

2007-01-24, 7:00 pm

On Jan 24, 10:20 am, "nobul...@gmail.com" <nobul...@gmail.com> wrote:
> the Gurl's solution would mis-parse approximately a 6% of the data.


must... resist... temptation... to... make... sarcastic... wisecrack...


--
David Filmer (http://DavidFilmer.com)

Purl Gurl

2007-01-24, 9:58 pm



nobull67@gmail.com wrote:
> Purl Gurl wrote:


[color=darkred]
> Since the subject of this thread is fetching data from _fixed_ columns
> it would be better off without the rindex().


Is yours a statement of known fact or a statement of personal opinion?


> The OP has told us that the sought data will always start at the same
> position.


> The OP has _not_ told us that there could never be another colon later
> in the record.


Nor did the author state there could be another colon. The author
provided very little information leaving readers guessing. My code
example addresses precisely what the author provided, nothing more,
nothing less.

Rather silly of you to expect a full blown fault free program based
on so little information.

> The last bit of the record looks like the ASCII interpretation of
> binary data so (assuming uniformly distributed values) the Gurl's
> solution would mis-parse approximately a 6% of the data.


Is yours a statement of known fact or simply a personal agenda?

Personal agenda is not a viable programming methodology.

Purl Gurl

Lost Sheep Of the Porn

2007-01-24, 9:58 pm


Purl Gurl wrote:
> nobull67@gmail.com wrote:
>
>
>
> Is yours a statement of known fact or a statement of personal opinion?
>
>
>
>
> Nor did the author state there could be another colon. The author
> provided very little information leaving readers guessing. My code
> example addresses precisely what the author provided, nothing more,
> nothing less.
>
> Rather silly of you to expect a full blown fault free program based
> on so little information.
>
>
> Is yours a statement of known fact or simply a personal agenda?
>
> Personal agenda is not a viable programming methodology.
>
> Purl Gurl


6% is fairly obvious. Take note.
Let y=f(x) be the position function

f=ma (Newtons second law)
f=-kx (Hooke's law)

ma=-kx
ma+kx=0

We now acceleration is the second derivative of the position function.
Therefore
y''(x)+(k/m)y(x) =0 {x| x >0}

Let y=e^rx

r^2e^rx +(k/m) e^rx = 0
r^2 + (k/m) = 0
r = sqrt(-k/m)

when we plug this expression back into y=e^rx, the expression expands
to the Euler Identity. Obviously this solution forms the basis to a
Vector Space. Thus your solution will mis-parse the data approximately
6% of the time.

Purl Gurl

2007-01-24, 9:58 pm

Lost Sheep Of the Porn wrote:

> Purl Gurl wrote:
[color=darkred]

[color=darkred]
> Let y=f(x) be the position function
> f=ma (Newtons second law)
> f=-kx (Hooke's law)
> ma=-kx
> ma+kx=0
> We now acceleration is the second derivative of the position function.
> Therefore
> y''(x)+(k/m)y(x) =0 {x| x >0}
> Let y=e^rx
> r^2e^rx +(k/m) e^rx = 0
> r^2 + (k/m) = 0
> r = sqrt(-k/m)


> when we plug this expression back into y=e^rx, the expression expands
> to the Euler Identity. Obviously this solution forms the basis to a
> Vector Space. Thus your solution will mis-parse the data approximately
> 6% of the time.


Ha! Ha! Funny! Nice to read a bit of humor around here.

However, most know Murphy's Law overrules all laws, both
natural and unnatural.

Purl Gurl




Purl Gurl

2007-01-24, 9:58 pm

Purl Gurl wrote:
[color=darkred]
> nobull67@gmail.com wrote:
[color=darkred]
[color=darkred]

Original context for readers,

BEGIN

I have lines like the one below.

PSCNThread 186092 ?D PSCN -> NasPdu: *** 00000000H [0ECF6442H]:
08120000 211A517C 027076CD 40433D24 ....!.Q|.pv.@C=$

I have to extract the numbers 08120000 211A517C 027076CD 40433D24
from the line. Every line will have the numbers at the same column. So
I need to fetch the data from the fixed columns. Please let me know how
to do it in perl.

END

(assuming his data is a single line whacked by word wrapping)

What is the exact number of columns?
What is the character width of each column?
Where does each column end?
What are the delimiters between columns?
Are these fixed width columns?
Does his data of interest span columns?
Will his data of interest always be the same length?
Will his data exhibit other characters?
Will his data exhibit empty columns?
Will empty columns consist of spaces?

None can write code which addresses those questions.
Only code which can be written is code which addresses
the precise data example displayed and no other data.

My example code addresses his example data, precisely,
nothing more, nothing less.

Nobull, you are full of bull!

This is consequences of attempting to troll me, as you
and David Filmer are attempting. Both of you are well
known, long historical trolls of the Perl Community.

Purl Gurl

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com