perl function enquery


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl function enquery
# 8  
Old 04-08-2012
could this help you ?
Code:
#!/usr/bin/perl
use strict;
use Spreadsheet::WriteExcel;
my $sheet;
my ($row,$col)=(0,0);
my @newflds;
my $j=0;
my $source_csv = shift @ARGV  or die "invocation: $0 <Source CSV> <destination file>";
my $destname = shift @ARGV or die "invocation: $0 <Source CSV> <destination file>";
my $dest_book  = Spreadsheet::WriteExcel->new("$destname") or die "Could not create a new Excel file in $destname: $!";
my $dest_sheet = $dest_book->addworksheet($sheet);
open (FH,"<","$source_csv") or die "Can not open csv file \n $! \n";
while (<FH>) {
        chomp;
        @newflds=split(/,/);
        foreach (@newflds) {
                $dest_sheet->write($row,$col++,$_);
        }
        $row++;
        $col=0;
}
$dest_book->close();
close(FH);
print "done!\n";

invocation:
Code:
 script <Source CSV> <destination file>"

# 9  
Old 04-08-2012
HI pravin27

Since I am newbie in perl, I find that the code above includes
the package
use Spreadsheet::WriteExcel;
As far as I know, the package should be downloaded. How can I download this package for Solaris 10 unix and then apply it to unix box?
# 10  
Old 04-08-2012
Spreadsheet::WriteExcel - search.cpan.org

Also, the same website contains details on how to install packages.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl qr function usage

I'm not sure why I'm having so much trouble with this. I think I'm really not understanding how this works. I'm trying to store a regex in a variable for use later in a script. Can someone tell me why this doesn't match??? #!/usr/bin/perl # # # $ticket=1212; my $rx_ticket =... (1 Reply)
Discussion started by: timj123
1 Replies

2. Shell Programming and Scripting

Converting shell to Perl I run into shell built in function trap and need alternative in Perl

I am working on converting shell to Perl script. In shell we have built in function trap Do you know alternative in Perl or actually we don't need it? Thanks for contribution (3 Replies)
Discussion started by: digioleg54
3 Replies

3. Shell Programming and Scripting

Perl split function

my @d =split('\|', $_); west|ACH|3|Y|LuV|N||N|| Qt|UWST|57|Y|LSV|Y|Bng|N|KT| It Returns d as 8 for First Line, and 9 as for Second Line . I want to Process Both the Files, How to Handle It. (3 Replies)
Discussion started by: vishwakar
3 Replies

4. Shell Programming and Scripting

How to use parameter with perl function?

am a beginer of shell Unix, plesase tell me how to get parameter with $perl in loop $ perl -lne '$/="DOCEND";print $_."DOCEND" if /$ACC/' file_input > output i can't get parameter in loop with perl fucntion like this pass paramerter to $ACC not accept in this script $ACC = paramerter to... (4 Replies)
Discussion started by: krai
4 Replies

5. Shell Programming and Scripting

PERL split function

Hi... I have a question regarding the split function in PERL. I have a very huge csv file (more than 80 million records). I need to extract a particular position(eg : 50th position) of each line from the csv file. I tried using split function. But I realized split takes a very long time. Also... (1 Reply)
Discussion started by: castle
1 Replies

6. Homework & Coursework Questions

PERL split function

Hi... I have a question regarding the split function in PERL. I have a very huge csv file (more than 80 million records). I need to extract a particular position(eg : 50th position) of each line from the csv file. I tried using split function. But I realized split takes a very long time. Also... (1 Reply)
Discussion started by: castle
1 Replies

7. UNIX for Dummies Questions & Answers

perl bless function

hi i am not getting what exactly bless function do in perl explanation in perldoc is not very clear i tried to search on google but i am getting confused or rather not getting at all. can anybody explain in short what it does in following example as well as in general ? sub new { my... (1 Reply)
Discussion started by: zedex
1 Replies

8. Shell Programming and Scripting

sort function in perl

Hi, here is my perl script.This script creates an array and is sorting it using the in-built sort function in perl. #!/usr/local/bin/perl my number=6; my @num_arr=(1,2,3,4,5); my @array=(23,"$number","Hello",2.345,@num_arr); #printing the array print... (2 Replies)
Discussion started by: DILEEP410
2 Replies

9. Shell Programming and Scripting

perl split function

$mystring = "name:blk:house::"; print "$mystring\n"; @s_format = split(/:/, $mystring); for ($i=0; $i <= $#s_format; $i++) { print "index is $i,field is $s_format"; print "\n"; } $size = $#s_format + 1; print "total size of array is $size\n"; i am expecting my size to be 5, why is it... (5 Replies)
Discussion started by: new2ss
5 Replies

10. Programming

Memory Deallocation Enquery

If i "new" a object of class type A and A uses some data structure like array, set, map etc. When i delete this object, need I delete/clear the array/set/map in the destrucator of A, or system will deallocate the memory automatically?? Thanks in advance! Em, do bear me if the question is... (3 Replies)
Discussion started by: zzz_zzz
3 Replies
Login or Register to Ask a Question