- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: understanding the perl one line
Operating System - OpenVMS
1752754
Members
5380
Online
108789
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-03-2006 02:38 PM
тАО10-03-2006 02:38 PM
understanding the perl one line
Hi,
in this forum in the thread http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1065208
i have seen the solution for the question as
#perl -ne '($h,$n)=split; if ($old=$o{$h}) {print "$h : ", $n - $old, "\n"} else {$o{$h}=$n}' file1.txt file2.txt
in the if statement iam seeing that the value $o{$h}is being assigned to $old,in the if condition there is no condition as i was expecting i.e like == ,>,< but the result is coming out as expected can please someone help in understanding this
Thanks in advance
in this forum in the thread http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1065208
i have seen the solution for the question as
#perl -ne '($h,$n)=split; if ($old=$o{$h}) {print "$h : ", $n - $old, "\n"} else {$o{$h}=$n}' file1.txt file2.txt
in the if statement iam seeing that the value $o{$h}is being assigned to $old,in the if condition there is no condition as i was expecting i.e like == ,>,< but the result is coming out as expected can please someone help in understanding this
Thanks in advance
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-03-2006 03:23 PM
тАО10-03-2006 03:23 PM
Re: understanding the perl one line
if ($variable)
Is true if $variable is defined and not 0.
if ($variable=$other)
First assigns $other to $variable and test the result for true or false.
So it really tests $other, while at the same time picking up its value.
It could be written as:
if ($other) {
$variable = $other;
...
}
hth,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-03-2006 03:45 PM
тАО10-03-2006 03:45 PM
Re: understanding the perl one line
($h,$n)=split is going to split the file i.e host1-80 10
host2-80 15 according the space .
how is %o association being formed in this case i believe that is what you are refering by saying the $o{$h} . After the condition is true you are trying to substract $n[0]..that would be 10 or 15 and you are refering the $o{$h} is the same value if the association is being formed from spilt.
Thanks for your help in advance
host2-80 15 according the space .
how is %o association being formed in this case i believe that is what you are refering by saying the $o{$h} . After the condition is true you are trying to substract $n[0]..that would be 10 or 15 and you are refering the $o{$h} is the same value if the association is being formed from spilt.
Thanks for your help in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-04-2006 02:00 AM
тАО10-04-2006 02:00 AM
Re: understanding the perl one line
thanks for explaining the how the if works .but that raised one more question i will post in a new thread
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP