Dear Monks

I need to print directly to a printer connected to my PC.
Somewhere on your site I found information that led me to believe
this is done by a command of
open(PRN, ">LPT1") - if the printer is connected to LPT1 of the PC being used
or open(PRN, '>\\printserver\printershare') if the printer is
connected to a printer on the network.
Therefore I wrote the follwing code

use strict "vars"; use Win32; my ($port_name, $port_name_use, $res_file_open, $page_item); print "\ngive port name for Zebra printer (eg LPT1/USB001) "; $port_name = <STDIN>; chomp($port_name); $port_name_use = '>' . $port_name; print "port name to be used is $port_name_use\n"; $res_file_open = open(PRN, $port_name_use) ; if($res_file_open == 1) { $page_item = 0; while ($page_item < 3) { $page_item +=1; print PRN "page $page_item\n"; print PRN "line 2\n"; print PRN "line 3\f"; } close(PRN); } else { print "could not open zebra printer on port $port_name\n"; }


Sadly this just treats the name in the open as a file therefore nothing is sent to
the printer.

What changes do I have to do so that I can print directly to the printer connected to my PC?

In reply to Printing directly to a printer by merrymonk

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.