Crypt::IDEA problems
Hi, I'm having problems installing Crypt::IDEA on my mac (10.4). sudo perl Makefile.pl works fine. However, when I run make or make test, I get the following error message: gcc -c -fno-common -DPERL_DARWIN -no-cpp-precomp - DUSE_SITECUSTOMIZE -DNO_HASH_SEED -DBUILT_BY_ACTIVESTATE -fno-strict- aliasing -pipe -Os -DVERSION=\1.02\ -DXS_VERSION=\1.02\ -I/ usr/local/ActivePerl-5.8/lib/5.8.7/darwin-thread-multi-2level/CORE _idea.c _idea.c:8:20: error: endian.h: No such file or directory make: *** [_idea.o] Error 1 Is the problem with endian.h? What is endian.h? I googled it, and found that it was part of GLT, but I don't see how that could be related to an encryption mod. Perhaps I should compile this with gcc 3.3 instead of gcc 4.0? If so, how do I do that? I'm running ActiveState Perl 5.8.7 on Tiger. Crypt::IDEA was not in the ActiveState repositories, so I'm doing this manually. Any help would be greatly appreciated. --jm
Re: Crypt::IDEA problems
John Mercer said: Is the problem with endian.h? What is endian.h? I googled it, and found that it was part of GLT, but I don't see how that could be related to an encryption mod. Well, I can answer this part of the question... endian.h looks to be a fairly general file, that GLT just happens to include. It defines some macros for dealing with endian issues. Now the question is what are endian issues. ;) Endian issues (and endian in general) are computer terms dealing with how numbers are stored/worked with on a computer. Just about every computer knows what a 'byte' is, but then you have numbers which are two, or four, or___ bytes long. The question is: What order are the bytes in? There are two possbile (Well, with longer numbers there are more, but only two good ones.), and good reasons for each. So, of course, people do it both ways. Normally you don't have to think about this that much, but when you have complicated, optimized, number crunching you often want to remove the levels of abstraction that mean most programmers don't have to think about this. Graphics processing and encryption are prime candidates for such, so them both using the same routines to handle it isn't suprising. Short version: It's a number-handling header, that they both happen to use. You'll need to find something that has or will install a copy for you, most likely. Daniel T. Staal This email copyright the author. Unless otherwise noted, you are expressly allowed to retransmit, quote, or otherwise use the contents for non-commercial purposes. This copyright will expire 5 years after the author's death, or in 30 years, whichever is longer, unless such a period is in excess of local copyright law.
Re: Crypt::IDEA problems
Looks to me that _idea.c is assuming that all system have /usr/ include/endian.h, which is false (it's probably a Linux assumption). You can probably get this to work by changing line 8 to: #include machine/endian.h for Mac OS X anyways. Edward Moy Apple On Jun 15, 2005, at 8:01 AM, John Mercer wrote: Hi, I'm having problems installing Crypt::IDEA on my mac (10.4). sudo perl Makefile.pl works fine. However, when I run make or make test, I get the following error message: gcc -c -fno-common -DPERL_DARWIN -no-cpp-precomp - DUSE_SITECUSTOMIZE -DNO_HASH_SEED -DBUILT_BY_ACTIVESTATE -fno- strict-aliasing -pipe -Os -DVERSION=\1.02\ -DXS_VERSION=\1.02 \ -I/usr/local/ActivePerl-5.8/lib/5.8.7/darwin-thread- multi-2level/CORE _idea.c _idea.c:8:20: error: endian.h: No such file or directory make: *** [_idea.o] Error 1 Is the problem with endian.h? What is endian.h? I googled it, and found that it was part of GLT, but I don't see how that could be related to an encryption mod. Perhaps I should compile this with gcc 3.3 instead of gcc 4.0? If so, how do I do that? I'm running ActiveState Perl 5.8.7 on Tiger. Crypt::IDEA was not in the ActiveState repositories, so I'm doing this manually. Any help would be greatly appreciated. --jm
Re: Crypt::IDEA problems
Good call, Ed. That fixed the problem. Smooth install. Thanks, jm On Jun 15, 2005, at 12:21 PM, Edward Moy wrote: Looks to me that _idea.c is assuming that all system have /usr/ include/endian.h, which is false (it's probably a Linux assumption). You can probably get this to work by changing line 8 to: #include machine/endian.h for Mac OS X anyways. Edward Moy Apple On Jun 15, 2005, at 8:01 AM, John Mercer wrote: Hi, I'm having problems installing Crypt::IDEA on my mac (10.4). sudo perl Makefile.pl works fine. However, when I run make or make test, I get the following error message: gcc -c -fno-common -DPERL_DARWIN -no-cpp-precomp - DUSE_SITECUSTOMIZE -DNO_HASH_SEED -DBUILT_BY_ACTIVESTATE -fno- strict-aliasing -pipe -Os -DVERSION=\1.02\ -DXS_VERSION=\1.02 \ -I/usr/local/ActivePerl-5.8/lib/5.8.7/darwin-thread- multi-2level/CORE _idea.c _idea.c:8:20: error: endian.h: No such file or directory make: *** [_idea.o] Error 1 Is the problem with endian.h? What is endian.h? I googled it, and found that it was part of GLT, but I don't see how that could be related to an encryption mod. Perhaps I should compile this with gcc 3.3 instead of gcc 4.0? If so, how do I do that? I'm running ActiveState Perl 5.8.7 on Tiger. Crypt::IDEA was not in the ActiveState repositories, so I'm doing this manually. Any help would be greatly appreciated. --jm
Parsing UTF8 files with wide characters
I thought I'd understood how to use unicode support in perl, but evidently not. In the script below, I'm stumped as to: 1) why the regex won't match ''. 2) why the substitution is carried out, but the result isn't in UTF8, nor is it UTF8 re-encoded in UTF8 (uncomment #require Encode; ... #Encode::decode_utf8($_); to test this ) TIA Robin #!/usr/bin/perl -w use strict; use diagnostics-verbose; #require Encode; binmode (DATA,:utf8); binmode (STDOUT,:utf8); for (DATA){ if (/([EMAIL PROTECTED])/gs){ print match: ,$1,\n; #Encode::decode_utf8($_); s/$1//gs; }elsif(/()/gs){ print match: ,$1,\n; s/$1/12/gs; } print; } __DATA__ !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd; HTML HEAD META HTTP-EQUIV=content-type CONTENT=text/html; charset=utf-8 TITLE A Web Page/TITLE /HEAD BODY BLOCKQUOTE H3newsFONT COLOR=#FF33001/FONT/H3 ... and this is a web page. P IMG ALT=A Filler WIDTH=450 HEIGHT=296 P hidden marker here -FONT COLOR=#FF3300[EMAIL PROTECTED]/FONT--BR /BLOCKQUOTE /BODY /HTML
Re: Parsing UTF8 files with wide characters
Try use utf8 - it lets Perl know that your script contains utf8 chars. More info: http://perlpod.com/5.9.1/lib/utf8.html Andrew On Jun 15, 2005, at 2:48 PM, Robin wrote: I thought I'd understood how to use unicode support in perl, but evidently not. In the script below, I'm stumped as to: 1) why the regex won't match ''. 2) why the substitution is carried out, but the result isn't in UTF8, nor is it UTF8 re-encoded in UTF8 (uncomment #require Encode; ... #Encode::decode_utf8($_); to test this ) TIA Robin #!/usr/bin/perl -w use strict; use diagnostics-verbose; #require Encode; binmode (DATA,:utf8); binmode (STDOUT,:utf8); for (DATA){ if (/([EMAIL PROTECTED])/gs){ print match: ,$1,\n; #Encode::decode_utf8($_); s/$1//gs; }elsif(/()/gs){ print match: ,$1,\n; s/$1/12/gs; } print; } __DATA__ !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd; HTML HEAD META HTTP-EQUIV=content-type CONTENT=text/html; charset=utf-8 TITLE A Web Page/TITLE /HEAD BODY BLOCKQUOTE H3newsFONT COLOR=#FF33001/FONT/H3 ... and this is a web page. P IMG ALT=A Filler WIDTH=450 HEIGHT=296 P hidden marker here -FONT COLOR=#FF3300[EMAIL PROTECTED]/ FONT--BR /BLOCKQUOTE /BODY /HTML
Re: Parsing UTF8 files with wide characters
On Jun 15, 2005, at 2:48 PM, Robin wrote: I thought I'd understood how to use unicode support in perl, but evidently not. In the script below, I'm stumped as to: 1) why the regex won't match ''. 2) why the substitution is carried out, but the result isn't in UTF8, nor is it UTF8 re-encoded in UTF8 (uncomment #require Encode; ... #Encode::decode_utf8($_); to test this ) The binmode() calls you've included tell Perl that the data coming from and going to those file handles is UTF8 encoded. But, you have UTF8-encoded text in your code, too. To tell Perl about that, you need to use the use utf8; pragma. sherm-- Cocoa programming in Perl: http://camelbones.sourceforge.net Hire me! My resume: http://www.dot-app.org
Re: Parsing UTF8 files with wide characters
thanks Andrew and Sherm I went back to look at perluniintro because I was sure I could remember reading that the use utf8 pragma was no longer needed, right under where it says this it continues Only one case remains where an explicit use utf8 is needed: if your Perl script itself is encoded in UTF-8 *sigh* Robin
Re: Parsing UTF8 files with wide characters
At 4:26 am +0900 16/6/05, Robin wrote: I went back to look at perluniintro because I was sure I could remember reading that the use utf8 pragma was no longer needed, right under where it says this it continues Only one case remains where an explicit use utf8 is needed: if your Perl script itself is encoded in UTF-8 Nevertheless (Perl 5.8.6) if you simply comment #binmode (DATA,:utf8); #binmode (STDOUT,:utf8); provided your script is UTF-8 encoded, there is no need for 'use utf8'. The script you posted works fine in that case, as does $f = $ENV{HOME}/junk.txt; open F, $f; print F ; close F; open F, $f; for (F) {// and print} JD
Re: Parsing UTF8 files with wide characters
On 2005.6.16, at 05:13 AM, John Delacour wrote: At 4:26 am +0900 16/6/05, Robin wrote: I went back to look at perluniintro because I was sure I could remember reading that the "use utf8" pragma was no longer needed, right under where it says this it continues "Only one case remains where an explicit "use utf8" is needed: if your Perl script itself is encoded in UTF-8" Nevertheless (Perl 5.8.6) if you simply comment #binmode (DATA,":utf8"); #binmode (STDOUT,":utf8"); provided your script is UTF-8 encoded, there is no need for 'use utf8'. The script you posted works fine in that case, Not a good idea. For the time being, and until UTF-8 is established as the default encoding for perl (should that ever happen), when your source code includes multibyte characters tell perl so. I suppose, in a context where you have automatic encoding conversion taking place whenever you move code from one environment to another, this rule of thumb would not be a rule of thumb. But otherwise, you want to do what you can to tell the various things that interpret your code what the encoding is. (And blind automatic conversion has its own set of problems.) as does $f = "$ENV{HOME}/junk.txt"; open F, "$f"; print F "月"; close F; open F, $f; for (F) {/月/ and print} JD -- Joel Rees I've already left the building. You don't really see me here.
Flat file being Scrambled
Hi, Here's a quick question. This doesn't have anything to do with perl on my mac, but just a perl question. I have a a small script that simply increases a number by 1, when it is run, then writes the changes back to the file. I am using it to check how many people come to the site by way of an email. Everything seemed to work fine until I got here this morning and the file was only left with 1 row of 1 number verses 2 rows of 10 numbers each. Here is what the file should look like (The zeros would not necessarily be zeros, but could be any number. 0:0:0:0:0:0:0:0:0:0 0:0:0:0:0:0:0:0:0:0 What I have found is that when I click at a normal pace, everything works fine, BUT... when I click the reload button unmercifully, the data file gets rewritten to look like the following: 0 (or some other number - less then what it was previously) That's it! everything else is gone. Is is possible that if there are so many hits that it can't keep up with the opening and writing of the file? This simple database is potentially being alter by 2 million people, as the email went out to that many people. Any help would be greatly appreciated. Below is the script. Thanks, Mark Wheler Here is the script: -- #!/usr/local/bin/perl -w #=== # format for ab variable in html email: # # control(0)/test(1):week(1-10) # # So 0:5 would be control group, week 5 and 1:9 would be # test group, week 9 #=== use strict; use CGI ':standard'; if (!-e blastinfo-test.txt) { # Create blastinfo-test.txt file in not in place open (FILE, blastinfo-test.txt) || die (Cannot open file); flock (FILE, 2); print FILE 0:0:0:0:0:0:0:0:0:0\n0:0:0:0:0:0:0:0:0:0; close (FILE); } #=== # Set and get variables #=== my $pathtolandingpage='../email_blasts/carnival/carnival1.html'; my $pathtodatafile='blastinfo-test.txt'; my @blasts_split; my $ab = param('ab'); my @ab_split = split(/:/, $ab); $ab_split[1]--; #my $anchor = param('anchor'); open (FILE, $pathtodatafile) || die $!; flock (FILE, 2); my @blasts = FILE; close (FILE); if ($ab_split[0] eq 0) { chomp($blasts[0]); @blasts_split = split(/:/, $blasts[0]); $blasts_split[$ab_split[1]]++; $blasts[0] = join(:, @blasts_split).\n; } else { @blasts_split = split(/:/, $blasts[1]); $blasts_split[$ab_split[1]]++; $blasts[1] = join(:, @blasts_split); } # # Write changes back to file # open (FILE, $pathtodatafile) || die (Cannot open file); flock (FILE, 2); print FILE @blasts; close (FILE); # # Send to landing page at correct anchor # print Location: $pathtolandingpage\n\n; exit; --
Re: Flat file being Scrambled
Mark == Mark Wheeler [EMAIL PROTECTED] writes: Mark open (FILE, $pathtodatafile) || die (Cannot open file); Mark flock (FILE, 2); 0wn3d! That's your breakage. Once in a blue mooon, you'll kill your entire data this way. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 merlyn@stonehenge.com URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Re: Flat file being Scrambled
Hi, Sorry, I don't understand. What's my breakage? Should I not use flock? Thanks, Mark Mark open (FILE, $pathtodatafile) || die (Cannot open file); Mark flock (FILE, 2); 0wn3d! That's your breakage. Once in a blue mooon, you'll kill your entire data this way
Re: Flat file being Scrambled
Hey Mark, I doubt any mortal brain could follow all the various permutations of clients hitting your files and trying to lock them while some other client is doing the same. But here's one way your data could get hosed: one client reads the file in between the time another client opened it for writing (thus blowing it away) and locked it. I'd suggest opening the file for both reading *and* writing, and not making any changes to the file until you can get your lock. Keep the file locked for the entire duration you've got the filehandle open. If you want, you can use a shared lock up until you start to write, at which point you can convert to an exclusive lock. How you get your data back, well, that's another matter. I suggest going back in time and using an SQLite or Berkeley DB database to begin with. -Ken On Jun 15, 2005, at 5:49 PM, Mark Wheeler wrote: Hi, Here's a quick question. This doesn't have anything to do with perl on my mac, but just a perl question. I have a a small script that simply increases a number by 1, when it is run, then writes the changes back to the file. I am using it to check how many people come to the site by way of an email. Everything seemed to work fine until I got here this morning and the file was only left with 1 row of 1 number verses 2 rows of 10 numbers each. Here is what the file should look like (The zeros would not necessarily be zeros, but could be any number. 0:0:0:0:0:0:0:0:0:0 0:0:0:0:0:0:0:0:0:0 What I have found is that when I click at a normal pace, everything works fine, BUT... when I click the reload button unmercifully, the data file gets rewritten to look like the following: 0 (or some other number - less then what it was previously) That's it! everything else is gone. Is is possible that if there are so many hits that it can't keep up with the opening and writing of the file? This simple database is potentially being alter by 2 million people, as the email went out to that many people. Any help would be greatly appreciated. Below is the script. Thanks, Mark Wheler Here is the script: -- #!/usr/local/bin/perl -w #=== # format for ab variable in html email: # # control(0)/test(1):week(1-10) # # So 0:5 would be control group, week 5 and 1:9 would be # test group, week 9 #=== use strict; use CGI ':standard'; if (!-e blastinfo-test.txt) { # Create blastinfo-test.txt file in not in place open (FILE, blastinfo-test.txt) || die (Cannot open file); flock (FILE, 2); print FILE 0:0:0:0:0:0:0:0:0:0\n0:0:0:0:0:0:0:0:0:0; close (FILE); } #=== # Set and get variables #=== my $pathtolandingpage='../email_blasts/carnival/carnival1.html'; my $pathtodatafile='blastinfo-test.txt'; my @blasts_split; my $ab = param('ab'); my @ab_split = split(/:/, $ab); $ab_split[1]--; #my $anchor = param('anchor'); open (FILE, $pathtodatafile) || die $!; flock (FILE, 2); my @blasts = FILE; close (FILE); if ($ab_split[0] eq 0) { chomp($blasts[0]); @blasts_split = split(/:/, $blasts[0]); $blasts_split[$ab_split[1]]++; $blasts[0] = join(:, @blasts_split).\n; } else { @blasts_split = split(/:/, $blasts[1]); $blasts_split[$ab_split[1]]++; $blasts[1] = join(:, @blasts_split); } # # Write changes back to file # open (FILE, $pathtodatafile) || die (Cannot open file); flock (FILE, 2); print FILE @blasts; close (FILE); # # Send to landing page at correct anchor # print Location: $pathtolandingpage\n\n; exit; --
Re: Crypt::IDEA problems
--As of Wednesday, June 15, 2005 7:40 PM -0500, Ken Williams is alleged to have said: Don't worry, Apple has solved the Endian problem once and for all with the move to Intel: --As for the rest, it is mine. And if you believe that, I've got some nice land for you in the jungles of Venus. ;) Daniel T. Staal --- This email copyright the author. Unless otherwise noted, you are expressly allowed to retransmit, quote, or otherwise use the contents for non-commercial purposes. This copyright will expire 5 years after the author's death, or in 30 years, whichever is longer, unless such a period is in excess of local copyright law. ---