Hi guys, ive been working on a script for the last day or so, and ive hit a stumbling block. The script is finished, but i keep getting a syntax error that i just can't find. i havent been perling long so i sorry if this is a bit of a newbie question. This is the code so far
#! /usr/bin/perl -w use diagnostics; use strict; use Getopt::Std; use Crypt::CBC; getopt( 'kio', \%opts ); $cipher = Crypt::CBC->new( -key => '$opts{"k"}', -cipher => 'Skipjack', ); $INFILE = %opts{"i"}; $OUTFILE = %opts{"o"}; open < INFILE or die "can't open $INFILE: $!"; open > OUTFILE or die "can't open $OUTFILE: $!"; read INFILE, $plaintext; $chipertext = $cipher->encrypt($plaintext); print OUTFILE, $chipertext; close OUTFILE; close INFILE; return (0);

Whenever I run the code I get the following error message:
Global symbol "%opts" requires explicit package name at skipjack.pl.td +y line 8. Global symbol "$cipher" requires explicit package name at skipjack.pl. +tdy line 10. Global symbol "$INFILE" requires explicit package name at skipjack.pl. +tdy line 14. Global symbol "%opts" requires explicit package name at skipjack.pl.td +y line 14.syntax error at skipjack.pl.tdy line 14, near "%opts{" Execution of skipjack.pl.tdy aborted due to compilation errors (#1) (F) You've said "use strict vars", which indicates that all variab +les must either be lexically scoped (using "my"), declared beforehand +using "our", or explicitly qualified to say which package the global var +iable is in (using "::"). Uncaught exception from user code: Global symbol "%opts" requires explicit package name at skipja +ck.pl.tdy line 8. Global symbol "$cipher" requires explicit package name at skipjack.pl. +tdy line 10. Global symbol "$INFILE" requires explicit package name at skipjack.pl. +tdy line 14. Global symbol "%opts" requires explicit package name at skipjack.pl.td +y line 14.syntax error at skipjack.pl.tdy line 14, near "%opts{" Execution of skipjack.pl.tdy aborted due to compilation errors.

Could anyone help me out with the error and if they see anything that needs improving or changing, I would greatly appricate it.
Thanks

UPDATE:
After following your instructions, i now have a working script. Thankyou


Morning!

In reply to Skipjack Encryption by shadowoflinux

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.