Can someone tell me what this is doing? I know it is reading records from a table and puts them in a hash. How do I print out, let's say, the first 5 columns of data (assuming columns are named col1, col2, ...)?
perldoc DBI
will tell you ;-)
But to be of little more help,
it's been quite a while since I last have written Perl code that used the DBI.
Thus it's likely I forgotten most of DBI.
But if I remember correctly,
the fetched hash'es keys are the field names of the table items
that you prepared in your select statement.
Since NAME_lc is passed you can safely reference the keys all lower case.
Hint, in Oracle's sqlplus you could issue a desc on the table you select
to see the field names.
Once the result set is fetched in your hashref it's very easy to refer to the fields
thanks to Perl's arrow operator.
Since I don't know you table's fields I use field_N here.
e.g.
But you could also reference them collectively by a hash slice.
e.g.
But admittedly, this looks rather ugly,
and referencing like this gave Perl the reputation of line noise and obfuscation.
I was looking through some code online and came accross this...
ls *.txt | grep text1 | cat file1 – file2 | `echo wc –l`
I know what "ls|grep text1" does and I know a word count gets echoed but beyond that I am confused. Please use layman terms as much as possible as I am a newbie. (8 Replies)
I am completely new to perl programming. My father is helping me learn said programming language. However, I am stuck on one of the assignments he has given me, and I can't find very much help with it via google, either because I have a tiny attention span, or because I can be very very dense.
... (4 Replies)
Hi all,
I am sure this is very simple but I cant quite get it.
I am trying to search textfile1.txt for a string then take the results of the search and append the result to textfile3.txt
So far I have used
$ find file1.txt -exec grep "string i am looking for" '{}' \; -print
this... (2 Replies)
Hi there
apologies for the really basic question but if i have a variable called $string that I want to run a regex against and output to another variable ...how do i do it, I know that if i wanted to alter the current $string variable i would do
$string=~ s/old/new/g;
but i kind of want... (2 Replies)
I have the following question in perl, I have come up with couple of solutions,Perl gurus please help me find the best answer to my question?
You have a PERL database named DataEntryData, and you need to separate out the various values from the DB entry $item, delimited by the ^ sumbol. There... (2 Replies)
Hi,
I am new to programming and also to perl..But i know 'perl' can come to my rescue, But I am stuck at many places and need help..any small help is much appreciated... below is the description of what i intend to acheive with my script.
I have a files named in this format... (13 Replies)
Hello everyone,
I am having to do a lot of perl scripting these days and I am learning a lot.
I have this problem
I want to move files from a folder and all its sub folders to one parent folder, they are all .gz files..
there is folder1\folder2\*.gz
and there are about 50 folders... (1 Reply)
Hello everyone,
Just started UNIX today! In our school we use solaris. I just want to know how do I setup Solaris 10 not the GUI one, the one where you have to type the commands like ECHO, ls, pwd, etc... I have windows xp and I also have vmware.
I hope I am not missing anything! :p (4 Replies)
sorry if im not asking inthe right spot but, how do you turn the beeping off every time you hit a key onthe keyboard. I tried the click -n but it told me it didnt recognize click
any help would be greatly appreciated ( the beeping is not going over well in the surrounding cubicles)
thank you... (4 Replies)
Hello,
I have text file while looks this
test1
test2
test3
test4
test5
test6
and if I want to parse it and make new file which would like this
test1 test2
test3 test4
test5 test6
How can I do this in korn shell script
Thanks (9 Replies)