- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- perl script not working the way I expect
Categories
Company
Local Language
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
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
Community
Resources
Forums
Blogs
- 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
08-22-2002 08:37 AM
08-22-2002 08:37 AM
"MEMNAME"!"NAME"!"VARNUM"!"LABEL"!"ROLE"!"ORIGIN"!"COMMENTS"!"CRFPAGE"!"CODES"
"COMMENT"!"AGE"!"16"!"AGE"!" "!" "!" "!" "
"COMMENT"!"CNTRY"!"20"!"DECODE, CTRY"!" "!" "!" "!" "
Here is the output 3 lines:
_"MEMNAME"_"NAME"_"VARNUM"_"LABEL"_"ROLE"_"ORIGIN"_"COMMENTS"_"CRFPAGE"_"CODES"_
_"COMMENT"_"AGE"_"16"_"AGE"_" "_" "_"integer ((open treatment start date - birth date) / 365.25)."_" "__
_"COMMENT"_"CNTRY"_"20"_"DECODE, CTRY"_" "_" "_" "_" "__
Here is the perl program:
#!/usr/contrib/bin/perl
open(VARLIST, "/tmp/varlist.csv")
|| die " can not open comman comments file\n";
while(
($MEMNAME,$NAME,$VARNUM,$LABEL,$ROLE,$ORIGIN,$COMMENTS,$CRFPAGE,$CODES) = split(/!/,$_);
printf "_%s_%s_%s_%s_%s_%s_%s_%s_%s_\n",$MEMNAME,$NAME,$VARNUM,$LABEL,$ROLE,$ORIGIN,$COMMENTS,$CRFPAGE,$CODES;
};
close VARLIST;
Why do I get two underscores on the lines after the first. I would expect only 1?
Puzzled. New PERL user. TIA
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2002 08:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2002 08:54 AM
08-22-2002 08:54 AM
Re: perl script not working the way I expect
chop;
Each line has an end-of-line character after it has been read in.
By the way- /usr/contrib/bin/perl is version 4 of perl, you should get version 5 from the software porting and archive.
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2002 09:37 AM
08-22-2002 09:37 AM
Re: perl script not working the way I expect
I feel embarrassed that the answer was simple.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2002 10:37 AM
08-22-2002 10:37 AM
Re: perl script not working the way I expect
That's why another pair of eyes is good.
One fellow labored all night to debug something. When I saw him the next morning, I pointed out that he had a capital oh (O) instead of a zero (0). He yelled a lot.
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2002 01:29 PM
08-22-2002 01:29 PM
Re: perl script not working the way I expect
learn to use chomp instead
chop cuts off the last character. whatever it is.
chomp is safe, it cuts of the value of $/, but only if present
chop;chop; is destructive
chomp;chomp; is not
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2002 01:32 PM
08-22-2002 01:32 PM
Re: perl script not working the way I expect
I usually do, but I only said "chop" because he was using perl 4.
"chomp" didn't appear until perl 5.
-- Rod Hills