Hi All
i am currently writing a script that reads a file into an array.
i am then doing a search from stdin for a string in the file.
my next task is as follows:
i would like to grab the line of text where the search string is stored and display it on the screen.
including multiple instances
============================================================
my code:
print "\nTo search for a MSISDN please enter the number below...\n";
$msisdn=<STDIN>;
chomp $msisdn;
print "searching...\n";
sleep 2;
print "searched OUTPUT file:\n";
$found=0;
foreach (@newarray)
{
print "$_";
if(/$msisdn/ig)
{
$found=1;
}
}
if($found==1)
{
print "MSISDN has been found\n";
}
else
{
print "MSISDN is not present in the output file\n";
============================================================
the file contains:
12:34:56 01420563694 1234 0 60 200 45 2970 1/30 2/0 s60k0t0a0m0c30
12:34:56 billy 01420563694 1234 0 300 200 45 2850 1/150 2/0
12:34:56 01420563694 1234 0 300 236 256 3425 1/300 2/0 s300k0t0a0m0c75
12:00:30 747568002 1234 0 30 330 279 1280 1/20 2/0 s30k0t0a0m0c20
============================================================
the example msisdn i am searching for is:
747568002 (4th line down)
============================================================
i want to grab the line:
12:00:30 747568002 1234 0 30 330 279 1280 1/20 2/0 s30k0t0a0m0c20
if anyone can help i will be very grateful
thanks
moonhead.
i am currently writing a script that reads a file into an array.
i am then doing a search from stdin for a string in the file.
my next task is as follows:
i would like to grab the line of text where the search string is stored and display it on the screen.
including multiple instances
============================================================
my code:
print "\nTo search for a MSISDN please enter the number below...\n";
$msisdn=<STDIN>;
chomp $msisdn;
print "searching...\n";
sleep 2;
print "searched OUTPUT file:\n";
$found=0;
foreach (@newarray)
{
print "$_";
if(/$msisdn/ig)
{
$found=1;
}
}
if($found==1)
{
print "MSISDN has been found\n";
}
else
{
print "MSISDN is not present in the output file\n";
============================================================
the file contains:
12:34:56 01420563694 1234 0 60 200 45 2970 1/30 2/0 s60k0t0a0m0c30
12:34:56 billy 01420563694 1234 0 300 200 45 2850 1/150 2/0
12:34:56 01420563694 1234 0 300 236 256 3425 1/300 2/0 s300k0t0a0m0c75
12:00:30 747568002 1234 0 30 330 279 1280 1/20 2/0 s30k0t0a0m0c20
============================================================
the example msisdn i am searching for is:
747568002 (4th line down)
============================================================
i want to grab the line:
12:00:30 747568002 1234 0 30 330 279 1280 1/20 2/0 s30k0t0a0m0c20
if anyone can help i will be very grateful
thanks
moonhead.