Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

parsing values from table ..using Perl

by get2vijay (Novice)
on Apr 02, 2015 at 04:28 UTC ( #1122228=perlquestion: print w/replies, xml ) Need Help??

get2vijay has asked for the wisdom of the Perl Monks concerning the following question:

Hello experts, I need your help in parsing the values from a table...using a perl script. This is how the table looks:
need to read the first complete row Please help as it's a part of my urgent office assignment. sorry if i missed to mention anything. Thanks in advance Vijay

Replies are listed 'Best First'.
Re: parsing values from table ..using Perl
by 2teez (Vicar) on Apr 02, 2015 at 06:09 UTC

    Hi get2vijay,

    Welcome to the PerlMonks Monastery.
    You are really surrounded by a lot of wonderful monks who are willing to help you, but you have to also show some effort on your part.
    To start with read How do I post a question effectively?
    Apply what you have read and you will see what a wonderful world you are in.
    Welcome once more!

    If you tell me, I'll forget.
    If you show me, I'll remember.
    if you involve me, I'll understand.
    --- Author unknown to me
Re: parsing values from table ..using Perl
by marinersk (Priest) on Apr 02, 2015 at 12:05 UTC


    Welcome to the Monastery

    All the other admonishments apply. That said, thank you for reformatting your message; it really was hard to visualize the data without that effort.

    There is at least one further challenge here: the term "table" can mean a lot of different things, and how you would go about solving this problem varies greatly depending on what form the table takes and how it is generated, not to mention how it will be made available to your Perl script.

    I understand you feel a sense of urgency about this task, but we really can't help unless we understand the problem -- and while your original post does, at least, show some data and gives a fair sense of the big picture, it does not have enough to just haul off and start writing code.

    For example, if it is a table in a database, we'd perhaps look at ways to use one of the DBImodules; on the other hand, if it's in a spreadsheet, perhaps one of the Parse::Spreadsheetmodules. Raw rext file? Perhaps the use of splitor substr, depending on the specifics. The list goes on and on.

    We'd like to help, but we need more information -- as well as a sense that you are seeking help and not a free supplicant to do your job for you.

    I am interested to see where this thread goes, and I hope we can ultimately be of Service.

Re: parsing values from table ..using Perl
by ww (Archbishop) on Apr 02, 2015 at 11:11 UTC

    And if actually learning how to write your code is not your intent, hire a programmer.

    Maybe you can PAY someone to make your "urgent office assignment" hir emergency.

Re: parsing values from table ..using Perl
by Anonymous Monk on Apr 02, 2015 at 06:55 UTC
Re: parsing values from table ..using Perl
by stevieb (Canon) on Apr 02, 2015 at 14:28 UTC

    Just read and print the first line?

    #!/usr/bin/perl use strict; use warnings; while (my $line = <DATA>){ next if $line =~ /Port/; print "$line\n"; last; } __DATA__ RNC RIP-IP Switch /Router Port GURRNC1 GURSW1 1/6 GURRNC1 GURSW2 2/6 GURRNC2 GURSW3 3/6 GURRNC2 GURSW4 4/6


    $ ./ GURRNC1 GURSW1 1/6

    Now simply replace <DATA> with a real file handle. Hopefully this will be enough to get you on the right track. Your question is awfly vague though so it's difficult to know exactly what you need.


      Thanks a ton..stevieb !! sorry couldn't write my requirement properly as ia m very much new to this amazing perl language. i have a case if the above given data is just in a plane .txt file,then what would be the solution ? please help... thanks again...
Re: parsing values from table ..using Perl
by kroach (Pilgrim) on Apr 02, 2015 at 06:46 UTC
    What do you mean by a complete row? Also, please surround your data with <code> tags.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1122228]
Approved by jellisii2
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2021-05-15 18:53 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (150 votes). Check out past polls.