Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: %p issue on perl script

by bv (Friar)
on Sep 10, 2009 at 17:15 UTC ( [id://794632]=note: print w/replies, xml ) Need Help??


in reply to %p issue on perl script

Your problem is that you are interpolating variables into a format string for printf. You should pick one way or the other: print or printf.

More detailed explanation: %p in a printf or sprintf format string prints a pointer, which is coming out as a string of hex digits. Your statement, using printf, should be more like this:

printf " %s At (%d, %d) the row is %s and the column is %s for EUR & N +AM \n", $feedback_value, $row, $col, $my_row,$my_column;

or using print, like this:

print " $feedback_value At ($row, $col) the row is $my_row and the column is $my_column for EUR & NAM \n";

Your second issue is related to Unicode encodings, but I'm afraid I can't help more (ASCII-only for me, so far). If you reformat your question using <code></code> tags, or repost the second question on its own, you'll be more likely to get a helpful response.

print pack("A25",pack("V*",map{1919242272+$_}(34481450,-49737472,6228,0,-285028276,6979,-1380265972)))

Replies are listed 'Best First'.
Use of Unicode Encodings in perl
by Sathish (Initiate) on Sep 11, 2009 at 04:25 UTC

    Many thanks for you help.

    The %p issue got solved after i changed "printf" to "print" as you suggested.

    Below is the code snippet for my second issue (Unicode encodings)

    #!/usr/bin/perl -w use strict; use warnings; use Data::Dumper; use Getopt::Long; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLE::Warn = 3; # die on errors. +.. my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); # open Excel file my $Book = $Excel->Workbooks->Open("C:/Audio/perl/Project/Voice.xls"); my $Sheet = $Book->Worksheets('Feedback') || die( "No such worksheet gendata" ); my $row_start_tmp = 0; my $row_end_tmp = 0; my $eur_column = 0; my $gom_column = 0; my $nam_column = 0; my $column_add = 0; my @gm_out; my $my_row = 0; my $my_column = 0; my $feedback_value = 0; my $eur_gom_total = 0; my $gom_nam_total = 0; my $eur_nam_total = 0; my $feedback_ID = 0; #--------------------------------------------------------------------- +---------- # TR file name my $fl = "FB_CHECK.csv"; $row_start_tmp = 2; $row_end_tmp = 695; $eur_column = 26; $gom_column = 120; my $i = 0; open(FH, ">$fl") or die $!; # open the excel sheet for write $feedback_ID = 3; foreach my $row ($row_start_tmp..$row_end_tmp) { foreach my $col ($eur_column..$eur_column) { # skip empty cells # next unless defined $Sheet->Cells($row,$column_value)-> +{'Value'}; $my_row = ($Sheet->Cells($row,$eur_column)->{'Value'}); $my_row =~ s/(^\s+|\s+$)//g; $my_column = ($Sheet->Cells($row,$gom_column)->{'Value'}); $my_column =~ s/(^\s+|\s+$)//g; $feedback_value = ($Sheet->Cells($row,$feedback_ID)->{'Val +ue'}); $feedback_value =~ s/(^\s+|\s+$)//g; if ($my_row ne $my_column) { printf " %s At ($row, $col) the row is %s and the colu +mn is %s for EUR & NAM \n", $feedback_value, $my_row,$my_column; push @gm_out, [ $feedback_value, $my_row,$my_column,0 +]; } } } printf FH "\n"; $eur_gom_total = @gm_out; printf FH "The Total mismatches between EUR & GOM is $eur_gom_tota +l \n"; printf FH "\n"; printf FH "Below results for EUR & GOM \n"; printf FH "\n"; printf FH "Row value, EUR English Display Data, GOM English Displa +y Data, NAM English Display Data \n"; my $out_size = @gm_out; for($i=0;$i<$out_size;$i++) { print FH "$gm_out[$i][0],$gm_out[$i][1],$gm_out[$i][2],$gm_out +[$i][3] \n"; }

    In the Voice.xls sheet on a particular cell the content is some italy language (other than english) (i cant print since it prints like ???????. ???????)

    When i try to print that cell contents to a CSV file it prints as ???????. ???????

    I am not aware of unicode strings please help me on this

    I got some idea about the issue. This is not because of unicode encodings because the string which causing the problem is not a unicode it is an mandarin language string

    How do i print a mandarin language string in a spread sheet? Please help me on this........

      Glad I could help. As I said before, you should post this second problem in a new question. This one won't get the attention you need to answer it. I can only point you to the documentation: perlunicode

      print pack("A25",pack("V*",map{1919242272+$_}(34481450,-49737472,6228,0,-285028276,6979,-1380265972)))

        Hi,

        Some how i solved this issue. I set the font to that spread sheet as below and now i dont have any issue in printing non-english strings.

        $Sheet2->Range("A100:Z100")->Font->{FontStyle}="Arial Unicode MS";

        But again i stuck up with another issue on printing the string into a spreadsheet.

        I am printing a string into an spreadsheet with an row input from an for loop. Below is the code snippet of an for loop for better understanding.

        for($i=0;$i<$out_size;$i++) { $Sheet2 -> Range("A$i") -> {'Value'} = $gm_out[$i][0]; $Sheet2 -> Range("B$i") -> {'Value'} = $gm_out[$i][1]; $Sheet2 -> Range("C$i") -> {'Value'} = $gm_out[$i][2]; $Sheet2 -> Range("D$i") -> {'Value'} = $gm_out[$i][3]; }

        Here the problem comes from an "Range". I am getting an error when i run this program an error pointing to "Range".

        Please suggest me an idea on how to input the "Range" with an variable size so that i can print an array $gm_out$ix into the variable ranges of ROW in the columns A, B, C & D.

        Please provide your help

Re^2: %p issue on perl script
by Sathish (Initiate) on Sep 16, 2009 at 16:46 UTC

    Hi,

    Some how i solved the second issue. I set the font to that spread sheet as below and now i dont have any issue in printing non-english strings.

    $Sheet2->Range("A100:Z100")->Font->{FontStyle}="Arial Unicode MS";

    But again i stuck up with another issue on printing the string into a spreadsheet.

    I am printing a string into an spreadsheet with an row input from an for loop. Below is the code snippet of an for loop for better understanding.

    for($i=0;$i<$out_size;$i++) { $Sheet2 -> Range("A$i") -> {'Value'} = $gm_out[$i][0]; $Sheet2 -> Range("B$i") -> {'Value'} = $gm_out[$i][1]; $Sheet2 -> Range("C$i") -> {'Value'} = $gm_out[$i][2]; $Sheet2 -> Range("D$i") -> {'Value'} = $gm_out[$i][3]; }

    Here the problem comes from an "Range". I am getting an error when i run this program an error pointing to "Range".

    Please suggest me an idea on how to input the "Range" with an variable size so that i can print an array $gm_out$ix into the variable ranges of ROW in the columns A, B, C & D.

    Please provide your help

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-16 18:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found