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
In reply to Re^3: To Separate alphanumeric
by Utilitarian
in thread To Separate alphanumeric
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |