- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Perl problem: logical operators.
Operating System - HP-UX
1819794
Members
3431
Online
109607
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
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
тАО11-24-2004 08:42 PM
тАО11-24-2004 08:42 PM
Perl problem: logical operators.
From a file, I read a list of files or directories.
I must check if in my current subtree , it exists. The individual match
( if it is a file or it is a directory) is successful but it associate
both of them with the OR operator ,it fails.
I mean : if ( -e $file ) -> success
if ( -d $file ) -> suc ess
if ( -e $file ) || ( -d $file ) -> fails
if ( ( -e $file) || ( -d $file ) ) -> fails
Can you help me with the correct synxtax?
Thanks,
Raul
- Tags:
- Perl
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-24-2004 09:05 PM
тАО11-24-2004 09:05 PM
Re: Perl problem: logical operators.
if (-e $file || -d _) {
action
}
Enjoy, Have FUN! H.Merijn [ introducing the often forgotten shortcut and speedup _ for last used file in stat op ]
action
}
Enjoy, Have FUN! H.Merijn [ introducing the often forgotten shortcut and speedup _ for last used file in stat op ]
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-24-2004 09:21 PM
тАО11-24-2004 09:21 PM
Re: Perl problem: logical operators.
In fact, if either ( -e $file ) or ( -d $file ) is TRUE, the total outcome shut be TRUE.
What if you use "or" instead of "||", i.e.
if ( -e $file ) or ( -d $file )
Also, does it help if you put some brackets around the condition, i.e.
if ( ( -e $file ) || ( -d $file ) )
What if you use "or" instead of "||", i.e.
if ( -e $file ) or ( -d $file )
Also, does it help if you put some brackets around the condition, i.e.
if ( ( -e $file ) || ( -d $file ) )
http://www.tresselt.eu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-24-2004 09:27 PM
тАО11-24-2004 09:27 PM
Re: Perl problem: logical operators.
procura's suggestion is the preferred way,
because usage of the thingy '_' in the second test avoids another stat() syscall.
The difference between || and 'or' is that the latter has lesser precedence which can make a decisive difference but not in this case, so there should be no difference
For details please consult
perldoc -f -x
perldoc perlop
because usage of the thingy '_' in the second test avoids another stat() syscall.
The difference between || and 'or' is that the latter has lesser precedence which can make a decisive difference but not in this case, so there should be no difference
For details please consult
perldoc -f -x
perldoc perlop
Madness, thy name is system administration
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.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP