Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Oh my, PERL Data

by ichinyo (Novice)
on Aug 30, 2016 at 18:03 UTC ( [id://1170809]=perlquestion: print w/replies, xml ) Need Help??

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

I like the way PERL looks, though I am watching video, as boring as anything. I have a guide book, makes things look easier.

Here is a question, how would a data field work. In BASIC there is read, then that does a data function. like.

Read N$, A,B,C print n$,A,B,C data Bob Jones, 23,45,67 end Run Bob Jones 23 45 67.

How could PERL be used like spread sheet?

Thanks

Replies are listed 'Best First'.
Re: Oh my, PERL Data
by talexb (Chancellor) on Aug 30, 2016 at 19:27 UTC

    Here's some code that does roughly what you want:

    #!perl use strict; use warnings; { while ( <DATA> ) { chomp; my ( $n_string, $a_num, $b_num, $c_num ) = split(/,/); print "$n_string: " . join(', ', $a_num, $b_num, $c_num) . "\n"; } } __DATA__ Bob Jones,23,45,67 Bill Hicks,56,43,29
    This produces the following output:
    Bob Jones: 23, 45, 67 Bill Hicks: 56, 43, 29

    When you save stuff from a spreadsheet, one of the possible output formats is a CSV, like the two lines of data shown above.

    Alex / talexb / Toronto

    Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Re: Oh my, PERL Data
by Your Mother (Archbishop) on Aug 30, 2016 at 19:23 UTC

    We would love to help and Perl is a perfect choice for CSV and spreadsheet style data. Your question, as it stands, it a bit hard to understand. Could you elaborate? Files? Data in the script? Explain what you're thinking and wanting to do as if to a non-programmer. Everything, step by step.

Re: Oh my, PERL Data
by kcott (Archbishop) on Aug 31, 2016 at 05:48 UTC
Re: Oh my, PERL Data
by NetWallah (Canon) on Aug 30, 2016 at 19:49 UTC
    You could use the perl built-in debugger, to do simple stuff:
    >perl -d -E "" Loading DB routines from perl5db.pl version 1.33 Editor support available. Enter h or `h h' for help, or `perldoc perldebug' for more help. Debugged program terminated. Use q to quit or R to restart, use o inhibit_exit to avoid stopping after program termination, h q, h R or h o to get additional info. DB<4> chomp (($n,$a,$b,$c)=<>) Bob Jones 23 45 67 ^Z DB<5> print join(",",$n,$a,$b,$c) Bob Jones,23,45,67 DB<6> print $a+$b-$c 1

            "Software interprets lawyers as damage, and routes around them" - Larry Wall

Re: Oh my, PERL Data
by InfiniteSilence (Curate) on Aug 31, 2016 at 18:03 UTC

    ...data field...data function..How could PERL be used like spread sheet...

    Correct me if I'm wrong but this question asks three separate questions: 1) How can Perl be used like a data field (on a spreadsheet) 2) how can it behave like a Basic program and 3) how can it behave like the embedded formula tools inside of a spreadsheet.

    Perl is a language that you can use to build software tools but is not a tool like a spreadsheet. A data field on a spreadsheet represents a collection of objects that fire events that parse your input, maintain state, and offer you a nice and pretty visual representation to interact with. You can build a spreadsheet with Perl but not the other way around (easily). This covers the spreadsheet-related questions.

    That leaves how Perl can be like the BASIC language. Well, they are two different languages with different syntax, rules, and purposes. BASIC was designed to teach people programming. The 'B' in BASIC stands for 'Beginner.' It was never meant to be your 'do all be all.' Instead it was designed to introduce you to this stuff of computing and then send you out into the wild. Perl started out with a different set of intentions and thus the syntax and constructs of the language look a lot different.

    Programming, like anything, takes time to learn. The excitement comes from mastering techniques, solving problems, and (in the case of Perl) watching people suffer and struggle with their computers trying to do things you can literally whip up in minutes.

    Celebrate Intellectual Diversity

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1170809]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-19 21:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found