#1
|
|||
|
|||
sample perl with visualbuild script
hi,
I am having hard time using perl script with VisualBuild (assinng a scalar value to a macro etc).. I couldnt go beyond compilation at times... I was wondering if you have a sample perl script which you could share? Thanks |
#2
|
|||
|
|||
Attached.
|
#3
|
|||
|
|||
Quote:
|
#4
|
|||
|
|||
Sorry about that. See new attachment.
Results here when building with VBP 7.1 and ActivePerl 5.10.0.1005 on Win XP SP3: 6/25/2009 1:28:51 PM: --------------------Starting Build: 'Perl.bld'-------------------- 6/25/2009 1:28:51 PM: Building project step 1 - Project steps... 6/25/2009 1:28:51 PM: Building project step 2 - Create macro... 6/25/2009 1:28:51 PM: Building project step 3 - Show macro... 123 |
#5
|
|||
|
|||
Quote:
e.g $Application->Macros(vbldMacroTemporary)->Add("ABC", '$abc'); if I use single quotes around "ABC" i get an compilation error or if i dont use quotes then VisualBuild assing my scalar as a VALUE to my macro? |
#6
|
|||
|
|||
I'm not sure exactly what you mean by "if i dont use quotes then VisualBuild assing my scalar as a VALUE to my macro".
This does what I would expect (assigns the value '123' to the ABC temporary macro): $abc = 123; $Application->Macros(vbldMacroTemporary)->Add("ABC", $abc); You can't assign a Perl variable reference to a VBP macro, but you can store the underlying variable's value. |
#7
|
|||
|
|||
Quote:
$abc = $_; $Application->Macros(vbldMacroTemporary)->Add("ABC", $abc); ??? Thanks for your help. |
#8
|
|||
|
|||
That works ok in my tests:
Code:
@myNames = ('Larry', 'Curly', 'Moe'); foreach (@myNames) { $abc = $_; $Application->Macros(vbldMacroTemporary)->Add($abc, $abc); } |
#9
|
|||
|
|||
Quote:
open (MYFILE, 'c:\perl\bin\Build.log') || die("cant open file"); while (<MYFILE>) { chomp; if (($_ =~ /[1-9]\serrors/) || ($_=~ /[1-9](\d+)\serrors/)) { $abc = $_; $Application->Macros(vbldMacroTemporary)->Add($ABC ,$abc); } } close (MYFILE); |
#10
|
|||
|
|||
VBP doesn't allow spaces in a macro name (and Perl is a case-sensitive language, so $ABC would not be defined in the sample code). The attached sample uses the first character of the match for the macro name. You would need to tweak as necessary to assign an appropriate macro name.
|
|
|