I think, this is what it would look like. I noticed that you seem to be printing to a file. In perl, if you write to a file, you need a file handle, which is usually a variable. And you need to pass that variable to the function OR it could be a global variable... So, that needs to be modified... In BASIC, you print to a file by writing PRINT #1, data$ but if you translate that to Perl, it looks like this: print $filehandle $data

AND PLEASE NOTE THAT IN PERL, THERE IS NO COMMA BETWEEN FILEHANDLE AND DATA!

Otherwise, I think, this is a strict translation of the above VB code to Perl:

#!/usr/bin/perl -w use strict; use warnings; my $testname = 'a'; Target_write_wide(1); sub Targets { return 'abc'; } sub TargetValues { return 'abc def int hun son'; } sub Target_write_wide { @_ or return; my $depth = shift; defined $depth or return; length($depth) or return; # Debug: print "Target write depth = $depth", 'Targetvalues', TargetVa +lues($depth); my $Celldata; my $Current_split = 0; my $Num_combinations = 0; my @TargetValueslist = split(' ', TargetValues($depth)); foreach (@TargetValueslist) { length($_) or next; $Celldata = "add_wide_split(\"" . Targets($depth) . "\",$_);\n"; print $Celldata; } if ($depth > 0) { Target_write_wide($depth - 1); } else { $Current_split++; $Num_combinations++; $Celldata = "run_all_wide_split(\"$testname" . "_combination:$Curr +ent_split\");"; print $Celldata; } }

Edit: I also made the assumption that Targets() and TargetValues() are functions. If those happen to be global arrays, then you need to change the parentheses to square brackets and put a dollar sign in front of the array name. But that should be easy...


In reply to Re: tO CONVERT vb SCRIPT TO PERL by harangzsolt33
in thread tO CONVERT vb SCRIPT TO PERL by geniuskid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.