473,382 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

how to get the value of using condition check

I have a file
------------------------------------------------------------------
Port Speed Duplex Flow Ctrl Link Name
---- ----- -------- --TX-----RX-- ------ ------
1 10000 full no no down 1
2 10000 full no no down 2
3 10000 full no no down 3
4 10000 full no no down 4
5 10000 full no no down 5
6 10000 full no no down 6
7 10000 full no no down 7
8 10000 full no no down 8
9 10000 full no no down 9
10 10000 full no no down 10
11 10000 full no no down 11
12 10000 full no no down 12
13 10000 full no no down 13
14 10000 full no no down 14
15 10000 full no no down 15
16 10000 full no no down 16
17 1G/10G full no no down 17
18 1G/10G full no no down 18
19 1000 full no no up 19
20 10000 full no no down 20

and my script is
open FILE,"interfacelink.txt" or die "cannot open file : $!";
my ($line, $ind, $port, $speed, $link);
$ind=$line=~ /Link/;
while (<FILE>) {

$line = $_;
if ( $line =~ /\bLink\b/ ) {
print "port is ", $port, substr($line,1,2). ", ";
print "speed is ", $speed, substr($line,7,5). ", ";
print "link is ", $link, substr($line,42,4)."\n";

}

}

when I run the script I got the output
port is 19, speed is 1000, link is up

need urgent help :I dont know how to check the condition like if the line contain "Link" in the first line then check the port link is up or down and if it is up then get the same out as above
Aug 29 '12 #1
3 1787
RonB
589 Expert Mod 512MB
Is there a reason why you didn't respond to the answer given to you 9hrs ago on devshed?
Aug 29 '12 #2
Hi Ron I did not get any answere to repond
Aug 30 '12 #3
RonB
589 Expert Mod 512MB
You certainly did get an answer.

Here is the answer I gave you in that devshed posting.

The code you posted won't produce the results that you stated from the sample data you posted.

Based on you sample data, I'd loop over the lines skipping any that don't start with a number, then use the split function to breakup the line into their separate fields. If you use an array slice, you can extract just the 3 needed fields instead of all 7.
Did you not understand what I was suggesting?

If my suggestion does not solve your issue, then please provide more details on what you need to accomplish.
Aug 30 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: chrispragash | last post by:
Hello All, This may be a silly question to ask - but for some reason I am unable to get this to work! I have a server control that renders a Label and a linkbutton, and I have a Javascript...
4
by: deko | last post by:
Basic question about checking the value of Toggle/Check/Combo/OptionGroups.... Checking like this: If Me!chkCheckBox Then ... End If and like this:
2
by: Kevin Humphreys | last post by:
Hi There, Is it possible to retrieve a client side control value using server VB.NET? Thanks, Kevin.
1
by: sathyan8294 | last post by:
i am using dotnet 2003.i am doing my project in vb.net windows application.i have two form in my project.first form is datagrid .In second form label,textboxes and combobox are avilable to save the...
7
by: messagewalker | last post by:
Hi guys, I wanted to know how to set node value using xpath, for example <root> <name></name> </root> what I want is get the node 'name' and set its value to say 'bob', so it will be like...
2
by: blazzer | last post by:
Hi, I need help. I just wondering whether i can set the double value using random class..i even use if statement to set it..but nothing..i wanna set between 0.5 n 0.7 value.. double planetMass...
1
by: Limno | last post by:
Hi, Suggest me, how to get the value using Session in C#.net. if i enter the value in one webform, it must display in another webform while i open that 2nd webform. But i dont want to redirect...
3
Fary4u
by: Fary4u | last post by:
http://www.furyconcept.co.uk/db.jpg attach file contains database table, retrieving value using multiple array, no problem retrieving 1st values but when i'm trying to retrieving 2nd array value...
3
karthik baskar
by: karthik baskar | last post by:
I have a check box for which a user can check many values . I need to get the value of the check box in a variable in PHP to insert it into the database . Please someone help me ..
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.