HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: PERL Problem update var and file
Operating System - HP-UX
1827769
Members
2760
Online
109969
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
Forums
Discussions
Discussions
Discussions
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
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
06-13-2002 11:00 AM
06-13-2002 11:00 AM
Hi All,
I have a problem with the script in the attachment.
The var $var_caps apears to be like this $var_caps=' 23.4'
and when the script compare at the if cmd with the $MAX_CAPS it didn??t update this var.
Can anybody helps ?
Regards,
Bassoi
If you never try, never will work
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2002 11:10 AM
06-13-2002 11:10 AM
Re: PERL Problem update var and file
Try changing the "gt" to ">". "gt" is for string compare, ">" for numeric.
-- Rod Hills
-- Rod Hills
There be dragons...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2002 05:18 AM
06-14-2002 05:18 AM
Solution
Hi Ricardo,
I hope you don't mind if I suggest some "improvements" to your script.
But first, regarding your question.
Perl doesn't distinguish data types as compiled languages do.
(well, that's partly true, Perl distinguishes between scalars such as ordinary variables and references, lists such as arrays and hashes, and type globs)
Whether something is a string or a numeric depends only on the context.
Thus I wouldn't enforce a string context, as you did by quoting but simply leave the assigned value to $var_caps and $ MAX_CAPS untouched
(you correctly chomped $var_caps already)
So your condition should, as already mentioned, indstaed read:
if ($var_caps < $MAX_CAPS) {
# do something
}
A word of caution to your openings of files.
Always test the success of an open() statement!
The Perl idiom to do this is simple:
open HANDLE, "<$file" or die "open of $file failed: $!\n";
Always switch on warnings!
pre Perl 5.6 in the shebang:
#!/usr/bin/perl -w
from Perl 5.6 onwards use the warnings Pragma:
use warnings;
Always use the strict pragma, even if the compiler may reject your code at first:
use strict;
Then, I wouldn't use shell escapes such excessively as you did by the backtick operation.
Perl has *far more* parsing power than the cuts you have invoked through the shell can offer.
Also use as many Perl built-in functions (and later modules) as possible.
Perl has a localtime() function, so you can avoid the date invocation.
Also have a look at the POD
perldoc perl
perldoc perlsyn
perldoc perlfunc
perldoc perlop
perldoc perlopentut
perldoc perlstyle
I hope you don't mind if I suggest some "improvements" to your script.
But first, regarding your question.
Perl doesn't distinguish data types as compiled languages do.
(well, that's partly true, Perl distinguishes between scalars such as ordinary variables and references, lists such as arrays and hashes, and type globs)
Whether something is a string or a numeric depends only on the context.
Thus I wouldn't enforce a string context, as you did by quoting but simply leave the assigned value to $var_caps and $ MAX_CAPS untouched
(you correctly chomped $var_caps already)
So your condition should, as already mentioned, indstaed read:
if ($var_caps < $MAX_CAPS) {
# do something
}
A word of caution to your openings of files.
Always test the success of an open() statement!
The Perl idiom to do this is simple:
open HANDLE, "<$file" or die "open of $file failed: $!\n";
Always switch on warnings!
pre Perl 5.6 in the shebang:
#!/usr/bin/perl -w
from Perl 5.6 onwards use the warnings Pragma:
use warnings;
Always use the strict pragma, even if the compiler may reject your code at first:
use strict;
Then, I wouldn't use shell escapes such excessively as you did by the backtick operation.
Perl has *far more* parsing power than the cuts you have invoked through the shell can offer.
Also use as many Perl built-in functions (and later modules) as possible.
Perl has a localtime() function, so you can avoid the date invocation.
Also have a look at the POD
perldoc perl
perldoc perlsyn
perldoc perlfunc
perldoc perlop
perldoc perlopentut
perldoc perlstyle
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
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP