[28770] in Perl-Users-Digest
Perl-Users Digest, Issue: 14 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 11 11:05:53 2007
Date: Thu, 11 Jan 2007 08:05:04 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 11 Jan 2007 Volume: 11 Number: 14
Today's topics:
Re: Call Perl in Verilog or SV? <agnusin@gmail.com>
Re: CPAN Write Excel <xxx@xxx.xxx>
Re: CPAN Write Excel <tadmc@augustmail.com>
Re: CPAN Write Excel <cgrady357@gmail.com>
Re: Devel::Cover How to get a more indepth report <Peter@PSDT.com>
Re: Devel::Cover How to get a more indepth report <bpatton@ti.com>
Re: Indirect function call via Name <ro.naldfi.scher@gmail.com>
Re: Parsing an XML file and adding another tag, if the <pannbu79@gmail.com>
Re: Skip non english character values <mritty@gmail.com>
Re: Skip non english character values aaron80v@yahoo.com.au
Re: Skip non english character values <mritty@gmail.com>
Re: Video::Capture undefined value <zentara@highstream.net>
Re: Working with array references <cmic@caramail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 11 Jan 2007 07:23:12 -0800
From: "Alex" <agnusin@gmail.com>
Subject: Re: Call Perl in Verilog or SV?
Message-Id: <1168528991.117722.179800@o58g2000hsb.googlegroups.com>
You can also communicate with external program using $system, $fdislpay
and $readmemh tasks.
I have such example interconnecting Verilog with simple TCL/TK gui:
http://www.tclforeda.org/tclforeda/sim_gui.htm
Regards,
-Alex
Shenli wrote:
> Hi Ajeetha,
>
> Thanks a lot for the help :-)
> I have tried your suggestion and it work OK.
>
> But when I try to pass a string to $system(), the ncvlog said "Using
> String without index is not supported in the given context."
>
> The code I write like below,
> //---------------------
> string perl_cmd_str = "";
>
> $sformat(perl_cmd_str,"perl ./perl/test_opt_file.pl -a %0d -b 4",
> data_a);
> $display("string is %s\n", perl_cmd_str);
>
> $system (perl_cmd_str);
> //---------------------
>
> Any suggestion on how to input a string to $system()?
>
> Best regards,
> Shenli
>
>
> Ajeetha (www.noveldv.com) wrote:
> > One of the simplest (and of limited capability as well) is to use:
> >
> > $system ("perl my_script.pl");
> >
> > Ajeetha, CVC
> > www.noveldv.com
> > Shenli wrote:
> > > Hi all,
> > >
> > > Sometimes, I want to do some sophisticated text operation in Verilog or
> > > SystemVerilog testbench. And we all know that Verilog and SV is like
> > > C/C++ and not very good at text manipulation.
> > >
> > > Is there any method to call Perl routine in Verilog or SV? Pass
> > > argument to Perl routine can be better. BTW, I use Cadence NC tools.
> > >
> > > Best regards,
> > > Davy
------------------------------
Date: Thu, 11 Jan 2007 11:15:16 +0100
From: "Gordana" <xxx@xxx.xxx>
Subject: Re: CPAN Write Excel
Message-Id: <eo4v80$9oq$1@ss408.t-com.hr>
OK.
I use the Win32::OLE module, and I can create, and save file.
How to open existing Excel .XLS file?
Thanks.
--
"Bob Walton" <see.sig@rochester.rr.com> wrote in message
news:45a5b795$0$9569$4c368faf@roadrunner.com...
> Gallon wrote:
> > I have MS Excel spreadsheets with tons of formulas and data already in
> > them, so I was very excited about discovering
> > "Spreadsheet::WriteExcel". This would allow me to write data directly
> > from my Perl scripts, rather than cutting and pasting. The only
> > drawback, except for me being an idiot or a luddite, is the module only
> > seems to have a "new" constructor! I need an "open" constructor, or
> > whatever. Does anyone know how I might do this???
> ...
> > Gregg Allen
> >
>
> So far as I know, Spreadsheet::WriteExcel does exactly what it says: it
> writes Excel files. It doesn't read them or update them.
> Spreadsheet::ParseExcel will read Excel files. Between the two, you
> might be able to accomplish an update. I recommend, though, that you
> check out the Win32::OLE module. It is more suitable for updating Excel
> spreadsheets. There are Excel examples in the module documentation that
> will get you started.
> --
> Bob Walton
> Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Thu, 11 Jan 2007 06:23:22 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: CPAN Write Excel
Message-Id: <slrneqcb1q.iv0.tadmc@tadmc30.august.net>
Bob Walton <see.sig@rochester.rr.com> wrote:
> Gallon wrote:
>> I have MS Excel spreadsheets with tons of formulas and data already in
>> them, so I was very excited about discovering
>> "Spreadsheet::WriteExcel". This would allow me to write data directly
>> from my Perl scripts, rather than cutting and pasting. The only
>> drawback, except for me being an idiot or a luddite, is the module only
>> seems to have a "new" constructor! I need an "open" constructor, or
>> whatever. Does anyone know how I might do this???
The very first paragraph of the documentation for the module you
are using says:
This module cannot be used to write to an existing Excel file.
>
> So far as I know, Spreadsheet::WriteExcel does exactly what it says: it
> writes Excel files. It doesn't read them or update them.
> Spreadsheet::ParseExcel will read Excel files. Between the two, you
> might be able to accomplish an update. I recommend, though, that you
> check out the Win32::OLE module. It is more suitable for updating Excel
> spreadsheets. There are Excel examples in the module documentation that
> will get you started.
I needed to do this in a CGI program last week, but the web server
was not Redmondware, so no OLE.
Jakarta POI to the rescue!
http://jakarta.apache.org/poi/
Recalling enough Java to get it working made me spit, but it allowed
me to serve Excel files derived from an Excel "template" file.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 11 Jan 2007 07:08:23 -0800
From: "Craig" <cgrady357@gmail.com>
Subject: Re: CPAN Write Excel
Message-Id: <1168528103.475066.100650@o58g2000hsb.googlegroups.com>
Gordana wrote:
> OK.
> I use the Win32::OLE module, and I can create, and save file.
> How to open existing Excel .XLS file?
>
> Thanks.
>
Here is a simple example:
#!/C:/Perl/bin/perl.exe
use strict;
use warnings;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
use Win32::OLE::Variant;
$Win32::OLE::Warn = 3;
my $excel = Win32::OLE->GetActiveObject('Excel.Application') ||
Win32::OLE->new('Excel.Application', 'Quit');
my $book = $excel->Workbooks->Open("C:\\TMP\\test1.xls");
my $sheet = $book->Worksheets(1);
my $aref = $sheet->Range("A1:D5")->{Value};
my $sheet2 = $book->Worksheets(2);
$sheet2->Range("A6:D10")->{Value} = $aref;
------------------------------
Date: Thu, 11 Jan 2007 14:29:16 GMT
From: Peter Scott <Peter@PSDT.com>
Subject: Re: Devel::Cover How to get a more indepth report
Message-Id: <pan.2007.01.11.14.29.15.404252@PSDT.com>
On Wed, 10 Jan 2007 18:19:40 -0600, Billy Patton wrote:
> I can run and get a report telling me a percentage of lines covered and
> times spent in each module.
>
> How do I get a line by line reference to each file.
> I would like to know which lines did not get touched.
>
> I used a coverage long ago that put ** infromt of each line used and
> empty when not used. This is what I'm afer.
Have you run the (default) HTML report? In cover_db/ you get
coverage.html, containing a table with modules in the first column, each
of which is a link to a page showing a table containing every line
preceded by cells reporting its coverage. The first cell is the number of
times the line was called and it's red if the number is zero.
--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/
------------------------------
Date: Thu, 11 Jan 2007 08:54:56 -0600
From: Billy Patton <bpatton@ti.com>
To: Peter Scott <Peter@PSDT.com>
Subject: Re: Devel::Cover How to get a more indepth report
Message-Id: <45A64FC0.9010608@ti.com>
Peter Scott wrote:
> On Wed, 10 Jan 2007 18:19:40 -0600, Billy Patton wrote:
>
>> I can run and get a report telling me a percentage of lines covered and
>> times spent in each module.
>>
>> How do I get a line by line reference to each file.
>> I would like to know which lines did not get touched.
>>
>> I used a coverage long ago that put ** infromt of each line used and
>> empty when not used. This is what I'm afer.
>
> Have you run the (default) HTML report? In cover_db/ you get
> coverage.html, containing a table with modules in the first column, each
> of which is a link to a page showing a table containing every line
> preceded by cells reporting its coverage. The first cell is the number of
> times the line was called and it's red if the number is zero.
>
Yea I found the html after running cover.
What I don't know is exactly what the column abbreviations for t he
column names.
------------------------------
Date: 11 Jan 2007 01:36:18 -0800
From: "Ronny" <ro.naldfi.scher@gmail.com>
Subject: Re: Indirect function call via Name
Message-Id: <1168508178.524770.245740@p59g2000hsd.googlegroups.com>
anno4000@radom.zrz.tu-berlin.de schrieb:
> > our $func="bar";
> > # Of course the following would not work
> > &$func(@_);
>
> What makes you think it doesn't work? Switch off strict 'refs' and
> it does.
Thanks a lot!! I should have known this already!
Ronald
------------------------------
Date: 11 Jan 2007 07:00:51 -0800
From: "P" <pannbu79@gmail.com>
Subject: Re: Parsing an XML file and adding another tag, if the tag is not available / the value is null
Message-Id: <1168527651.606033.294230@i39g2000hsf.googlegroups.com>
Thanks Guys, for taking your time out to help me out.
I still have an issue, I can't use XML::Twig, it is not provided with
the version of the UNIX we use here, can you give me some other way
similar to this, with other older packages.
Also this needs to be done for all the XML files in a folder & sub
folders.
Just let me know your thoughts.
Thank you,
Regards,
Annbu P
Tad McClellan wrote:
> mirod <xmltwig@gmail.com> wrote:
> > On Jan 10, 10:18 am, "P" <pannb...@gmail.com> wrote:
> >
> >> I have a scenario in which we are adding a new tag to the existing
> >> structure of the XML files, some of the new files created might have
> >> the newly added tag with value / just an empty tag, all I need is to
> >> add the new tag if it is not present with the value available in
> >> another tag, or if it is empty have to give the value from the other
> >> tag to this.
> >
> > Using XML::Twig here is how you would do it:
>
>
> [ snip robust code that any sensible person would prefer. ]
>
>
> Or if the OP is willing to live with a fragile dirty hack, then:
>
> $xml =~ s{(.*<fname>.*?</fname>\n)(.*\n)}
> { $a = $1 . $2;
> ($b=$1) =~ s/fname/nickname/g;
> $a . $b;
> }gie;
>
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
------------------------------
Date: 11 Jan 2007 06:16:19 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Skip non english character values
Message-Id: <1168524979.724481.70720@77g2000hsv.googlegroups.com>
aaron...@yahoo.com.au wrote:
> Occasionally the excel file I am dealing with contains non english
> characters in certain fields (delimited by comma) such as Chinese,
> Japanese and Korean. How do I check and skip those so that my perl
> script won't break?
If your perl script "breaks" when encountering non-English characters,
your script is broken and should be fixed. How exactly does it
"break"? Please post a short-but-complete script that demonstrates
what you're doing wrong.
How you "skip" over the non-english characters depends entirely on how
you are processing the data. Line by line, character by character,
field by field, other? Again, please post a short-but-complete script
that demonstrates what you're doing.
Have you read the Posting Guidelines that are posted here twice a week?
Paul Lalli
------------------------------
Date: 11 Jan 2007 06:29:47 -0800
From: aaron80v@yahoo.com.au
Subject: Re: Skip non english character values
Message-Id: <1168525787.704088.205400@k58g2000hse.googlegroups.com>
Hi,
Thanks. All I am trying to do is to read the content of the 4th
delimiter value and remove \n from it. I don't see why it should break
for non-English.
while (<STUFF>) {
next if /^(\s)*$/;
@str1 = split(/,/);
if ($str1[3] =~ /\n/) {
$i++;
$_=~ s/\n/ /eg;
#$_=~ s/\s+/ /g;
}
foreach $name (@str1) {
chomp($name);
}
print OUT "$_";
}
What posting guide? Isn't most groups have about the same posting
guide?
Aaron
------------------------------
Date: 11 Jan 2007 06:52:48 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Skip non english character values
Message-Id: <1168527168.583627.153550@p59g2000hsd.googlegroups.com>
aaron...@yahoo.com.au wrote:
> Thanks. All I am trying to do is to read the content of the 4th
> delimiter value and remove \n from it. I don't see why it should break
> for non-English.
You have still not said HOW it breaks. What does "break" even mean?
Does your program crash? Inifinite Loop? Incorrect output? No
output? WHAT HAPPENS?
This is now the second time I've asked this question. I should not
have to ask it at all. I will not ask it again.
> while (<STUFF>) {
>
> next if /^(\s)*$/;
What do you think the parentheses are doing in that statement?
> @str1 = split(/,/);
> if ($str1[3] =~ /\n/) {
You have a severe logic problem. You're reading a file line-by-line,
but are searching one of the internal fields for a newline. This can't
happen, unless there actually are only four fields in the file. And if
there are, you really just need to chomp() the line before hand.
> $i++;
> $_=~ s/\n/ /eg;
What do you think the e is doing in that statement?
> #$_=~ s/\s+/ /g;
> }
> foreach $name (@str1) {
> chomp($name);
> }
Again. Logic problem. Only the very last field can POSSIBLY have a
newline character, so it makes no sense of any kind to chomp each one.
> print OUT "$_";
What do you think the quotes are doing in that statement? Please read:
perldoc -q quoting
> }
>
> What posting guide?
Like I said, the Posting Guidelines that are posted here twice a week.
They have the words "Posting Guidelines" in their subject. They are
not difficult to find.
> Isn't most groups have about the same posting guide?
If you had read the Posting Guidelines for this group, you would have
been able to avoid SEVERAL things you've done in this posting that has
made people decide to skip over your post, and likely kill file you.
Those things include:
not use strict and warnings
using inconsident indentation
not posting sample input
not posting desired output
not posting actual output
not quoting the material you're replying to.
not posting a short-but-COMPLETE script
The posting guidelines are there to give you these tips, so that you
get the best chances of someone who knows what your problem might be
actually reading and responding to your post. Please do not reply
again until you read them.
Paul Lalli
------------------------------
Date: Thu, 11 Jan 2007 11:13:42 GMT
From: zentara <zentara@highstream.net>
Subject: Re: Video::Capture undefined value
Message-Id: <jm6cq216u12fsofcn159iv8fg9bvkq8kmu@4ax.com>
On 10 Jan 2007 03:46:59 -0800, josvanr@gmail.com wrote:
>Hello
>
>I'm trying to get to work the examples from themodule
>Video-Capture-V4l-0.901
>(debian package libvideo-capture-v4l-perl v 0.901-1)
>All the supplied examples seem to be suffering from the same
>problem:
>
>stumpernickel:/usr/share/doc/libvideo-capture-v4l-perl/examples# ./grab
>Device: name Logitech QuickCam Pro 4000, type capture, channels 1,
>audios 1, sizes 160x120-640x480
>Channel 0: name Webcam, tuners 0, flags, type camera, norm 0
>Picture Settings: brightness 32256, hue 65535, colour 40616, contrast
>64512, whiteness 49152, depth 24, palette 15
>Can't call method "mode" on an undefined value at ./grab line 103.
>
>Has anyone encountered (and /or solved) the same problem?
I have a TV capture card and the script works fine for me.
Line 103 defines the tuner (i.e. TV channel tuner), and I'm
probably right, in that your camera has no tuner.... it's just
a plain camera.
Try commenting out the lines referring to tuner.
zentara
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
------------------------------
Date: 11 Jan 2007 07:38:58 -0800
From: "cmic" <cmic@caramail.com>
Subject: Re: Working with array references
Message-Id: <1168529938.543239.85730@p59g2000hsd.googlegroups.com>
Frederik Vanderstraeten a =E9crit :
> Hi
>
> I'm new to Perl. I have a question about array references: what's the
I'm a bit new, too...8-)
.=2E.
> E.g., what is the easiest way to rewrite this:
>
> $arrayRef =3D $obj->get('myArray');
> @array =3D $@arrayRef;
> @array =3D (@array, 'newElement');
> $obj->set('myArray', \@array);
>
> As get returns a reference, I assume I could easily do all of this in
> one statement.
May be it is too late, but R.L.Schwartz has an article about "Show me
your references" that might help learning references .... It is in
SysAdmin magazine, January issue :
http://www.samag.com/documents/s=3D10108/sam0701h/0701h.htm
--
Michel Marcon aka cmic
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 14
*************************************