- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- KSH to PERL
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
06-05-2002 10:38 AM
06-05-2002 10:38 AM
I??m a beginner using Perl and I??d like to know how to write the ksh script in the attachment into Perl code.
It takes 2 hours using ksh.
Regards,
R.Bassoi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2002 11:10 AM
06-05-2002 11:10 AM
Re: KSH to PERL
Opening the output file once and spawning cut six times during each iteration will kill the performance of any script.
Work with this:
#!/usr/bin/ksh
DATE=$(date)
while IFS=';' read VAR1 VAR2 VAR3 ...
do
case $VAR4 in
RJ*) VAR_DG=INTRA-RJ-2;;
...
*) print -u2 "$DATE -> INVALID UF ERROR: $VAR4";;
esac
print -u1 "CRECNT........"
done < file.csv > output.txt 2> cbase.rr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2002 11:15 AM
06-05-2002 11:15 AM
Re: KSH to PERL
Try this instead:
#!/usr/bin/ksh
DATE=$(date)
while IFS=';' read VAR1 VAR2 VAR3 ...
do
case $VAR4 in
RJ*) VAR_DG=INTRA-RJ-2;;
...
*) VAR_DG=''; print -u2 "$DATE -> INVALID UF ERROR: $VAR4";;
esac
if [ ${#VAR_DG} -gt 0 ]
then
print -u1 "CRECNT........"
fi
done < file.csv > output.txt 2> cbase.rr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2002 12:36 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2002 10:52 PM
06-05-2002 10:52 PM
Re: KSH to PERL
=open(INP,"
missing double quote and replace || with or
open INP, "< arquivo1a.csv" or die "..."
=open(OUT,">output.txt);
again missing double qoute, and check return status
open OUT, "> output.txt" or die "...";
=%codemap=(
= "RJ","INTRA-RJ-2",
= "ES","INTRA-ES-2",
= :
= );
use lexicals and => for automatic quoting of key values in hash
my %codemap = (
RJ => "INTRA-RJ-2",
);
=while(
= chop;
chop is evil. use chomp.
= ($var1,$var2,$var3,$var4,$var5)=split(";",$_);
wrong. splits first argument is a regular expression, not a string. For the two exceptions top that where the first argument *is* a string read the docs.
my ($var1, ...) = split m/;/; # $_ is default second arg for split
= $var1=$var1+0;
$var1 += 0;
= $var_uf=substr($var4,0,2);
= if ($var_dg=$codemap{$var_uf}) {
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2002 10:07 AM
06-10-2002 10:07 AM
Re: KSH to PERL
Thanks to all !!!