Hi sowmya,

You need to close your code tags, this should have looked mangled in the preview.
You must have received errors when you tried to run this program, you should learn to read them ;) You could use diagnostics if the error messages seem cryptic
I've modified your program to work and improved the coding style, however you need to work through errors to learn, so these are the changes required.

General issues
Use the three argument form of open, it prevents errors
You should also include $! (check it out in perlvar) in your die message as it's good to know what went wrong
Indirect filehandles are better practice and will allow you to pass them around your program when you're writing programs with sub-routines
eg. open(my $input_file, '<', 'input') or die "cannot open input: $!";
You must declare your variables when you use strict (see my)

Logic issues
What is the point of @b, you should process the elements of @a as you go
You process the loop without doing anything and then examine only the first character of the array @b
The way to make a regex test is =~ , eqis for string equality
eg. if($a =~ /[A-Za-z]/) {
You may want to print a place holder to mark the fact that a character was printed to the other file.
To get the line of a file you are processing, take a look at $. in perlvar you could use this to generate a useful error message in your else block

Try to make the changes above and next time close your code tags, look at the preview and copy in the errors you are seeing when describing your problem

Happy learning, Utilitarian

print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."

In reply to Re^3: To Separate alphanumeric by Utilitarian
in thread To Separate alphanumeric by Anonymous Monk

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.