Your issue is unclear to me - please read
I know what I mean. Why don't you?. Specifically, providing input, expected output and a full script that replicates your problem would be helpful.
Given that you are apparently not using
strict, I suspect the reason you are having trouble with named variables is typographic in nature. See
Use strict warnings and diagnostics or die.
foreach $keye (@key_en)
{
$linb=`cat /home/vikash/pro_1/en_1000 | grep --regexp '$keye'`;
print "$linb\n";
}
and
foreach (@key_en)
{
$linb=`cat /home/vikash/pro_1/en_1000 | grep --regexp '$_'`;
print "$linb\n";
}
are functionally equivalent. Why do you think it doesn't work?
1 more thing i had to ask is how many $_ variables can be used simultaneously and how.
There can only be one variable of any name at a given location in a script, so there is only one variable named $_.
As a side note, there is no reason to pipe cat into grep. You can save characters and possible confusion by writing that as
$linb=`grep --regexp '$keye' /home/vikash/pro_1/en_1000`;
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.