Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Batch to Perl translation (just 1 line, not the whole script)

by theneil (Novice)
on Aug 07, 2012 at 18:16 UTC ( #986050=perlquestion: print w/ replies, xml ) Need Help??
theneil has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I've searched everywhere and can't find an answer so I guess I need to ask it!

I'm calling a perl script from BMC Impact Explorer that's filtering each ticket to the right support group using a Bayesian (SPAM Filtering) approach. I use the get_external function which sends the ticket message to the perl script and expects the group as the result.

But I am having trouble returning the group in the proper format. I HAVE however created a dummy .bat file that returns the output in the correct format (using the format I found on the BMC Communities forum)

I am wondering if anyone can essentially translate my .bat file output to Perl output?

.bat file:

echo BAYES; >> %1 echo bayesClass=nameOfClassVariable; >> %1 echo END >> %1
I literally need to output those strings in the same way that it's done in the .bat file. Any ideas? Thanks!

Comment on Batch to Perl translation (just 1 line, not the whole script)
Download Code
Re: Batch to Perl translation (just 1 line, not the whole script)
by BrowserUk (Pope) on Aug 07, 2012 at 18:25 UTC

    On the face of it, a simple:

    print <<'stuff'; BAYES; bayesClass=nameOfClassVariable; END stuff

    Or even just:print "BAYES;\nbayesClass=nameOfClassVariable;\nEND\n"; ought to send the same text to STDOUT.

    The missing information is what is in %1 in the .bat script?


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

Re: Batch to Perl translation (just 1 line, not the whole script)
by aitap (Deacon) on Aug 07, 2012 at 20:50 UTC
    open my $fh, ">>", $ARGV[0] || die "$0: $ARGV[0]: $!\n"; # open the file specified in the first argument in append mode print $fh q{BAYES; bayesClass=nameOfClassVariable; END}; # write the text; close $fh; # close the file;
    See open, print, Quote and Quote like Operators, close for more information.
    Sorry if my advice was wrong.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://986050]
Approved by BrowserUk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2014-11-27 22:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (188 votes), past polls