All,
I was playing with my code and after re-reading perdoc perlre, I still do not understand the items in yellow and their need.
items in yellow???
here is my code.
open(F,"$ARGV[0]") || die "dick face: $!\n";
$i=0;
print "-w '";
#print $i;
while (<F>) {
chomp($_); if ($i > 0) {
print " or ";
} $i++; print "barcode=\"$_\" ";
}
print "\'\n";
I will start from the bottom up:
Why do I need or what is the significance of print "\ ' \n"; I really do not need the first \ !
You're correct. The backslash is not needed to escape single quotes within double quotes.
At line print barcode it seems that do need the \ "$_\" "; as when I take the \'s away I get these errors which I am not understanding:
Double quotes must be quoted within double quotes. Otherwise, perl will think the string has ended. In the above example it would be translated as:
print "barcode=" $_ " ";
And as the error below says, if this is your intention, their should be an operator before and after the $_ in order for it to be a valid instruction.
If you want to use the double quotes in a string without the esapes, you can use a differnet quote character for your string:
print qq{barcode="$_" };
Read the section "Quote and Quote-like operators" in `perldoc perlop`
Scalar found where operator expected at parse_for_ejects.pl line 11, near ""barcode="$_"
(Missing operator before $_?)
String found where operator expected at parse_for_ejects.pl line 11, near "$_" ""
(Missing operator before " "?)
syntax error at parse_for_ejects.pl line 11, near ""barcode="$_"
parse_for_ejects.pl had compilation errors.
Randy.
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>