Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

New with perl

This is a discussion on New with perl within the PERL forums, part of the Web Development category; Hi please need realy help. I am new in perl here is what i am looking for input file : collected by : n/a collection agency code : canadian bonded ...

Go Back   Geeks Talk > Web Development > PERL
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read

PERL PERL Scripts - Tips, Tricks, Issues, Latest News, PERL Resource and PERL related topics can be discussed in this forum.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-29-2008
Junior Member
 
Join Date: Jul 2008
Location: Canada
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
shrupeete is on a distinguished road
New with perl

Hi please need realy help. I am new in perl here is what i am looking for input file : collected by : n/a collection agency code : canadian bonded credit ltee code ban activity type cycle status ---- --------- ---------------------- ----- ------------ bch 300008827 financial activity 5 canceled ar-activity : payment activity-amt : 84.60 activity date : 07/15/2008 bch 300340698 financial activity 7 canceled ar-activity : invoice receipt activity-amt : 13.01 activity date : 07/17/2008 report totals bans : 2 what i want out in 2 file first file working) ban code activity type cycle status second file : (not working) ban ar-activity activity-amt activity date what i am trying to do once hit the ":" split the info and print fthe record while ($record = <arca>) { $record =~ s/[\r\n]+/ /g; # remove cr and/or lf and replace with space if (substr($record,40,12) eq "report date:"){ $reportdate = substr($record,53,10); } if (int(substr($record,7,9)) >= int(300000000)||(substr($record,7,9)) >= int(500000000)){ $ban = substr($record,7,9); print outputfile trim($reportdate); # as report date, print outputfile $delimiter; print outputfile trim(substr($record,1,6)); # as code, print outputfile $delimiter; print outputfile trim($ban); # as ban, print outputfile $delimiter; print outputfile trim(substr($record,49,12)); # as ban status, print outputfile $delimiter; print outputfile trim(substr($record,42,5)); # as bill cycle, print outputfile "\n"; } else { if($record =~ /:/){ # my @pos = split(/:/,$record); # &trim_arr(@pos); print second trim($ban); # as ban to second file , print second $delimiter; print second "hello"; print second $delimiter; print second $record; print second "\n"; } } #$col=substr($record,45,1); #@pos = split(/:/,$col); #&trim_arr(@pos); #foreach my $token (@pos) { #if($token eq ':') #{ # print outputfile "$token$delimiter"; #} #} } close(arca); close(outputfile); close(second); second output coming (wrong output) |hello| report arca-05 c o l l e c t i o n a g e n c y f i l e r e p o r t page: 2 |hello| bch date: 07/17/2008 |hello| collected by : n/a |hello| collection agency code : canadian bonded credit ltee 300008827|hello| ar-activity : payment 300008827|hello| activity-amt : 84.60 300008827|hello| activity date : 07/15/2008 300340698|hello| ar-activity : invoice receipt 300340698|hello| activity-amt : 13.01 300340698|hello| activity date : 07/17/2008 300340698|hello| report totals bans : 2
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-29-2008
Junior Member
 
Join Date: Jul 2008
Location: Canada
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
shrupeete is on a distinguished road
Re: New with perl

i got it work but not split function not wrking
modify the code :
while ($record = <ARCA>) {
$record =~ s/[\r\n]+/ /g; # Remove CR and/or LF and replace with space

if (substr($record,40,12) eq "Report Date:"){
$ReportDate = substr($record,53,10);
}
if (int(substr($record,7,9)) >= int(300000000)||(substr($record,7,9)) >= int(500000000)){
$Ban = substr($record,7,9);
print OutPutFile trim($ReportDate); # AS Report Date,
print OutPutFile $Delimiter;
print OutPutFile trim(substr($record,1,6)); # AS Code,
print OutPutFile $Delimiter;
print OutPutFile trim($Ban); # AS BAN,
print OutPutFile $Delimiter;
print OutPutFile trim(substr($record,49,12)); # AS BAN Status,
print OutPutFile $Delimiter;
print OutPutFile trim(substr($record,42,5)); # AS Bill Cycle,
print OutPutFile "\n";
}
else{
if(substr($record,45,1) eq ':'){
my @pos = split(/:/,$record);
&trim_arr(@pos);
print Second trim($Ban); # AS BAN to second file ,
print Second $Delimiter;
print Second trim(@pos);
print Second "\n";
}
}
#$col=substr($record,45,1);
#@pos = split(/:/,$col);
#&trim_arr(@pos);
#foreach my $token (@pos) {
#if($token eq ':')
#{
# print OutPutFile "$token$Delimiter";
#}
#}
}
close(ARCA);
close(OutPutFile);
close(Second);

output coming : WRONG
Ban|ACTIVITY DATE|ACTIVITY-AMT|AR-ACTIVITY|
300004967|NAME : 2877457 CANADA INC. ADDRESS-1 : 9600 RUE MEILLEUR, 2 ETAGE
300004967|ATTENTION : ADDRESS-2 :
300004967|AR-BALANCE : 8,400.27 CITY/PROVINCE : MONTREAL,/QC
300004967|HOME-TN : POSTAL CODE : H2N2E3
300004967|WORK-TN : SIN : 000-000-000
300004967|EMPLOYER-NAME : BIRTH DATE :
300004967|ASSIGN DATE : 07/17/2008 CANCEL FEE : 0.00
300004967|CURRENCY_CODE : CAD
Reply With Quote
  #3 (permalink)  
Old 07-29-2008
Junior Member
 
Join Date: Jul 2008
Location: Canada
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
shrupeete is on a distinguished road
Re: New with perl

want output like :
Ban|ACTIVITY DATE|ACTIVITY-AMT|AR-ACTIVITY
300004967|07/17/2008|8,400.27|CAC
i using split function
my @pos = split(/:/,$record);
&trim_arr(@pos);
which is telling me its 3 elements but now to break them
Reply With Quote
  #4 (permalink)  
Old 07-30-2008
Junior Member
 
Join Date: Jul 2008
Location: Canada
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
shrupeete is on a distinguished road
Re: New with perl

working guys thx
Reply With Quote
Reply

  Geeks Talk > Web Development > PERL

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
PERL Language r3108 PERL 2 04-17-2009 07:08 AM
Working with XML in Perl Lokesh M AJAX & XML 0 09-06-2007 11:29 AM
about PERL... psuresh1982 PERL 5 09-04-2007 11:04 PM
How is PERL helpful for testers Geek_Guest Career Advice 0 06-28-2007 04:10 AM
Need Forums or PERL/PYTHON kalayama Suggestions & Feedback 3 12-21-2006 09:14 PM


All times are GMT -4. The time now is 08:05 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved