Ask a Question related to PERL Miscellaneous, Design and Development.
-
Dan Guzman #1
using tr and ascii value
I'm updating a process that reads in text file from a mainframe
extract. The script reads and parses out this file and creates html
documents from this data. I'm having a problem when the mainframe put
in a certain character '' the perl script stops running. It's values
are:
hex - 1a
dec - 26
oct - 032
How do I replace these types of characters? Thanks,
Dan
.........
while($mLine=<INPUTFILE>) {
chomp($mLine);
$mLine =~tr/<>/ /; #-replaces <> with a space .
$mLine =~tr/\26/ /;
print $mLine;
if (substr($mLine,0,12) eq "START-REC!!!") {
#- Parse columns and insert to table!
($mTag,$mticket) = split /!!!/,$mLine;
$mticket=~ s/^\s*(.*?)\s*$/$1/;
$mText = "<pre><b><font size=4 color=blue>Ticket :
$mticket</font>\n<font size=1 color=blue>Last Mainframe
Synchronization: $mLastUpdate</font>\n\n</b>";
} elsif (substr($mLine,0,13) eq "!!!END-REC!!!") {
$mText=$mText."\n<b><font size=1 color=blue>Last Mainframe
Synchronization: $mLastUpdate</font></b></pre>";
#- Write $mText to file using the ticket nnumber as filename.
&loadTicketData($mticket,$mText);
print "$mticket\n";
} else {
$mText=$mText.$mLine."\n";
}
}
close(INPUTFILE);
Dan Guzman Guest
-
Non Ascii pathname
When I try to open a .dcr file that has Japanese characters in the pathname IE seems to find it fine. But the ActiveX control seems to be unable to... -
ASCII bug?
mysql field.test="St. Patricks Day " ------------------------ form.cfm: <cfquery name="getfield" datasource="database"> select field from... -
string to ascii
let's say I have a string say, "abcABC" how do I convert those 6 letters into their respective ASCII numbers, and if I have 6 ASCII numbers, how... -
Ascii to tif.
AIX version 4.3.3 computer rs6000/f50 Is there a AIX/UNIX utility that will take an ASCII file and convert it to a TIF file? -
Bob Walton #2
Re: using tr and ascii value
Dan Guzman wrote:
........> hex - 1a
> dec - 26
> oct - 032
>
> How do I replace these types of characters? Thanks,
>
> Dan
> $mLine =~tr/\26/ /;
Did you look in the docs, specifically:
perldoc perlop
? There it will tell you that something like:
$mLine =~ tr/\032/ /;
or
$mLine =~ tr/\x1a/ /;
should work.
....
--
Bob Walton
Bob Walton Guest
-
Eric J. Roode #3
Re: using tr and ascii value
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[email]dan@danguzman.com[/email] (Dan Guzman) wrote in
news:ddf15003.0308061646.6c037d1f@posting.google.c om:
Close. Backslash-escaping doesn't work in decimal. You can either use> I'm updating a process that reads in text file from a mainframe
> extract. The script reads and parses out this file and creates html
> documents from this data. I'm having a problem when the mainframe put
> in a certain character '' the perl script stops running. It's values
> are:
>
> hex - 1a
> dec - 26
> oct - 032
>
> How do I replace these types of characters? Thanks,
> ........
> $mLine =~tr/\26/ /;
octal:
$mLine =~ tr/\032/ /;
or hex:
$mLine =~ tr/\x1a/ /;
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPzGtZmPeouIeTNHoEQJUIQCfbvVcljOeyDKYYJ7V7hua0Q 3Z9V4AoLcB
5lHA8bKsv7MgaACKJorxqX1T
=PiEV
-----END PGP SIGNATURE-----
Eric J. Roode Guest
-
Dan Guzman #4
Re: using tr and ascii value
[email]tadmc@augustmail.com[/email] (Tad McClellan) wrote in message news:<slrnbj3gf7.2e2.tadmc@magna.augustmail.com>.. .
The OS is Windows 2000. Running ActivePerl build 626> Dan Guzman <dan@danguzman.com> wrote:
>>> > I'm updating a process that reads in text file from a mainframe
> > extract.
>
> What OS is your Perl program running on?
>I've tried the suggestions above, but without success:>>> > I'm having a problem when the mainframe put
> > in a certain character ' ' the perl script stops running.
$mLine =~ tr/\x1a/ /;
$mLine =~ tr/\032/ /;
Do you mean when the file gets picked up?>
> If your program is running on an OS whose filesystem makes
> a distinction between "text" and "binary" files (like Windows),
> then:
$ftp->login($_user,$_passw);
$ftp->ascii();
Would I do the binmode when I read the file? Thanks,>
> perldoc -f binmode
>
> might fix it.
Dan
Dan Guzman Guest
-
Eric J. Roode #5
Re: using tr and ascii value
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[email]dan@danguzman.com[/email] (Dan Guzman) wrote in
news:ddf15003.0308070727.4a8f32e1@posting.google.c om:
Oh? What was the failure? What did it do that you didn't expect, or what> I've tried the suggestions above, but without success:
>
> $mLine =~ tr/\x1a/ /;
> $mLine =~ tr/\032/ /;
didn't it do that you did expect? What was your input, your expected
output, and your actual output?
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPzLnaGPeouIeTNHoEQIAcgCgthwYom1PgNmNx+OHqm7zm3 pqCxoAnji/
egxse58hwqS0hQHgwDtXWii4
=cTON
-----END PGP SIGNATURE-----
Eric J. Roode Guest



Reply With Quote

