Printf
How could I please put the following example; 1000.000 10.000 100.000 1.000 To please print out, IN A LINE with the Decimal Place! and not from the first number, so all the decimal places would line up! example; I have tried printf and had no luck Thanks GD -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Dates
> I want to print a weekly transaction statement using perl. > It should ask the user to enter the start date and the end date > e.g:$start_date = 30/08/01(dd/mm/yy) > > $end_date = 05/09/01 > This information will filter through a transactions file to print out the > statement within the given date. > My program currently has this code: > >if (($day == 17) || ($day == 18) || ($day == 19) || ($day == 20) > ||($day >== 21) || ($day == 22) || ($day == 23)){ > --- > -- > } > > Is it possible to use the start and end dates to filter through the data > e.g, with the given dates above, the program should print statements with > date 30/08, 31/08, 01/09, 02/09, . > Thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Changing Variables
> I want to print a weekly transaction statement using perl. I have written > most of the perl code but I incorporated the dates I needed within the > program. i want the program to be more interactive. It needs to ask the > user to enter the start and end dates for the statement. these will be > stored as variables. I need to know how to incorporate these ever changing > variables within the perl program especially when a start date has a > different month to the end date eg: > $start_date = 30/08/01(dd/mm/yy) > $end_date = 05/09/01 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
FW: Sorting
> How do I please sort; $a in ascending order > > > ## > $inFile = " $outFile = "sort-etopup.pl"; > open IN, $inFile or die "Can't open $inFile: $!"; > open OUT, ">$outFile" or die "Can't create $outFile: $!"; > > while () { > $line = $_; > $a = substr($line, 94, 8); # Terminal ID > $b = substr($line, 109, 6); # Merchant ID > $c = substr($line, 80, 14); # Date > $d = substr($line, 4, 1); # Network ID > printf OUT "%8s %6s %14s %1s\n", $a, $b, $c, $d; > } > [End of file] > # -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
$ARGV Help
I have a program that reads an input file and outputs the file, with where I want each field to start from! ## open ORG,"<$ARGV[0]" or die "Cannot open $ARGV[0]",$!; open NEW,">$ARGV[1]"; while($line=){ chomp $line; @fields = split ',',$line; printf ORG"%-9s%-15s%-40s%-15s\n",$fields[0],$fields[1],$fields[2],$fields[3]; } close ORG; close NEW; exit; [End of file] ### What I need help on please is 'How to specify at the COMMAND LINE where I want each field to start from', INSTEAD of specifying it from the in the programme! At the moment I specify the positions in the programme by; printf ORG"%-9s%-15s%-40s%-15s\n",$fields[0],$fields[1],$fields[2],$fields[3]; NOTE; * The number of fields very all the time, as different input files will have different amounts of fields. * The start positions will always be different. PS. Any help and advice would be very much appreciated. Regards, Govin. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Aline
> How do I please get the fields to align left please; At the moment the output of the fields align right; 113418VGary O'Callag 407358 OVTQ WV113394 Clive Butler 40528 PTYUR > I want the output to be; 113418V Gary O'Callag 407358 OVTQ WV113394 Clive Butler 40528PTYUR > programme so far which > > open CSV," open NEW,">a.pl"; > while($line=){ > chomp $line; > my @fields = split ',',$line; > printf NEW"\n%7.7s%10.10s%35.35s%15.15s", > $fields[0],$fields[1],$fields[2],$fields[3]; > } > close CSV; > close NEW; > exit; > > > Any suggestations would be very much apprecated. > > Thanks, > Kind Regards, > GD.
RE: Help pls %
How do I please get the fields to start from the positions I want them to please; For example I want; $fields[0], (which is 7 characters long to start from position "0"). $fields[1], (which is 10 characters long to start from position "10"). $fields[2], (which is 35 characters long to start from position "25"). $fields[3]; (which is 15 characters long to start from position "65"). programme so far which open CSV,"a.pl"; while($line=){ chomp $line; my @fields = split ',',$line; printf NEW"\n%7.7s%10.10s%35.35s%15.15s", $fields[0],$fields[1],$fields[2],$fields[3]; } close CSV; close NEW; exit; Any suggestations would be very much apprecated. Thanks, Kind Regards, GD.
RE: printf
Does any body know why the printf is not printing anything out! I tested the rest of the script by replacing the printf line with, ## print "$line"; ## the file prints (with out any changes to the file, as expected). So everything else is working apart from the printf. Any help would be much appreciated. Thanks. GD
RE: loop
Is this possible, if not how can I go about doing this; while($line=<@newarray>){ I want to go about runnig a loop on @newarray, but I also need the varible to hold the @newarray! Thanks GD
RE: Some body help!
> I have a input file which is a fixed line file (all along one line, no " > \n or \r "). > ## > Q. How would I separate each data type, to do the following; > > At @fields 490, insert \r (carriage return). > > So I want the input file, to look like below, is a few *LINES* of example > of the input file after inserting \r: > > 168127407932117187M01080m200107035eN/A > 168148007947033647M200107015m21n/a > 168149807947023347M000200107m034500n/a > 168150607947058268M200107015y13 n/a > ## > > I want to do this so that the while loop does not stop after the first > selection, and continues looping, for each line (once they are separated)! > > As the problem being at the moment is that the while loop stops at the > first selection! > ## > > ### > open ISCD," CALL_SUMMARY_CHANGES4_5.HADES;21",$!; > open NEW,">.pl"; > while($line=){ > chomp $line; > @fields = split //, $line; > printf NEW '%1.1s' x 44, @fields[0..33,290..299]; > } > close ISCD; > close NEW; > exit; > [End of file] > ## > > Any help would be much appreciated! > > Kind Regards, > GD
RE: \r
I have a input file which is a fixed line file (all along one line, no " \n or \r "). ## Q. How would I separate each data type, to do the following; At @fields 490, insert \r (carriage return). So I want the input file, to look like below, is a few *LINES* of example of the input file after inserting \r: 168127407932117187M01080m200107035eN/A 168148007947033647M200107015m21n/a 168149807947023347M000200107m034500n/a 168150607947058268M200107015y13 n/a ## I want to do this so that the while loop does not stop after the first selection, and continues looping, for each line (once they are separated)! As the problem being at the moment is that the while loop stops at the first selection! ## ### open ISCD,".pl"; while($line=){ chomp $line; @fields = split //, $line; printf NEW '%1.1s' x 44, @fields[0..33,290..299]; } close ISCD; close NEW; exit; [End of file] ## Any help would be much appreciated! Kind Regards, GD
FW: REGEX
> Thank you for your reply. I made the changes you suggested, however some > of them did not work, these where the following results; > > # while (defined($line=)){ *produced only line 1* > # while(){ *produced NO lines* > # print SORTCODE @fields[0..33,290..299]; > close iscd; > close sortcode; > exit;*produced only line 1* > ## > For some reason it seems that the programme is not reconising the > "\r carrage return" or "\n new line", at the end of each line for the > input file! > OR not looping the file! > > of new program > ## > open ISCD," CALL_SUMMARY_CHANGES4_5.HADES;21",$!; > open NEW,">.pl"; > while (defined($line=)){ > chomp $line; > @fields = split //, $line; > printf NEW '%1.1s' x 44, @fields[0..33,290..299]; > } > close ISCD; > close NEW; > exit; > [End of file] > ## > > >I have a input file, below is a few *LINES* of example of the input file: > > > 168127407932117187M01080m200107035eN/A > > 168148007947033647M200107015m21n/a > > 168149807947023347M000200107m034500n/a > > 168150607947058268M200107015y13 n/a >
RE: REGEX[2]
> One problem (sorry), the program only reads the first line and not the > rest. Any suggestions, would be very much apprecated. > > # > I have a input file, below is a few *LINES* of example of the input file: > > 168127407932117187M01080m200107035eN/A > 168148007947033647M200107015m21n/a > 168149807947023347M000200107m034500n/a > 168150607947058268M200107015y13 n/a > > ## > > # > open iscd," $ARGV[0]",$!; > open sortcode,">.pl"; > while($line=){ > chomp $line; > @fields = split //, $line; > printf sortcode > "%1.1s%1.1s%1.1s%1.1s%1.1s%1.1s%1.1s%1.1s%1.1s%1.1s%1.1s%1.1s%1.1s%1.1s%1. > 1s%1.1s%1.1s%1.1s%1.1s%1.1s%1.1s%1.1s%1.1s%1.1s%1.1s%1.1s` > @fields[0..33,290..299]; > } > close iscd; > close sortcode; > exit; > [End of file] > ## > > Thanks > Kind Regards > GD >
RE: REGEX
Hi, can any body help me with a regex problem that I have please! # Q. Could any body please show me how to, print data by searching character Numbers in a input line! # I have a input file, below is a few *LINES* of example of the input file: 168127407932117187M01080m200107035eN/A 168148007947033647M200107015m21n/a 168149807947023347M000200107m034500n/a 168150607947058268M200107015y13 n/a ### For each *line* of the input file I need to get certain sets of data in the line (string), for example; 0 to 5 (characters), 8 to 12 (characters), 14 to 16 (characters on each line) *I can only search by specifying numbers* as there is no, spaces, tabs and etc, to separate the fields that I require! Here is a programme that I wrote in the past to search for Fields, as there was tab spaces in-between the input file, fields. I would like to modify this programme to do what I need, however I can not use this as there is no tab spaces to separate the fields in the input file! open iscd,"<$ARGV[0]" or die "Cannot open $ARGV[0]",$!; open sortcode,">$ARGV[1]"; while($line=){ chomp $line; @fields=split "\t",$line; printf sortcode "\n%6.6s%8.8s%27.27s%35.35s%35.35s", $fields[0],$fields[1],$fields[2],$fields[4],$fields[5],$fields[6]; } close iscd; close sortcode; exit; ### Any help would be much appreciated. Kind Regards GD
RE: $ARGV
I have tried to find out in full detail about the file handle $ARGV and only got the basics. Could any one please explain the $ARGV in more detail, e.g. how to put a input file into the $ARGV, if the input file was constantly changing! The File in may program: open iscd,"<$ARGV[0]" or die "Cannot open $ARGV[0]",$!; open sortcode,">$ARGV[1]"; while($line=){ Thanks, GD
RE: \r
What is the code please to get, after field 6; \r (carriage return) I tried this, but no luck; $fields[6] =~ s\r//; Any help would be much appreciated!!! Thanks, GD # PROGRAM: #!/path/to/perl -w use strict; open CSV,"vt04-07-01.csv-changed"; while (){ chomp; my @fields = split ','; splice @fields, 2, 1; splice @fields, 5, 1; $fields[6] =~ s\r//; for (@fields) { print NEW "$_" } } close CSV; close NEW; exit; [End of file]
RE: Regex
Thank you for your time and your valuable help is much appreciated. I made the changes to the program like you suggested, however I get this error, when I run the program! ## A3 GD > perl CSV.PL; Global symbol "$line" requires explicit package name at csv.pl; line 6. Execution of csv.pl; aborted due to compilation errors. %SYSTEM-F-ABORT, abort ## The modified program: ### #!/path/to/perl -w use strict; open CSV,"vt04-07-01.csv-changed"; while($line=){ chomp; my @fields = split ','; splice @fields, 2, 1; for (@fields) { print NEW "blah $_\n" } } close CSV; close NEW; exit; [End of file] ## > ### USE STRICT AND -w I can not stress that enough!!! ### > > #!/path/to/perl -w > use strict; > > ### use CAPS for filehandles to avoid conflicts with reserved words... use > $ARGV in both places, or neither ### > open CSV, "$ARGV[0] or die "Cannot open $ARGV[0]",$!; > open NEW,">vt04-07-01.csv-changed"; > > ### we'll put all the input into $_ it makes things easier i think... ### > while () { > > ### kill trailing \n ### > chomp; > > ### split the fields on comma's from $_ and put them in @fields ### > my @fields = split ','; > > ### 3rd element of @fields holds unwanted info, we'll splice it out... > perldoc -f splice for more details ### > splice @fields, 2, 1; > > ### an arbitrary print statement to show you all went well > for (@fields) { print NEW "blah $_\n" } > > ### feel free to add more code in... ### > } > > hope this helps, > > Jos Boumans > Thanks, Kind Regards, > GD
RE: Regex
Hi, I have been asked to write a perl script, to Delete 1 field in a input file and then print to a output file! What I need to delete from the file is: Field [3] Can any body please suggest what else needs to be added to the script that I wrote below to do this task please. The big problem being that the data in the File is not sorted in any form, e.g. no Headings etc. The only thing separating the fields is a comment= , Here is two data items examples from the input file (each data is streachted along ONE LINE) : (The field [3] that I need to get rid of is "006" and the number is not always the same) "Value Telecom",98599.00,"006","Welcome to Value Telecom. If you have any queries please contact Customer Services on 0845 6555000 or visit any Carphone Warehouse store.","44776811","SS",,"2001-07-04-08.03.32.221465" "Value Telecom",98599.00,"006","Welcome to Value Telecom. If you have any queries please contact Customer Services on 0845 6555000 or visit any Carphone Warehouse store.","447947022824","SS",,"2001-07-04-08.03.32.221465" THE PROGRAM so far: open csv,"vt04-07-01.csv-changed"; while($line=){ chomp $line; $fields[3] =~ } close csv; close new; exit; [End of file] Any help would be much appreciated as I only have two days to this in!!! Thanks, GD
Printf
Hello can any one help please! Im sending to an out put file to print; printf sortcode"\n%6.6s1%20.20s%45.35s%30.30s%30.30s%30.30s%4.4s%4.4s%8.6s%8.8s", $fields[0],$fields[5],$fields[70],$fields[71],$fields[72],$fields[75],$field s[76],$fields[77],$fields[78],$fields[79]; Q. My question was, is there a way to select two or more fields in one go instead of separate, for example (a guess); $fields[0 5 70] Q. Is there a way of doing this properly!
Printf
I can not get the printf to print, using the following relevant line of code: printf sortcode $fields[0],$fields[5],$fields[70],fields[77]; I am missing something in-between; sortcode *$fields[0] I have tried different things but had no luck! PS Your help would be much appreciated. Thanks, GD
RE: Is this correct
One question please, I want to search for M and A, at the moment I am only searching for M (as below) if ($fields[14] =~ /M/) Would the example below be correct please; if ($fields[14] =~ /\M\|\A\/) Your help is much APPRECIATED > Kind Regards, > GD >
RE: Help please (any one)
Ur Help is Highly APPRECIATED > From: Dave Neill [SMTP:[EMAIL PROTECTED]] > > If you mean by "field 15" the fifteenth element in your array, try: > > > while($line=){ > > > chomp $line; > > > @fields=split "\t",$line; > *if ($fields[14] =~ /M/) { > > printf sortcode "\n%6.6 > > > s%8.8s%27.27s%20.20s%5.5s%16.16s%10.10s%8.8s%10.10s", > > > $fields[0],$fields[5], > > > > > > $fields[70],$fields[71],$fields[73],$fields[74],$fields[75], > > > $fields[76],$fields[77]; > > } > > > } > > > > > > close iscd; > > > close sortcode; > > > exit; > > You'll want to read up on if regexp matching to make this condition more > restrictive and to find out how to match your other conditions. > > > Thanks for your reply early it was much appricated. I have two questions please; 1. If we are after field 15, how comes you used field 14 in your answer please! *if ($fields[14] =~ /M/)*** 2. Were could I read up on 'regexp' please! Kind Regards, GD
RE: Help please (any one)
> Hello everyone, I finally got my perl program running (below). What I had > to do was get certain 'data types' (fields) from a input file and out put > to a new file. > My question was; > How do I put a condition on the program, as I only want data from the > input files, which at 'field 15' has a 'M' and some other fileds that I > need(as marked on example data)! > > e.g Data example from input file which has 20+. Has fields('data types') > >086117...00.BNY INTERNATIONAL LTD .CO-OPERATIVE BANK .THE CO-OP >ERATIVE BANK PLC ..0021..A..15/10/1999 > ..*M*.18/05/199 >9...301599.0021.01.00.0021.02.Y.N.N..14/11/1999...29-MAY-2 >001 .N...25/05/2001 05:18.5250.M.03/10 >/1996..21 ...GB .MGMAC -Comercial CR Ltd > .1..Brighton, E.Sussex ...Sovereign Hse > .Church St ...Brighton >.E.Sussex .BN1 .1SS .01273 .321211 > .. > > My program: > > open iscd,"iscd.tmp" or die "Cannot open $ARGV[0]",$!; > open sortcode,">sortcode.tmp"; > while($line=){ > chomp $line; > @fields=split "\t",$line; > printf sortcode "\n%6.6 > s%8.8s%27.27s%20.20s%5.5s%16.16s%10.10s%8.8s%10.10s", >$fields[0],$fields[5], > > $fields[70],$fields[71],$fields[73],$fields[74],$fields[75], >$fields[76],$fields[77]; > } > > close iscd; > close sortcode; > exit; > > > > > > > > > > > > > Govinderjit Dhinsa >
RE: Search Conditions
> Hello everyone, I finally got my perl program running (below). What I had > to do was get certain 'data types' (fields) from a input file and out put > to a new file. > My question was; > How do I put a condition on the program, as I only want data from the > input files, which at 'field 15' has a 'M' and some other fileds that I > need(as marked on example data)! > > e.g Data example from input file which has 20+. Has fields('data types') > >086117...00.BNY INTERNATIONAL LTD .CO-OPERATIVE BANK .THE CO-OP >ERATIVE BANK PLC ..0021..A..15/10/1999 > ..*M*.18/05/199 >9...301599.0021.01.00.0021.02.Y.N.N..14/11/1999...29-MAY-2 >001 .N...25/05/2001 05:18.5250.M.03/10 >/1996..21 ...GB .MGMAC -Comercial CR Ltd > .1..Brighton, E.Sussex ...Sovereign Hse > .Church St ...Brighton >.E.Sussex .BN1 .1SS .01273 .321211 > .. > > My program: > > open iscd,"iscd.tmp" or die "Cannot open $ARGV[0]",$!; > open sortcode,">sortcode.tmp"; > while($line=){ > chomp $line; > @fields=split "\t",$line; > printf sortcode "\n%6.6 > s%8.8s%27.27s%20.20s%5.5s%16.16s%10.10s%8.8s%10.10s", >$fields[0],$fields[5], > > $fields[70],$fields[71],$fields[73],$fields[74],$fields[75], >$fields[76],$fields[77]; > } > > close iscd; > close sortcode; > exit; > > > > > > > > > > > > > Govinderjit Dhinsa >
RE: PROGRAM!
ME wrote: > You want to print out array elements 0 (for the ID), 3 (branch), > and -3 through -7 (address), at least I think that will work. > #!/usr/bin/perl -w use strict; while (<>) { @fields = split /*/; for (my $i = -1; $i > -9; --$i) { print $fields[$i] . "\n"; } } Q What does " use strict "do please! Q IS this what you want me to change it to for (my $i = 0; $i > -3; $i > -7) { PS. not able to get access to the manpage. Thanks. Kind Regards, GD
Re:MANPAGE
How do I get access to the manpages please
FW: FW: PROGRAM!
Morning, I have made a attachment in word, to make it slightly easier for you to see the 'data items' in the file. There are two examples, but they are suppose to all be on one line. However I couldn't get the examples on one line for you to see, sorry! All the spaces between the items are correct. Also I put a program in the attachment on page2, Question: what would have to be changed, so that I only get back only the 3 data items that I need please! <> Thanks Kind Regards, GD
RE: PROGRAM HELP!
(Thanks ME, who ever you are) Hi, I have been asked to write a perl script, to format the output in to fields/columns; Description for script: *Read a existing file and put it in my requested format, *Take certain data types from the file (input), (problem) *Put the certain data types in to fields/columns (output). (problem) The big problem being that the data in the File is not sorted in any form, e.g. no Headings etc. The only thing separating the data types are spaces! What I need to get from the file are: ID.NUMBER,BranchNAME, ADDRESS. The file contains the above 3 data types that I need, also about another 10+ which I need to get rid off! Can any body please suggest how do this task please, e.g. Report writing etc Here is two data examples from the input file (each data is normally streachted along ONE LINE) : (I need the three data types that are'underlined' (ID.NUMBER, BranchNAME, ADDRESS). 086117 00 BNY INTERNATIONAL LTD CO-OPERATIVE BANK THE CO-OPERATIVE BANK PLC0021A 15/10/1999 M18/05/1999 301599 00210100 002102 Y NN 14/11/1999 29-MAY-2001 N 25/05/2001 05:185250M 03/10/1996 21 GBM GMAC -Comercial CR Ltd 1 Brighton, E.Sussex Sovereign Hse Church St Brighton E.SussexBN1 1SS 01273 321211 101599 00 PAYMASTER GENERAL BANK OF ENGLAND BANK OF ENGLAND0001D 17/08/1999 M 01/09/1998 00010101 000101 Y N DR CR CU PR BS DV AUN 15/10/2000 29-MAY-2001 N 25/05/2001 05:188117 N 20/09/2000 M GOVERNMENT AGENCIES Paymaster General 1 Paymaster General Cheque & Credit Clearing (FDR) Christopher Martin Rd BasildonEssex SS149AA 01268 298624 > Any help would be much appreciated as I only have two days to this in!!! > Thanks, GD
RE: PERL PROGRAM HELP!
Hi, I am new to perl and have been chucked in the deep end!!! I have been asked to write a perl script, with a output in report style; Description for script: Read a file, (sorted) take certain data from the file, (problem) put the certain data in to fields.(problem) The big problem being that the File is not sorted in any form, e.g. no existing columns or fields or Headings! What I need to get from the file are: ID NUMBER, BranchNAME, ADDRESS. The file contains the above 3 data types and about another 5, which I need to get rid off! Can any body please suggest how do this task or what I need to read up on (topics e.g. Report writing etc) or any other tutorials on report writing or, any thing to show me how to get certain data from a file please Any help would be appreciated as I only have two days to this in!!! Somebody please help!
RE: PERL PROGRAM HELP!
Iv been givin this program to modify, but I can not astblish what some parts of the program are doing. From printf to } Can any body help please and run through it with me pls! open iscd,"<$ARGV[0]" or die "Cannot open $ARGV[0]",$!; open sortcode,">$ARGV[1]"; while($line=){ chomp $line; @fields=split "\t",$line; printf sortcode "\n%6.6s%8.8s%3.3s%27.27s%20.20s%35.35s%35.35s%10.10s%1.1s%1.1s%2.2s%2.2s%2. 2s%2.2s%2.2s%2.2s%2.2s%2.2s%2.2s%2.2s%1.1s%1.1s%6.6s%35.35s%4.4s%4.4s%10.10s %8.8s", $fields[0],$fields[1],$fields[2],$fields[4],$fields[5],$fields[6],$fields[7] ,$fields[11],$fields[14],$fields[25], $fields[26],$fields[27],$fields[28],$fields[29],$fields[30],$fields[31],$fie lds[32],$fields[33], $fields[34],$fields[35],$fields[58],$fields[60],$fields[61],$fields[64], $fields[76],$fields[77],$fields[78],$fields[79]; } close iscd; close sortcode; exit; [End of file]