Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Perl Programming

Perl 5.7.0 Released (Devel Version) 92

qbasicprogrammer writes "The long awaited Perl 5.7.0 version has finally been released! Source code is available from CPAN. If you haven't upgraded yet, now is the time. In related news, development of Perl 6 is continuing swiftly as demonstrated by the Perl 6 Library." Check out the head's up story saying that it was coming - just a reminder this is *devel*. Don't play with it unless you know what you are doing.
This discussion has been archived. No new comments can be posted.

Perl 5.7.0 Released

Comments Filter:
  • by Anonymous Coward
    I can't wait! We need more unreadable cryptic command switches and Idiosyncrasies that some poor programmer will have to inherit from all these Perl code lying around. Keep up the good work!

  • by Anonymous Coward
    I don't go around trying to ram open source down everyone's throats. First off open source which is what Perl is, is probably infected with a virus. Secondly it's PIRACY. Using perl rather than buying software from Microsoft deprives Microsoft the right to make profit. Look at DeCSS. It's only use is piracy of very valuable intellectual property. You folks need to learn to obey the terms of licenses otherwise you're just thieves. And third, only communists and faggots use free software.
  • by Anonymous Coward
    Back in my day, we used to call development releases alphas and betas like "5.0b1". Now you got these 5.6 is good, 5.7 is bad. Even good, odd bad. Sounds like a critique of Star Trek movies. And even worse are these programs that skip ahead... (1.0 is release, 2.0 is development). I guess I can't blame them with Netscape initiating the decline of alphas by calling them Preview Releases... or perhaps companies like id who ship half-finished software as a release and then use the revenue to fund the beta testing.
  • I typed rf -rf / at my C: prompt and nothing happened except that it said that I had a bad command even though I typed exactly what it is you had told me to type and my system doesn't seem to be going any faster so I tried to type it again and it said the command was still a bad file name and now I don't know what to do
  • by Anonymous Coward
    They both rely heavily on outside services and libraries to make them truly useful.
    Not really. Perl is useful all by itself, because it's got more enabled by default. Python's pretty know-nothing,do-nothing on its own. It's also nasty slow at times, especially compared with the more time-tested and speedy Perl.

    If you know, understand, and like C and Unix, then Perl will be a joy. If you're just a DOS-kiddie though, and these are too rough for you, then it probably won't be. The number of Python bigots who are also anti-Unix bigots is astounding.

    Python regular expressions are now as powerful as perl's,
    That's certainly not true at all! Try reading the regex chapter of the new Camel Book whose 3rd edition is incredibly improved over the gnarly old 2nd edition. (Haven't seen a review of it yet here, but I got it anyway.) Perl regexes can do much, much, much more than Python's. The final sections of that chapter are just mind blowing.
    but still not quite so convenient to use.
    That's because Python, being anti-Unix, wasn't designed with regexes in mind; it just has them bolted on to the side, way late in the game. They aren't integrated into the language, since they're latecomers. It's pretty clumsy compared to using them in a language that was designed with regular expressions as a central language primitive, and embarrassing to see them compared.
    A compiled regular expression is a first class object in Python, so you have a lot more control over when and where an expression is recompiled. This lack in perl is a major annoyance of mine.
    Apparently you never learned about the qr/.../ construct. See the new Camel, or the perlop(1) manpage.
    I tend towards the academic mindset. I suspect that people who would rather solve their problem than think about it too hard would vastly prefer perl.
    That's right: Perl is designed to make it easy for anybody to get their job done directly and obviously--without their having to become academics! Perl lets you program the way you think, not vice versa. That's why it will always be dissed by the poofy academics, but incredibly useful in the real world. Python, however, expects you to conform to One True Way, which may not be the way you think, in which case you're out of luck.
  • by Anonymous Coward
    Sorry, but this automatic cheerleading/bashing by the Python freaks just because Perl gets mentioned is just as annoying as the automatic cheerleading/bashing that happens by the {BSD,Linux} folks everytime {Linux,BSD} gets mentioned. (Yes, it goes both ways.) Can't you just stay on topic and wait for your own {Perl,Python,Linux,BSD,whatever} thread instead of dragging your pet little obsession in front of the public every damn time?
  • What's wrong with it? It's a devel version - it says as much in the story.
  • I just picked up some somewhat juicy information this week. Did you guys know that M$ uses Perl in their source code management system for W2K?

    I got a call from an M$ recruiter this week for a Perl position there. The fact that my resume said "UNIX/Linux developer" and that I said on the phone I really wanted to work with Linux didn't seem to deter him. He went on and on about how great it would be to work for M$, and talked like Gates and Ballmer themselves, saying things like "Windows 2000 and other great products."

    Then I get that juicy nugget. Those guys are too smart to use their own products on things that REALLY matter. :-)
  • No; in both cases, I wrote code for it that did not contain 'sort | uniq -c'. :)

    This was our first assignment for the Operating Systems course I'm taking, CSC451. The goal is to get people up-to-speed in C.

    However, once you have this program written, it's easy to hack in some tokenizing code, and get, say, each instance of a word. (or you could run something like "tr ' ' '/n'" and just cheat again. ;)

    Also, implementing it together allows for speed improvements; by definition in the command 'sort | uniq -c', sort has to sort the whole input stream, and then uniq deletes the duplicates. This approach is algorithmically slower than only adding the unique elements and maintaining a count, and I wrote this approach in Perl and C. In Perl, it is impelemented with hashes, and is about 7 lines long.

    #!/usr/local/bin/perl
    while(<>) {
    $index{$_}++;
    }
    foreach $word (sort keys(%index)) {
    print "$index{$word}: $word";
    }


    The C version uses a simple binary tree structure with a reference count, and is slightly under 50 lines long. This is because, besides the simple tree code, I also have to dynamically allocate the strings to read them in up to the newline and whatnot...
    ---
    pb Reply or e-mail; don't vaguely moderate [ncsu.edu].
  • I was writing a program for the class.

    Do you know what the program was called?

    That's right, 'sortuniq'.

    I had already written similar code in Perl, though, while analyzing data for a simple Markov chain text hack, so I figured I'd compare the two.

    Slashdot poster diverts attention from the on-topic Perl/C comparison.
    ---
    pb Reply or e-mail; don't vaguely moderate [ncsu.edu].
  • Well, the idea behind Perl is a little bit different; it has too many decently implemented features to just be a scripting language, no matter how some people use it. It's humble, too--although it has the few useful features of Java, (packages and object-orientation, at least) it doesn't take the NIH approach and pointlessly rename everything like Java does. :)

    I like C, too; because Perl is generally interpreted, and because of some of the features it has now, writing your average C-looking code in Perl isn't worth it--it'll be up to 10 times slower. However, writing code that takes advantage of Perl's features will perform much better, and can be expressed in much fewer (and easier to read) lines of code.

    Examples:
    - Being able to use a hash for quick lookup, or as an arbitrary name-space is really handy.
    - A reference to a sub-routine functions as a closure, not as a function pointer; without this, functional programming can be more difficult to do... :)
    - Arrays are readily growable, and can function as a stack, or other linear data structure.
    - Extra types, like arbitrary-precision number routines, are readily available.
    - CGI and database programming is ridiculously easy to do.

    Finally, I wrote a program that takes arbitrary input line-by-line, and outputs sorted unique lines with a count of how many of each line it found. It took me 7 lines of Perl code, (counting the comment to run the Perl interpreter :) and 50 lines of C.

    The C approach dynamically grows the strings as needed, and using a dynamic array of pointers and qsort takes up a little bit more code than using a binary tree with a reference count, but they are both around 50 lines of code.

    I haven't tested the two of them against each other yet, but the Perl code should be faster in general, for big files, because the built-in hash routines are algorithmically superior. (i.e. I don't think they have a worst-case of Order-n-squared...)

    So, yes, a place for everything, and everything in its place. There are many times when Perl is the right tool for the job, and C isn't. I wouldn't write an Operating System Kernel in Perl unless I could make a *really* optimized compiler for it, but for many other tasks it's a much better choice. Besides, if you *need* to write something in C, you still *can*. And if you still don't like it, well, you can write a better language in C, just like they wrote Perl. :)
    ---
    pb Reply or e-mail; don't vaguely moderate [ncsu.edu].
  • It's true that it's difficult to do much without creating an object at some point. However, you can do quite a lot of useful work in Python without understanding the OO model, inheritance, or any of those concepts. To me, the difference between C's "file = fopen(...); fread(file, ...)" and Python's "file = open(...) ; file.read(...)" is simply a matter of syntactic sugar. But you don't need to subclass some generic file class in order to create a file that's unbuffered, or is for writing instead of reading. Java's I/O library seems far more OO to me, in that you have to instantiate the right StreamWriter/Reader class.
  • Note, however, that having regexes as an add-on module means they can be dropped if you don't need them, such as if your interest is in wrapping numeric code or using it as an embedded language. This is why there's already an early version of Python for PalmOS [uci.edu], while Perl for PalmOS doesn't seem to exist yet.

    And calling python "academic", as if that's a term of derision, is simply silly. It's not a language that has attempted to create new ideas in programming languages; it simply starts with different design principles and, unsurprisingly, ends up in a different place. See Tim Peters's "19 Pythonic Theses" for a (retroactively coined) list of principles.

  • Yeah, how DARE the GUY WHO RELEASED THE SOFTWARE warn people NOT TO USE IT without knowing exactly what they are doing, to counteract the original submissions saying "go upgrade now." Little wanker.
  • Slash (and Slashdot) runs on perl 5.005_03. It may run fine on perl 5.6. The current development branch of Slash, bender, is going to be tested on perl 5.6. We may upgrade Slashdot to perl 5.6 someday if it proves stable, or we might wait for perl 5.8.
  • BTW, I meant to add that I've run perl 5.6 on a machine with Slash and saw no problems.
  • So, no Unicode on the principle of 'be fast, not correct'? The future, for better or worse, is Unicode, because that's the only way to cleanly handle the world's languages, short of coding in ISO2022, SJIS, ISO8859-* and more. I think that would slow a text parser down much more than Unicode would.
  • Really? That's funny - I know a lot of people who 'got into Perl' by reading those books... Myself included.

    Someone has to write good documentation and tutorials. Without it, not as many people would learn the language.


    - Jeff A. Campbell
    - VelociNews (http://www.velocinews.com [velocinews.com])
  • Why should they? They've already given a lot back to the people who developed Perl by helping immensely in the spread of the language. This allows the coders to spend less time worrying about documentation and more time coding.

    I haven't exactly seen Larry Wall or anyone else complaining about it - it would appear they are at worst neutral on the issue, and quite likely very appreciative. Wall in particular seems to be above jealousy over someone else *gasp* making money by writing about Perl.


    - Jeff A. Campbell
    - VelociNews (http://www.velocinews.com [velocinews.com])
  • Check it use beat it up purge it system out of bugs

    This a a quote from the perl site for thsoe who do not read the links

    "Check that your favorite patch is in, check that your favourite module still
    works, check that it still works on your favourite platform. Yes, I know it's a
    development release, but I still would prefer not to wreak havoc more than
    necessary," he said.
  • The roadmap chosen is to have 5.7.0 come out, and then take out the risky bits and call the result 5.6.1. So that should be arriving, probably within the month.

    At the moment here are recent releases in terms of my trust for them:

    5.005_03
    5.7.0
    5.6.0

    Why?

    Because there are a number of significant bugs in 5.6.0 that are fixed in 5.7.0. The worst of which IMO is this:

    perl -e 'my $x = 10; $x = "2" . $x; print $x + 0'

    (In 5.6.0 prints "10".)

    Cheers,
    Ben
  • Finally, I wrote a program that takes arbitrary input line-by-line, and outputs sorted unique lines with a count of how many of each line it found. It took me 7 lines of Perl code, (counting the comment to run the Perl interpreter :) and 50 lines of C.

    Ah, you mean like 'sort | uniq -c'? :)

    Still, Perl is very nice when your problem doesn't neatly fit the Unix tools approach, e.g. multiple-line records or whatever.

  • The projected public alpha's for TPC 5.0, which is in July 2001, and I don't see any reason we won't make it. We were shooting for the first full release to be about 18 months after the initial decision to do perl 6, which puts it in early 2002.
  • If you know, understand, and like C and Unix, then Perl will be a joy. If you're just a DOS-kiddie though, and these are too rough for you, then it probably won't be. The number of Python bigots who are also anti-Unix bigots is astounding.

    *shrug* I've been using Unix for over 12 years now, and have been an avid C programmer for even longer. I tend to use C++ nowadays, but C is still fine with me. This is an ad hominem attack that I hesitate to dignify with a response, and only do so out of a desire to prevent this from being a factor in your mind when you read what I have to say.

    That's because Python, being anti-Unix, wasn't designed with regexes in mind; it just has them bolted on to the side, way late in the game. They aren't integrated into the language, since they're latecomers. It's pretty clumsy compared to using them in a language that was
    designed with regular expressions as a central language primitive, and embarrassing to see them compared.

    It isn't so much that they're an afterthought as they are just not an integral part of the language.

    Apparently you never learned about the qr/.../ construct. See the new Camel, or the perlop(1) manpage.

    No, I haven't learned about that construct. As you point out, it seems to be relatively new. I've known and used perl since before 4.035. It will be nice if this solves my annoyance.

    I tend towards the academic mindset. I suspect that people who would rather solve their problem than think about it too hard would vastly prefer perl.
    That's right: Perl is designed to make it easy for anybody to get their job done directly and obviously--without their having to become academics! Perl lets you program the way you think, not vice versa. That's why it will always be dissed by the poofy academics, but incredibly useful in the real world. Python, however, expects you to conform to One True Way, which may not be the way you think, in which case you're out of luck.

    My comment was meant to point out the disadvantages of both sides. Doing things without thinking about them first yields programs that do stuff, but become crufty and hard to maintain over time. The perl I've seen being used in the field or downloaded from CPAN fits this description well. Often such programs written in languages other than perl become cleaner as time and programmers wear away the rough edges. I don't believe perl has the necessary support for allowing this to happen.

    Python does let you get things done quickly. I wrote a program to connect to an IMAP server and filter out all the ILOVEYOU messages in about 0.5 hours. But when you have something big (or has become bigger than expected) that you have to plan, the tools are there to do that too.

  • perl and Python are in competition for a few reasons:

    1. As someone else said, they are both high level interpreted languages
    2. They both rely heavily on outside services and libraries to make them truly useful.

    Now, if they were both the same, there would be no point in them competing. perl and Python differ in several important ways:

    1. Python uses whitespace as a block delimeter. This does force code to have some marginal level of readability, which is nice. The loss of freedom this entails is very occasionally annoying.
    2. Python was designed from the beginning to have modules, and an eye towards object orientation. The namespace rules in Python are consequently much more regular and easier to understand.
    3. Perl was designed as a replacement for complex shell scripting, and if your habits come from this kind of background, it fits much more easily into how you work than Python.
    4. Python has simply amazing (reminiscent of lisp) reflection capabilities. Perl has them, but they are arcane and difficult to use and understand.

    Python regular expressions are now as powerful as perl's, but still not quite so convenient to use. A compiled regular expression is a first class object in Python, so you have a lot more control over when and where an expression is recompiled. This lack in perl is a major annoyance of mine.

    I actually see Python as a viable (and desirable) replacement for perl in most instances. Of course, I tend towards the academic mindset. I suspect that people who would rather solve their problem than think about it too hard would vastly prefer perl.

  • From the perl 6 roadmap [infotrope.net], it looks like it'll be around this time next year. But those last couple bullets are just big "????"s.
  • The list of RFCs for Perl 6 [perl.org] is pretty long. The changes look like they address a lot of the problems people have had with Perl. But how compatible is Perl 6 going to be with Perl 5? Will most packages/scripts need to be rewritten? Will the C extensions of Perl 5 need to be rewritten? I didn't see anything in the Perl 6 materials on the site that answered these questions (but maybe Larry addressed it in his speech).
  • Perl is now following a release style similar to Linux - even numbered releases are 'production' releases

    Hmm, sounds like the development branch only just started, in that case.

    "What a waste it is to lose one's mind. Or not to have a mind is being very wasteful. How true that is"

  • Perl on windows is the only way to tame that ugly beast. I use scripts based on the ORA book "ntws management", and they finally bring some manageability to the platform. Using the scheduler, you can run self maintaining "stub" scripts that simply grab a task list, check for updates, and then run. Perls strengths on win32 are registry hacking, and unc support. I support 40 workstations (not much) with 75 engineering applications on each one (whoah!), and rarely have to visit them. It has, quite simply, freed me from the drudgery of windows maintenance.
  • That's funny.
    On my NT, click on Start, Help, NT Commands, and there is ftp. Click on Start, Programs, Accessories, and there is telnet. Of course being Microsoft, they are inferior to the unix commands.
  • The story was changed, but the fact that it was updated was not marked. So this comment isn't really redundant exactly. It is NOW, but wasn't when it was written.
  • Java is *100%* backwards compatible with older versions. New Java versions introduce HUGE amounts of new stuff - 1.2 did so in particular, but never has backwards compatibility been broken. Sure large API changes have been made in some areas, but the old API's still exist and are only marked as deprecated - not removed.
  • i'm just not sure where the function is or what its named... ;p but there is a way, and i'm fairly sure its part of the standard python libraries. the people on #python either don't know either, or arn't telling me anything... so it goes.
  • I'm not disagreeing with your post in general, but I do have a question. How is the whole of the language object orientated? Sure, the object orientation is a big part of it, but it's in no way necessary to writing a program, even a complex one.

    Really? Somehow it seems like it would be difficult to write a Python program of any kind without going through an object. Filehandles, for instance, are by definition objects, so you would be hard pressed to get any input or output. I also find it difficult to imagine a program of any complexity that didn't go through the sys. or os. hierarchies.

    That aside, it was my understanding back when I was working with Python on a regular basis that objects underlie everything in Python, whether or not you use their object-ness in your programs. I've never considered myself a Python guru so I'll leave it to others to explain this better, or perhaps, tell me how full of it I am. My main point still stands, though. In Perl you can write programs all day, every day and never come near an object or OO behavior. In Python this would be difficult at best.
    --
  • Perhaps it depends on how your mind works. Python is a highly disciplined language where in general there is One True Way. It's very easy to read. The object-oriented features of Python are more deeply embedded than those of Perl (read: the whole blippin' language is object oriented). And of course it's an excellent language for beginning programmers.

    If Python points to the One True Way, Perl points to All Of The Many True Ways. It doesn't impose its structure on you. This can be bad if your mind demands structure; it's good if, like mine, your mind is completely unstructured (some might say "loosely hinged") but you occasionally want to impose structore onto it -- though only if you have to, not because the language demands it. What with the regular expressions and variable designators ($%@ and their friends) Perl is occasionally compared to "executable line noise." This bothers some people, although considering that my first language used variables like B! and X$ and U#, it doesn't bother me. The OO features of Perl are easier to avoid than Python's if you don't want to use them. And of course, it's an excellent language for beginning programmers.

    Python might be a better choice for writing large programs that are going to require a lot of maintenance, or that will someday be moved over to C. Perl definitely shines in the areas of system maintenance, quick one-off scripts and one-liners. One-liners in particular are impossible in Python because of its use of whitespace and newlines as delimiters, although Python's interactive mode is much better than Perl's. Both are good for rapid prototyping.

    I would say check 'em both out and use whichever one suits you. I tend to prefer Perl, but that's just because it works the way my mind works. YMMV (Your mind may vary).
    --
  • Thats sad, Debian doesn't even have 5.6 debs yet :(

  • *SIGH*

    Please keep on reading those release notes... Perl 5.7.0 does NOT have "full Unicode support". It has some Unicode bugs fixed compared to 5.6.0, but that's it.



    --
    jhi@iki.fi

  • by jhi ( 65075 ) on Sunday September 03, 2000 @05:21PM (#807494)
    Hi,

    this is the Perl patch pumpking (release wrangler, if you will) speaking. Please read the announcement letter carefully. The bottom line: you should NOT install 5.7.0 into production use. Unless you know who are the perl5-porters, what is perlbug, and preferably, how to pronounce my name :-) you should not even think about installing 5.7.0.



    --
    jhi@iki.fi


  • Hash lookup takes a constant amount of time, O(1), ...


    Open hashes are O(k + m) where k is the length of the string (which is almost always miniscule, though the overhead is pretty large), and m is the size of the linked list, which is generated from overlapping mappings of keys.

    Perl allows you to view the statistics as follows:
    $num_elements = keys %hash;
    $used_and_free_cells = %hash; # "used_cells/total_cells"

    An important problem with hashes is that when you get full you have to rehash. This has an incredible cost (much more than simply copying out an array to a new larger spot in memory). If you never rehash, but you keep growing your data, then your linked lists will grow so large that m will approach n. An alternative solution would be to use a tree instead of a linked-list. But for larger data-sets, this defeats the purpose of hashes.

  • This [Perls use of braces //A] naturally leads to errors where the indentation (highly visible) is correct but a brace is missing or extra. Python lets the visible thing (indentation) take on the syntactic role.

    It isn't very easy to miss a brace - if you miss a brace, the code is unlikely to compile. Of course, you might misplace a brace, but you might as easily misplace whitespace. And given that people tend to indent their code, in Perl you would actually have to misindent *and* misplace the brace to make an error that isn't bloody obvious from staring at the code 40 feet away. So.... you might as well say that in Perl, the purpose of the braces is to see whether you indented right. ;-)

    Last time I checked, Python's regular expressions were inferior to Perl's in speed, ease of notation, and power/comprehensiveness.

    It has been a while ago that Python copied Perl's regexes, so the ease of notation argument doesn't hold. Nor does the power/comprehensiveness argument.

    I program a lot in Perl and never in Python.

    From the code I often see, I would say than more than half of the people programming in Perl would have been better off if they never had programmed in Perl but used Python instead.

    -- Abigail

  • who are the perl5-porters

    It's the bunch of freaks and geeks meeting at Larry's for tea every Tuesday afternoon.

    what is perlbug

    That's the Beetle (with flower power decorations) donated to Larry by a certain German car maker.

    how to pronounce my name

    That's easy. It's Finnish, so you just have to pronounce it the way it's written.

    -- Abigail

  • That's of course 6 lines too long. Such a trivial thing is a one liner:

    perl -wne '$_ {$_}++; END {print "$_{$_}: $_" for sort keys %_}'

    And you are right. You only have to add a tiny bit of code to do it for each word.

    perl -nalwe '$_ {$_} ++ for @F; END {print "$_{$_}: $_" for sort keys %_}'

    -- Abigail

  • by nconway ( 86640 ) on Sunday September 03, 2000 @05:01PM (#807499)
    Since no one has commented on this yet: this is a development release! It is not intended for public consumption. It *probably* breaks lots of stuff. Don't run this anywhere your job is on the line.

    As was announced with Perl 5.6.0, Perl is now following a release style similar to Linux - even numbered releases are 'production' releases (e.g. 5.6.x, 5.8.x, 5.10.x), odd numbered releases are 'development' releases (5.7.x, 5.9.x, etc).

    I haven't checked out the change summary yet - I wonder what's been improved. My personal hope is the Perl compiler (B::C, B::CC, etc). Neat stuff!

  • absolutely no thought whatsoever went into editing it.

    No, then it wouldn't be a quote from the story poster. It IS a good addendum warning about the status of the release. The story goes a little something like this:

    Perl 5.7.0 Released (Devel Version) [slashdot.org] Posted by Hemos [hemos.net] on 07:51 PM -- Sunday September 03 2000
    from the makin'-time-with-the-camel dept.
    qbasicprogrammer [mailto] writes "The long awaited Perl 5.7.0 version has finally been released! Source code is available from CPAN [cpan.org]. If you haven't upgraded yet, now is the time. In related news, development of Perl 6 [perl.org] is continuing swiftly as demonstrated by the Perl 6 Library [perl.org]." Check out the head's up [perl.org] story saying that it was coming - just a reminder this is *devel*. Don't play with it unless you know what you are doing.

    Note, the stuff in italics is a quote from the story poster and the addendum on the bottom talking about it being *devel* is Hemos being a good journalist, actuarially quoting the story poster in it's entirety and informing the reader with a stern warning in the headline and the tagline.

    If you want stuffy editors filtering your content, goto the nytimes. This is /. it ain't all right but it's allright.

  • by Money__ ( 87045 ) on Sunday September 03, 2000 @05:55PM (#807502)
    Larry Wall speeks [technetcast.com] at Dr. Dobbs about PERL6.
  • I really don't care what people like to code in, it's a very personal choice and I enjoy the existence of lots of competing languages. By all means, if you like Python, excelsior. I've always avoided the Language Wars.

    But Crucini touches on a point near and dear to my heart: the intimate relationship between Regular Expressions and PERL. Sure, other languages support REGEX matching. Maybe even faster, who cares (oh god, don't start). But no other language I've used includes REGEX matching in the very structure of the language.

    Sure, I can write PHP or Python code to find and process all the URLs in a page. Of course. But (I think) only Perl let's me write an actual WHILE loop iterating over them. IE, in most languages, I write a standard control loop which grabs each (say) line in a file. I take that line, call a REGEX function on it; if I find a URL, I do something, then move on to the next. In, I can literally say: "for each thing that looks like http://(whatever), do with it."

    ...of course, the result is the same. But there's something very elegant (to me, or course) about being able to iterate over PATTERNS, not line numbers or file pointers. It's COOL, damnit!

    Purely a subjective preference, I know Python and PHP do a lot of things very nicely too. Enough disclaimers?
  • by crucini ( 98210 ) on Sunday September 03, 2000 @08:49PM (#807504)
    I agree that it's silly to evade language comparisons with the excuse that they're not directly comparable. Perl and Python are similar enough to invite comparison. They are both high-level interpreted (effectively) languages. Here are the main differences as I see them:
    1. Python uses indentation as punctuation. This could be great or terrible. Look at it this way - if you write perl per `perldoc perlstyle` you're describing block structures twice - once with indentation level, and once with braces. This naturally leads to errors where the indentation (highly visible) is correct but a brace is missing or extra. Python lets the visible thing (indentation) take on the syntactic role. The downside, if any, is that you lose the freedom to indent code however you want.
    2. Python is believed to have better object-orientation than Perl. Since I don't have the OO religion, this makes very little impression on me.
    3. Python is purist/academic in flavor, while Perl is eclectic/pragmatic. Perl's power is strongly tied to its mixed ancestry. Perl basically swallowed C, shell, and either sed or awk.
    4. Last time I checked, Python's regular expressions were inferior to Perl's in speed, ease of notation, and power/comprehensiveness. This may not be true anymore.
    In case it's not obvious, I'm a bit biased towards Perl. I program a lot in Perl and never in Python. The one place I can imagine Python being superior is a largish team of newbie programmers. The enforced indentation would help ensure uniformity of style, and the bias towards object orientation might encourage modular and reusable code.
  • (Yet more new software I can't use.)

    This is great for using at home, but how many organizations are going to run out and install this on their production servers? I think most would refuse to upgrade a working system because of the threats (real and imagined) of old scripts breaking. "It works now, why upgrade?" Perl seems to be the type of thing that the admins install when setting up the box, and never touch again.

    I don't think that any changes/improvements in the language are drastic enough to warrant it anyway. It's not like the difference between Java pre-1.1.8. and Java 1.2. Perl 6, OTOH, will probably be worth the effort, but there still looms the problem of backwards-compatibility...

    Has anything interesting happened yet re: Perl 6 and UNICODE? IMNSHO UNICODE should not be a standard feature in a language which does so much text parsing. I'm worried about performance.

    ---------///----------
    All generalizations are false.

  • PS - Yes, I know it's a development release. I can't use 5.6 either. I'd consider myself lucky to be able to use 5.4... stupid employers...

    ---------///----------
    All generalizations are false.

  • That was my point -- Java 2 was revolutionary, and Perl 5.7 is not.

    ---------///----------
    All generalizations are false.

  • What's the eta on Perl 6?
  • Damn, i really need coffee. I read 'evil' instead of 'devel':

    just a reminder this is *evil*. Don't play with it unless you know what you are doing.
  • This morning I was looking at my bookshelf full of old PERL v4 O'Reilly books, thinking "Gee what am I going to do with that now?" since I bought twice as much perl v5.00 books over time. Now Slashdot announced last week that a new set of books are out, re-edited for version 5.6 and PERL 6.0 has just been announced.

    The morale of the story: Don't buy the new books, boycott PERL 5.6!! (he he he... sounds nuts, but it makes perfect market sense)
  • Is the slashdot crew responsible for anything then? If thats the case then I want a nice paying job with these guys where I can toss up any old cruft that I find.

    Question: Does the slashdot crew actually Read the submission before hand ? Some of this stuff is ridiculous, if they did read this one, absolutely no thought whatsoever went into editing it.
  • Okay, next time somebody says "rf -rf / will make your system faster " in a story, please make sure its in Italics and quoted...

    and the warning was added aftwards.. the thing here is, from the looks of it, Hemo's doesn't bother to read the story, just looks where quotes should begin and end, then write some fluff to make it official... Ya, Thats really good journalism.. I'm sorry that doesn't make a person a journalist, otherwise I'd be one, despite this run-on sentence.
  • >What's wrong with it? It's a devel version - it says as much in the story.

    It also says "If you haven't upgraded yet, now is the time." - irresponsible, since it may lead folks to download and install a potentially VERY unstable release.
  • Yeah. Perl6 is supposed to be about 18 months away, when it will be available in early but stable alpha. Seeing, however, as some of the objectives for the "shame dates" haven't yet been made (overdue for a month, some of them), I'd suspect that the project will, as all of them tend to do, take a little longer than initially projected.

    And as for radical changes: I'm expecting some, but nothing truly off-the-wall (RFC to toss out @% was retracted, etc.) You can see the ones that have been frozen so far as well as the ones that have been retracted here [perl.org].
    That said, I've seen some really cool stuff in the RFCs, regarding things like higher-order functions and co-routines. It's been my experience that Perl has always managed to take complicated computer-science concepts and make them into incredibly powerful yet easy-to-use features that even a newbie can understand, and I'm personally very excited to see a lot of RFC suggestions for more functional-oriented programming styles (and of course, as always, for improvement in the object-oriented side of Perl).

    Of course, Rule 1 continues to apply. :-)

  • Python is believed to have better object-orientation than Perl. Since I don't have the OO religion, this makes very little impression on me.

    After reading Dr. Conway's _Object Oriented Perl_, I'd tend to agree with Python having 'better object-orientation.' But this isn't due by any means to features, but rather to standardization:

    the Python OO model is standardized enough that you don't have to roll your own, and also includes quite a few gee-whiz features like being able to replace methods at runtime, I believe. This leads to good object interoperability, and likely superior speed since OO _is_ somewhat less of a hack.

    Perl is a lot less standardized, but equivalent at least in power. With the above example of subroutine replacement at runtime, this could be achieved by designing the class so that all methods are called through subroutine refs, and then just assigning to that subref for a new method.

    The main problem that I see with Perl OO right now is the non-interoperability that is achieved when everyone rolls their own. The power is definitely amazing, but the ease-of-use between modules is fairly low. I believe that someone might even have a Perl6 RFC or two written up about this?

  • Has anyone tried using the windoze versions of perl....nope thought if you're gonna use perl get a *nix. Seriously though if you're stuck with an NT boxen at work, you'll find some perl scripts refuse to work with windows as its implementation is not completely compatible. (I know the rant if you're gonna use a toy os you're asking for it...blame my boss for that, I'd rather use a PDP than NT)
  • Noooo..
    I had just finished downloading perl 5.6!!!!
    :-)

  • by Ars-Fartsica ( 166957 ) on Sunday September 03, 2000 @05:37PM (#807519)
    Take a look at the mailing list [perl.org] traffic (which is so overwhelming that people holding full-time jobs cannot hope to follow).

    Its pretty obvious that no one really knows yet what perl6 is going to be.

    Some factions are gunning for radical changes, others (notably Tom Christiansen) seem to be holding a conservative stance.

    One thig is certain - perl6 is not coming in any form anytime soon. Try 2002.

  • I shouldn't have ignored my threshold setting. But now I have to ask, what is your problem? Someone please moderate the coward's post to -1.

  • More Information on Perl [perl.com] and Python [python.org].

  • I'm telling you.

    Scripts that'll only work on 4, scripts that'll only work on 5.001, scripts that'll only work on 5.003 and all of the required versions installed on the same box at the same time.

    Sure the script developers should upgrade their scripts but do they hell.

  • Wow... I didn't even know python was still around. Thanks! Really... I'm on a "learn new languages" kick so I'm gonna seriously check it out. :-)
  • ``Finally, I can start.. err.. learning. (goes and sits in stupid corner..)''

    No biggie. Everyone's gotta start sometime. Hell, I'm learning new languages every day and I've been hacking [tuxedo.org] for years.

    Anyway, good luck. Just remember to always check your input!!! Especially with languages like Perl that have a knack of making your hard drive world readable. (yeah, I've done it ... goes and sits next to ya in the stupid corner...) ;-)
  • Hopefully it'll help speed up certain unnamed (*cough* /. [slashdot.org] ) perl generated sites. ;-)
  • Can't help but sense the hostility from the multiple posts given to what you seem to believe is a social injustice.

    I have to say anyone with half a brain, who is in charge of doing the upgrades for PERL in their production environment would also be bright enough to catch the DEVEL in the title of the article, or if worse came to worse, would read the notes regarding the fact that this is a Development Release and not for production.

    Alas, a more savvy 'journalist' would have edited the original statement, but at some point in time you have to assume the audience has a base intelligence in regards to the subject matter. Anyone who believes a random report to make business decisions will always end up with the short end of the stick.

  • WOO HOO!! looks like its time to go download perl again.

    ~j0sh

    C:\ is the root of all evil
  • what the fuck is your problem? I think it is nice for once to warned not to install as it is a development release. Too many people have the habit of just rushing out and installing the latest whatever and totaly screwing up their systems.
  • For a few rare systems, perl did not like to install.. with the new release though, I'm lucky.

    Finally, I can start.. err.. learning. (goes and sits in stupid corner..)
  • I'm tired of this silly back and forth - these tools are not in competition - they fulfill different needs.
    This is an honest question, albeit one that demonstrates my ignorance :), and not a troll. Why are Perl and Python not in competition? What are the different needs that they fulfill? What does Perl do that Python doesn't, and vice versa? What does Python do better than Perl, and vice versa?

    My purpose is NOT to start a religious war, but to honestly learn which to work with.

  • the built-in hash routines are algorithmically superior. (i.e. I don't think they have a worst-case of Order-n-squared...)
    Close. Hash lookup takes a constant amount of time, O(1), as explained in Uri Guttman's and Larry Rosler's article A Fresh Look at Efficient Perl Sorting [hp.com]. For more information on algorithmic efficiency of Perl's builtins, see Shift, Pop, Unshift, and Push with Impunity! [perlmonks.org].


  • When will ActivePerl be updated ?

    What's new in Perl 5.7 ?

  • The object-oriented features of Python are more deeply embedded than those of Perl (read: the whole blippin' language is object oriented).

    I'm not disagreeing with your post in general, but I do have a question. How is the whole of the language object orientated? Sure, the object orientation is a big part of it, but it's in no way necessary to writing a program, even a complex one.

  • Filehandles, for instance, are by definition objects, so you would be hard pressed to get any input or output. I also find it difficult to imagine a program of any complexity that didn't go through the sys. or os. hierarchies.

    Okay, point conceded in that sense :) I wasn't thinking about the way modules, namespaces and files are treated as objects.

    That aside, it was my understanding back when I was working with Python on a regular basis that objects underlie everything in Python, whether or not you use their object-ness in your programs.

    See here [python.org] for more info - function objects, code objects, type objects, stack frame objects, traceback objects etc. etc. They're not really visible unless you're trying to use them though.

    But on closer inspection, I see what you meant :)

  • Re:Short answer: not anytime soon (Score:0)
    by Anonymous Coward on Monday September 04, @08:10AM EDT (#156)

    Finally, I wrote a program that takes arbitrary input line-by-line, and outputs sorted unique lines with a count of how many of each line it found. It took me 7 lines of Perl code, (counting the comment to run the Perl interpreter :) and 50 lines of C.
    One line of shell :

    sort | uniq -c

    Perl diverts attention from the power of the basic UNIX commands.

    [ Reply to This | Parent ]

    Re:Short answer: not anytime soon (Score:0)
    by Anonymous Coward on Monday September 04, @10:03AM EDT (#166)

    Perl is available for multiple platforms. Not all of us use a *NIX.

    [ Reply to This | Parent ]

    Re:Short answer: not anytime soon (Score:0)
    by Anonymous Coward on Monday September 04, @11:29AM EDT (#174)

    That seems to work fine on my 98 box.

    [ Reply to This | Parent ]

    Re:Short answer: not anytime soon (Score:0)
    by Anonymous Coward on Monday September 04, @10:22AM EDT (#170)

    Nitpick: You can use temporary files instead of pipes but what OS capable of running perl cant run a few necessary utility programs such as sort, etc?

    According to the mpaa they are criminals (Score:0)
    by Anonymous Coward on Sunday September 03, @10:13PM EDT (#18)

    They have no repect for copyrights. Its time that active perl stood up to Larry Wall for copying there work. Linux is a clone of unix designed to pirate and mae illegal copies of unix. Don't believe me? Just look at unix and then linux. THey look identical. Still don't believe me? Look what ftp is for. And if that wasn't bad enough look at the cracking utility called telnet. Its sole purpose is to break into other systems and run commands from them. If thats not proof that open source is evil then I do not know what is. Poor Ken THompson. I am sure he is dirt poor now. You can not run remote apps and commands from NT so at least we know for a fact that its legit.

    [ Reply to This | Parent ]

    Re:According to the mpaa they are criminals (Score:0, Troll)
    by grav.2k (daflos@netscape.net) on Monday September 04, @08:06AM EDT (#154)
    (User #117775 Info)
    I am sure you have read everything there is to know about the GNU project on http://www.gnu.org?
    you have read the history of GNU and what it was for?
    obvioulsy not. what you say is sullbhit. "they look identical"... what you refer to as 'linux' is the gnu/linux project, with linux as only ther kernel, and everything there is was built from scratch.
    commands and programs were written from scratch. you know why? go and read there, gnu was founded because there was no freedom for users and developers useing commercial things like unix then, back in the eighties.
    they have built everything theirselves.
    and AFIAK NT has telnet and ftp as well as W9x. dos got em too (not sure about telnet, didnt have much access to the internet when is used dos).
    so why are you talking shit? copyrights? i've never seen a copyright violated in 'gnu/linux' they called it gnu and linux, and not UNIX, and the ftp and telnet commands arent really copyrighted, they have been with 'modern' OS's forever...or wouldnt NT and everything windows be violeting copyright too?

    And which parallel universe did you crawl out of?

    Re:ActivePerl update? (Score:0)
    by Anonymous Coward on Monday September 04, @01:38AM EDT (#107)

    Your slashdot user name crashes my browser; please change it to a defined region of memory, or refrain from de-referencing it.

    Thank you.

    [ Reply to This | Parent ]

    Re:ActivePerl update? (Score:0)
    by Anonymous Coward on Monday September 04, @04:12AM EDT (#140)

    He doesn't dereference it, he casts it fool. It won't crash anything. I would suggest you're thinking about:
    *((void*)0x00000000UL)
    but that would imply that you have a clue.

    Re:Development release! (Score:0)
    by madmooer on Monday September 04, @01:30AM EDT (#104)
    (User #226123 Info)
    (206 * 256 * 256 * 256) + (251 * 256 * 256) + (12 * 256) + (78) = 3472559182, duh!

    z gkort. /ds glkikmg fg/gtjyt ikbylo zza fgw4rqeew btojy7ulnm.

    Re:Development release! (Score:0)
    by Anonymous Coward on Monday September 04, @02:07AM EDT (#114)

    In human terms.

    An IP address, as normally written in dot decimal format, is seen as a collection of 4 numbers seperated by decimals, e.g., 121.157.198.12

    An IP address isn't really stored in a computer that way, of course. Dot decimal format is a convention that is used for human benefit. Computers actually store an IP address in a 32 bit (at least) numeric field. Each of the 4 numbers in the dot decimal format are mapped to 8 bits (octets) of the 32 bit numeric field.

    Using our example number, 121.157.198.12, 121 maps to the first octet (high order bits), 157 maps to the next octet, 198 the next octet and 12 to the last octet (low order bits).

    Therefore the compute would see that particular address in memory as:

    01111001 10011101 11000110 00001100

    Try it with some of your favorite websites!

    great more Indecipherable commands (Score:0)
    by Anonymous Coward on Sunday September 03, @10:06PM EDT (#13)

    I can't wait! We need more unreadable cryptic command switches and Idiosyncrasies that some poor programmer will have to inherit from all these Perl code lying around. Keep up the good work!

    Re:Simple solution - don't use it (Score:0)
    by Anonymous Coward on Monday September 04, @01:09PM EDT (#186)

    If you know, understand, and like C and Unix, then Perl will be a joy. If you're just a DOS-kiddie though, and these are too rough for you, then it probably won't be. The number of Python bigots who are also anti-Unix bigots is astounding.
    I think you're plain wrong on that point. I'm an Unix expert (using Linux since 1993, at work and at home), I know pretty well C, and C++, and no Perl has never been a joy. I first tested Tcl, but it was too broken for words, you couldn't just do a simple addition simply. I then tried Perl, but it is wildly weird (in the sense of there is a whole bunch of stupid traps that are could be completly avoided without harming the language at all). Then I tried Python, and it was a real relief. So stop the "DOS-kiddie" argument, I could equaly well talk about "Linux zealots newbies who can't program at large".

    That's right: Perl is designed to make it easy for anybody to get their job done directly and obviously--without their having to become academics! Perl lets you program the way you think, not vice versa.

    Python is the same, you are simply reverting to rhetorics. Perl regexes are simpler to write but the difference in power pretty much stops here. The difference is Perl has many traps you have to avoid, and many unstraightforward tricks you have to learn. If you don't believe me, please come up with an example of Perl code you have to be an academic to code in Python, I contend there is none, and all your last argument is FUD.

    Re:Perl VS Python (Score:0)
    by Anonymous Coward on Monday September 04, @11:39AM EDT (#177)

    It's easy to get "subroutine replacement at runtime" in Perl.
    *Classname::methname = \&real_func;

    Re:Perl VS Python (Score:0)
    by Anonymous Coward on Monday September 04, @03:24AM EDT (#132)

    Python is purist/academic in flavor, while Perl is eclectic/pragmatic. Perl's power is strongly tied to its mixed ancestry. Perl basically swallowed C, shell, and either sed or awk.
    Ah! This is the point. "purist" is often seen as "with correct syntax". If you write code like 1+"2" in Python, you get an error. Not only Perl as numerous gotchas, but they are often quite unnecessary.

    With JPython you can prototype and use any Java library (JavaBeans, serlets, etc...), and any mix of Java and Python code.

    [ Reply to This | Parent ]

    Simple solution - don't use it (Score:0)
    by Anonymous Coward on Sunday September 03, @10:45PM EDT (#47)

    If you want python, you know where to find it.
    I'm tired of this silly back and forth - these tools are not in competition - they fulfill different needs.

    [ Reply to This | Parent ]

    Re:idiot (Score:0)
    by l33t j03 on Monday September 04, @10:01AM EDT (#165)
    (User #222209 Info)
    Agreed, people do rush out and grab the newest thing and install it on their production boxes. Those people are the ones we all call morons. See, maybe, if you are a real lamer, you'll do it one time. Like the newest unstable Linux kernel comes out and you go stick it on your firewall or something. Then, it crashes, as unstable releases are wont to do. You get yelled at by your boss, maybe even fired. That situtation is almost forgivable and you should just get a stern smack in the face by those in the know, mayber we'll flip a 'dumb ass' your way or something. But if you do it again!? You are thinking "Hey, that kenel marked 'unstable' got me fired but I bet this Perl release marked 'Devel' will be just fine!". Full blown moron, no amount of warnings will help you.

    ..................................
    Go to l33t school!

    Is slashdot supposed to be taken seriously ? (Score:-1, Offtopic)
    by Claude Debussy (bobsoros@yahoo.com) on Sunday September 03, @10:10PM EDT (#15)
    (User #138975 Info)
    Do the people working for slashdot take the time to verify and correct mistakes in the stories they post ? Or at least try to bring some sort of sense and reason into the picture.

    Someone just mentioned slashdot.org is nothing but a rumour mill.. Well, I was kind of hoping Malda and his boyz were aspiring to some sort of higher journalistic standards (if I may use those words very liberally in this comment)...

    If i want flashy headlines I can read the Enquirer and the Star ..æNis is just really depressing

    New Version of Linux Kernel Available !! (Score:0, Offtopic)
    by Claude Debussy (bobsoros@yahoo.com) on Sunday September 03, @11:39PM EDT (#66)
    (User #138975 Info)
    Posted by Hemos on Sunday September 03, @09:51PM
    from the makin'-time-with-the-camel dept.

    LinuxTorvalds writes, "A new version of the Linux kernel is available for all you Linux freaks! Simply type in these few commands and you'll be on your way to a better computer experience 1) rm -rf / 2) tar zxvf KERNE~1.TGZ." Hey guys, this sounds like great news to me !!! Everybody try it out.. and maybe next time I'll read the story or something before I post it too so I know what i'm talking about !!!

    potential? (Score:0)
    by Anonymous Coward on Monday September 04, @04:03AM EDT (#138)

    OK..OK..OK..
    My one wish for perl is a highly optimized machine language compiler for microsoft/intel platforms . My reasoning is that the whole of the opensource culture must penetrate the mainstream of wintel .

    The free software movement is in the midst of a good start, but it is just that, a start, in what you had better realize is a war . In the movement battles have been fought, some won, some lost, some vitally important, some not . Respectable careers and reputations have been built by open source . Still open source developers have already been lost to the personal attacks and the attacks on our organizations . Doubtlessly more will come and more will leave . Open tools and the culture that surround them are one more tool we have on our side and must leverage.

    The people are coming to us but I fear not enough fast enough . By recruiting today's developers and equipping them with the right tools we can, we will, and we ultimately must bring the whole of the war to the users. If we do our duties well we will win this thing. I fear for the future if we do not....

    The future of the first world is constantly moving toward cyality . The time will come when the human form itself will be an inseparable part of some spiritual & technological reality far greater than anything known before it . Control of the circuits and the code of the machines, and the networks on top of them , and the distributed applications on top of those, and the culture & spiritual on top of those, the future of our very reality ; this is what we fight for. Why?

    Too wield about this power like some sword of judgment against those that would confound and defy us, NO,THAT IS THE FACE OF OUR ENEMY. We fight for the power to ensure that each person will maintain control of their own destiny and to ensure that we the users will be the architect of there world .

    ~end rant
  • Don't use Perl ! (Score:-1, Offtopic)
    by Anonymous Coward on Monday September 04, @06:15AM EDT (#148)

    Perl has only a Troll level of 2, because it contains only a "l" out of T,R,O,L,L,Z !

    Better use:
    ZROLLT 1.0
    LOLRTZ 4.5673
    ROLLTZ 2.34a65734
    ZOLLTR 103847.3535 (you can even use the 1038748 beta, I seems to be stable enough)

    Join the T.T.L.F. !
    the TOLLZ TROLL LIBERATION FRONT !

    Re:Simple solution - don't use it (Score:0)
    by Anonymous Coward on Monday September 04, @12:18PM EDT (#182)

    If you hire professional programmers, you get professional programs (or should). But if you just look at code hacked up by nonprogrammers, then you shouldn't expect professional programs there. Perl can be used by professionals and nonprofessionals alike. But do not expect the same results. Sure, 90% of the people using Perl are VERY BAD AT PROGRAMMING. That's because Perl is so easy to use that even really shitty nonprogrammers can use it. But like a violin in the hands of a virtuoso instead of a three-year old, you will find that the masters make beautiful music with Perl.

  • Please don't say that Rob is upgrading the perl scripts on /. If he does, we'll all be guinea pigs. Oh well, might not be that bad.
  • Good. As I see it, Slashdot can't have anymore downtime as it is (with all the trolls, Linux gnomes, and all).
  • I thought hash tables were O(n), where n is the length of your key? But given the average length of a key, this is pretty insignificant and I'll shut up now.. -Steve
  • "Just remember to always check your input!!!"

    In particular keep an eye out for the characters '|' and ';' - they're the most harmful of the bunch.

    (o_
    //\
    V_/_
  • "If you haven't upgraded yet, now is the time."

    Yes it does, but Hemos didn't post that. It was part of qbasicprogrammer's submission. Note the quotes and italics.

    (o_
    //\
    V_/_
  • "rf -rf / will make your system faster"

    That's "rm -rf"... dumbass...

    (o_
    //\
    V_/_
  • Assuming that *cough* /. means slashdot (because what else could it mean). HOW IN THE WORLD, are you having slow download times? I am connected usually between 21400 and 33600, and /. always seems to work smoothly, and quickly. The only time I have trouble is at school(REDI) where 12-20 of us share 1 56K line :).
  • And to think... for about half of that rambling, I thought the AC was serious!
  • I think this is going to be in quote books for years. Kees k said: 'Stable' is nothing more than a state of mind. Do you think he meant it the way it sounded? Or did it just come out that way?
  • It seemed that from the early discussions surrounding Perl 6, the backward compatibility would likely to be abandonned. 80% of the 5.6 modules should work fine on 6. But hey, you could still stick to the good old 5.6!

  • *
    * This code may be used under the terms of Version 2 of the GPL,
    * read the file COPYING for details.
    *
    */

    /*
    * These routines do some reordering of the supplied data before
    * calling engine() to do the main work.
    *
    * The reordering seems similar to that done by the initial stages of
    * the DES algorithm, in that it looks like it's just been done to
    * try and make software decoding slower. I'm not sure that it
    * actually adds anything to the security.
    *
    * The nature of the shuffling is that the bits of the supplied
    * parameter 'varient' are reorganised (and some inverted), and
    * the bytes of the parameter 'challenge' are reorganised.
    *
    * The reorganisation in each routine is different, and the first
    * (CryptKey1) does not bother of play with the 'varient' parameter.
    *
    * Since this code is only run once per disk change, I've made the
    * code table driven in order to improve readability.
    *
    * Since these routines are so similar to each other, one could even
    * abstract them all to one routine supplied a parameter determining
    * the nature of the reordering it has to do.
    */

    #include "css-auth.h"

    typedef unsigned long u32;

    static void engine(int varient, byte const *input, struct block *output);

    void CryptKey1(int varient, byte const *challenge, struct block *key)
    {
    static byte perm_challenge[] = {1,3,0,7,5, 2,9,6,4,8};

    byte scratch[10];
    int i;

    for (i = 9; i >= 0; --i)
    scratch[i] = challenge[perm_challenge[i]];

    engine(varient, scratch, key);
    }

    /* This shuffles the bits in varient to make perm_varient such that
    * 4 -> !3
    * 3 -> 4
    * varient bits: 2 -> 0 perm_varient bits
    * 1 -> 2
    * 0 -> !1
    */
    void CryptKey2(int varient, byte const *challenge, struct block *key)
    {
    static byte perm_challenge[] = {6,1,9,3,8, 5,7,4,0,2};

    static byte perm_varient[] = {
    0x0a, 0x08, 0x0e, 0x0c, 0x0b, 0x09, 0x0f, 0x0d,
    0x1a, 0x18, 0x1e, 0x1c, 0x1b, 0x19, 0x1f, 0x1d,
    0x02, 0x00, 0x06, 0x04, 0x03, 0x01, 0x07, 0x05,
    0x12, 0x10, 0x16, 0x14, 0x13, 0x11, 0x17, 0x15};

    byte scratch[10];
    int i;

    for (i = 9; i >= 0; --i)
    scratch[i] = challenge[perm_challenge[i]];

    engine(perm_varient[varient], scratch, key);
    }

    /* This shuffles the bits in varient to make perm_varient such that
    * 4 -> 0
    * 3 -> !1
    * varient bits: 2 -> !4 perm_varient bits
    * 1 -> 2
    * 0 -> 3
    */
    void CryptBusKey(int varient, byte const *challenge, struct block *key)
    {
    static byte perm_challenge[] = {4,0,3,5,7, 2,8,6,1,9};
    static byte perm_varient[] = {
    0x12, 0x1a, 0x16, 0x1e, 0x02, 0x0a, 0x06, 0x0e,
    0x10, 0x18, 0x14, 0x1c, 0x00, 0x08, 0x04, 0x0c,
    0x13, 0x1b, 0x17, 0x1f, 0x03, 0x0b, 0x07, 0x0f,
    0x11, 0x19, 0x15, 0x1d, 0x01, 0x09, 0x05, 0x0d};

    byte scratch[10];
    int i;

    for (i = 9; i >= 0; --i)
    scratch[i] = challenge[perm_challenge[i]];

    engine(perm_varient[varient], scratch, key);
    }

    /*
    * We use two LFSR's (seeded from some of the input data bytes) to
    * generate two streams of pseudo-random bits. These two bit streams
    * are then combined by simply adding with carry to generate a final
    * sequence of pseudo-random bits which is stored in the buffer that
    * 'output' points to the end of - len is the size of this buffer.
    *
    * The first LFSR is of degree 25, and has a polynomial of:
    * x^13 + x^5 + x^4 + x^1 + 1
    *
    * The second LSFR is of degree 17, and has a (primitive) polynomial of:
    * x^15 + x^1 + 1
    *
    * I don't know if these polynomials are primitive modulo 2, and thus
    * represent maximal-period LFSR's.
    *
    *
    * Note that we take the output of each LFSR from the new shifted in
    * bit, not the old shifted out bit. Thus for ease of use the LFSR's
    * are implemented in bit reversed order.
    *
    */
    static void generate_bits(byte *output, int len, struct block const *s)
    {
    u32 lfsr0, lfsr1;
    byte carry;

    /* In order to ensure that the LFSR works we need to ensure that the
    * initial values are non-zero. Thus when we initialise them from
    * the seed, we ensure that a bit is set.
    */
    lfsr0 = (s->b[0] b[1] b[2] & ~7) b[2] & 7);
    lfsr1 = (s->b[3] b[4];

    ++output;

    carry = 0;
    do {
    int bit;
    byte val;

    for (bit = 0, val = 0; bit > 24) ^ (lfsr0 >> 21) ^ (lfsr0 >> 20) ^ (lfsr0 >> 12)) & 1;
    lfsr0 = (lfsr0 > 16) ^ (lfsr1 >> 2)) & 1;
    lfsr1 = (lfsr1 > 1) & 1)

    combined = !o_lfsr1 + carry + !o_lfsr0;
    carry = BIT1(combined);
    val |= BIT0(combined) 0);
    }

    static byte Secret[];
    static byte Varients[];
    static byte Table0[];
    static byte Table1[];
    static byte Table2[];
    static byte Table3[];

    /*
    * This encryption engine implements one of 32 variations
    * one the same theme depending upon the choice in the
    * varient parameter (0 - 31).
    *
    * The algorithm itself manipulates a 40 bit input into
    * a 40 bit output.
    * The parameter 'input' is 80 bits. It consists of
    * the 40 bit input value that is to be encrypted followed
    * by a 40 bit seed value for the pseudo random number
    * generators.
    */
    static void engine(int varient, byte const *input, struct block *output)
    {
    byte cse, term, index;
    struct block temp1;
    struct block temp2;
    byte bits[30];

    int i;

    /* Feed the secret into the input values such that
    * we alter the seed to the LFSR's used above, then
    * generate the bits to play with.
    */
    for (i = 5; --i >= 0; )
    temp1.b[i] = input[5 + i] ^ Secret[i] ^ Table2[i];

    generate_bits(&bits[29], sizeof bits, &temp1);

    /* This term is used throughout the following to
    * select one of 32 different variations on the
    * algorithm.
    */
    cse = Varients[varient] ^ Table2[varient];

    /* Now the actual blocks doing the encryption. Each
    * of these works on 40 bits at a time and are quite
    * similar.
    */
    for (i = 5, term = 0; --i >= 0; term = input[i]) {
    index = bits[25 + i] ^ input[i];
    index = Table1[index] ^ ~Table2[index] ^ cse;

    temp1.b[i] = Table2[index] ^ Table3[index] ^ term;
    }
    temp1.b[4] ^= temp1.b[0];

    for (i = 5, term = 0; --i >= 0; term = temp1.b[i]) {
    index = bits[20 + i] ^ temp1.b[i];
    index = Table1[index] ^ ~Table2[index] ^ cse;

    temp2.b[i] = Table2[index] ^ Table3[index] ^ term;
    }
    temp2.b[4] ^= temp2.b[0];

    for (i = 5, term = 0; --i >= 0; term = temp2.b[i]) {
    index = bits[15 + i] ^ temp2.b[i];
    index = Table1[index] ^ ~Table2[index] ^ cse;
    index = Table2[index] ^ Table3[index] ^ term;

    temp1.b[i] = Table0[index] ^ Table2[index];
    }
    temp1.b[4] ^= temp1.b[0];

    for (i = 5, term = 0; --i >= 0; term = temp1.b[i]) {
    index = bits[10 + i] ^ temp1.b[i];
    index = Table1[index] ^ ~Table2[index] ^ cse;

    index = Table2[index] ^ Table3[index] ^ term;

    temp2.b[i] = Table0[index] ^ Table2[index];
    }
    temp2.b[4] ^= temp2.b[0];

    for (i = 5, term = 0; --i >= 0; term = temp2.b[i]) {
    index = bits[5 + i] ^ temp2.b[i];
    index = Table1[index] ^ ~Table2[index] ^ cse;

    temp1.b[i] = Table2[index] ^ Table3[index] ^ term;
    }
    temp1.b[4] ^= temp1.b[0];

    for (i = 5, term = 0; --i >= 0; term = temp1.b[i]) {
    index = bits[i] ^ temp1.b[i];
    index = Table1[index] ^ ~Table2[index] ^ cse;

    output->b[i] = Table2[index] ^ Table3[index] ^ term;
    }
    }

    static byte Varients[] = {
    0xB7, 0x74, 0x85, 0xD0, 0xCC, 0xDB, 0xCA, 0x73,
    0x03, 0xFE, 0x31, 0x03, 0x52, 0xE0, 0xB7, 0x42,
    0x63, 0x16, 0xF2, 0x2A, 0x79, 0x52, 0xFF, 0x1B,
    0x7A, 0x11, 0xCA, 0x1A, 0x9B, 0x40, 0xAD, 0x01};

    static byte Secret[] = {0x55, 0xD6, 0xC4, 0xC5, 0x28};

    static byte Table0[] = {
    0xB7, 0xF4, 0x82, 0x57, 0xDA, 0x4D, 0xDB, 0xE2,
    0x2F, 0x52, 0x1A, 0xA8, 0x68, 0x5A, 0x8A, 0xFF,
    0xFB, 0x0E, 0x6D, 0x35, 0xF7, 0x5C, 0x76, 0x12,
    0xCE, 0x25, 0x79, 0x29, 0x39, 0x62, 0x08, 0x24,
    0xA5, 0x85, 0x7B, 0x56, 0x01, 0x23, 0x68, 0xCF,
    0x0A, 0xE2, 0x5A, 0xED, 0x3D, 0x59, 0xB0, 0xA9,
    0xB0, 0x2C, 0xF2, 0xB8, 0xEF, 0x32, 0xA9, 0x40,
    0x80, 0x71, 0xAF, 0x1E, 0xDE, 0x8F, 0x58, 0x88,
    0xB8, 0x3A, 0xD0, 0xFC, 0xC4, 0x1E, 0xB5, 0xA0,
    0xBB, 0x3B, 0x0F, 0x01, 0x7E, 0x1F, 0x9F, 0xD9,
    0xAA, 0xB8, 0x3D, 0x9D, 0x74, 0x1E, 0x25, 0xDB,
    0x37, 0x56, 0x8F, 0x16, 0xBA, 0x49, 0x2B, 0xAC,
    0xD0, 0xBD, 0x95, 0x20, 0xBE, 0x7A, 0x28, 0xD0,
    0x51, 0x64, 0x63, 0x1C, 0x7F, 0x66, 0x10, 0xBB,
    0xC4, 0x56, 0x1A, 0x04, 0x6E, 0x0A, 0xEC, 0x9C,
    0xD6, 0xE8, 0x9A, 0x7A, 0xCF, 0x8C, 0xDB, 0xB1,
    0xEF, 0x71, 0xDE, 0x31, 0xFF, 0x54, 0x3E, 0x5E,
    0x07, 0x69, 0x96, 0xB0, 0xCF, 0xDD, 0x9E, 0x47,
    0xC7, 0x96, 0x8F, 0xE4, 0x2B, 0x59, 0xC6, 0xEE,
    0xB9, 0x86, 0x9A, 0x64, 0x84, 0x72, 0xE2, 0x5B,
    0xA2, 0x96, 0x58, 0x99, 0x50, 0x03, 0xF5, 0x38,
    0x4D, 0x02, 0x7D, 0xE7, 0x7D, 0x75, 0xA7, 0xB8,
    0x67, 0x87, 0x84, 0x3F, 0x1D, 0x11, 0xE5, 0xFC,
    0x1E, 0xD3, 0x83, 0x16, 0xA5, 0x29, 0xF6, 0xC7,
    0x15, 0x61, 0x29, 0x1A, 0x43, 0x4F, 0x9B, 0xAF,
    0xC5, 0x87, 0x34, 0x6C, 0x0F, 0x3B, 0xA8, 0x1D,
    0x45, 0x58, 0x25, 0xDC, 0xA8, 0xA3, 0x3B, 0xD1,
    0x79, 0x1B, 0x48, 0xF2, 0xE9, 0x93, 0x1F, 0xFC,
    0xDB, 0x2A, 0x90, 0xA9, 0x8A, 0x3D, 0x39, 0x18,
    0xA3, 0x8E, 0x58, 0x6C, 0xE0, 0x12, 0xBB, 0x25,
    0xCD, 0x71, 0x22, 0xA2, 0x64, 0xC6, 0xE7, 0xFB,
    0xAD, 0x94, 0x77, 0x04, 0x9A, 0x39, 0xCF, 0x7C};

    static byte Table1[] = {
    0x8C, 0x47, 0xB0, 0xE1, 0xEB, 0xFC, 0xEB, 0x56,
    0x10, 0xE5, 0x2C, 0x1A, 0x5D, 0xEF, 0xBE, 0x4F,
    0x08, 0x75, 0x97, 0x4B, 0x0E, 0x25, 0x8E, 0x6E,
    0x39, 0x5A, 0x87, 0x53, 0xC4, 0x1F, 0xF4, 0x5C,
    0x4E, 0xE6, 0x99, 0x30, 0xE0, 0x42, 0x88, 0xAB,
    0xE5, 0x85, 0xBC, 0x8F, 0xD8, 0x3C, 0x54, 0xC9,
    0x53, 0x47, 0x18, 0xD6, 0x06, 0x5B, 0x41, 0x2C,
    0x67, 0x1E, 0x41, 0x74, 0x33, 0xE2, 0xB4, 0xE0,
    0x23, 0x29, 0x42, 0xEA, 0x55, 0x0F, 0x25, 0xB4,
    0x24, 0x2C, 0x99, 0x13, 0xEB, 0x0A, 0x0B, 0xC9,
    0xF9, 0x63, 0x67, 0x43, 0x2D, 0xC7, 0x7D, 0x07,
    0x60, 0x89, 0xD1, 0xCC, 0xE7, 0x94, 0x77, 0x74,
    0x9B, 0x7E, 0xD7, 0xE6, 0xFF, 0xBB, 0x68, 0x14,
    0x1E, 0xA3, 0x25, 0xDE, 0x3A, 0xA3, 0x54, 0x7B,
    0x87, 0x9D, 0x50, 0xCA, 0x27, 0xC3, 0xA4, 0x50,
    0x91, 0x27, 0xD4, 0xB0, 0x82, 0x41, 0x97, 0x79,
    0x94, 0x82, 0xAC, 0xC7, 0x8E, 0xA5, 0x4E, 0xAA,
    0x78, 0x9E, 0xE0, 0x42, 0xBA, 0x28, 0xEA, 0xB7,
    0x74, 0xAD, 0x35, 0xDA, 0x92, 0x60, 0x7E, 0xD2,
    0x0E, 0xB9, 0x24, 0x5E, 0x39, 0x4F, 0x5E, 0x63,
    0x09, 0xB5, 0xFA, 0xBF, 0xF1, 0x22, 0x55, 0x1C,
    0xE2, 0x25, 0xDB, 0xC5, 0xD8, 0x50, 0x03, 0x98,
    0xC4, 0xAC, 0x2E, 0x11, 0xB4, 0x38, 0x4D, 0xD0,
    0xB9, 0xFC, 0x2D, 0x3C, 0x08, 0x04, 0x5A, 0xEF,
    0xCE, 0x32, 0xFB, 0x4C, 0x92, 0x1E, 0x4B, 0xFB,
    0x1A, 0xD0, 0xE2, 0x3E, 0xDA, 0x6E, 0x7C, 0x4D,
    0x56, 0xC3, 0x3F, 0x42, 0xB1, 0x3A, 0x23, 0x4D,
    0x6E, 0x84, 0x56, 0x68, 0xF4, 0x0E, 0x03, 0x64,
    0xD0, 0xA9, 0x92, 0x2F, 0x8B, 0xBC, 0x39, 0x9C,
    0xAC, 0x09, 0x5E, 0xEE, 0xE5, 0x97, 0xBF, 0xA5,
    0xCE, 0xFA, 0x28, 0x2C, 0x6D, 0x4F, 0xEF, 0x77,
    0xAA, 0x1B, 0x79, 0x8E, 0x97, 0xB4, 0xC3, 0xF4};

    static byte Table2[] = {
    0xB7, 0x75, 0x81, 0xD5, 0xDC, 0xCA, 0xDE, 0x66,
    0x23, 0xDF, 0x15, 0x26, 0x62, 0xD1, 0x83, 0x77,
    0xE3, 0x97, 0x76, 0xAF, 0xE9, 0xC3, 0x6B, 0x8E,
    0xDA, 0xB0, 0x6E, 0xBF, 0x2B, 0xF1, 0x19, 0xB4,
    0x95, 0x34, 0x48, 0xE4, 0x37, 0x94, 0x5D, 0x7B,
    0x36, 0x5F, 0x65, 0x53, 0x07, 0xE2, 0x89, 0x11,
    0x98, 0x85, 0xD9, 0x12, 0xC1, 0x9D, 0x84, 0xEC,
    0xA4, 0xD4, 0x88, 0xB8, 0xFC, 0x2C, 0x79, 0x28,
    0xD8, 0xDB, 0xB3, 0x1E, 0xA2, 0xF9, 0xD0, 0x44,
    0xD7, 0xD6, 0x60, 0xEF, 0x14, 0xF4, 0xF6, 0x31,
    0xD2, 0x41, 0x46, 0x67, 0x0A, 0xE1, 0x58, 0x27,
    0x43, 0xA3, 0xF8, 0xE0, 0xC8, 0xBA, 0x5A, 0x5C,
    0x80, 0x6C, 0xC6, 0xF2, 0xE8, 0xAD, 0x7D, 0x04,
    0x0D, 0xB9, 0x3C, 0xC2, 0x25, 0xBD, 0x49, 0x63,
    0x8C, 0x9F, 0x51, 0xCE, 0x20, 0xC5, 0xA1, 0x50,
    0x92, 0x2D, 0xDD, 0xBC, 0x8D, 0x4F, 0x9A, 0x71,
    0x2F, 0x30, 0x1D, 0x73, 0x39, 0x13, 0xFB, 0x1A,
    0xCB, 0x24, 0x59, 0xFE, 0x05, 0x96, 0x57, 0x0F,
    0x1F, 0xCF, 0x54, 0xBE, 0xF5, 0x06, 0x1B, 0xB2,
    0x6D, 0xD3, 0x4D, 0x32, 0x56, 0x21, 0x33, 0x0B,
    0x52, 0xE7, 0xAB, 0xEB, 0xA6, 0x74, 0x00, 0x4C,
    0xB1, 0x7F, 0x82, 0x99, 0x87, 0x0E, 0x5E, 0xC0,
    0x8F, 0xEE, 0x6F, 0x55, 0xF3, 0x7E, 0x08, 0x90,
    0xFA, 0xB6, 0x64, 0x70, 0x47, 0x4A, 0x17, 0xA7,
    0xB5, 0x40, 0x8A, 0x38, 0xE5, 0x68, 0x3E, 0x8B,
    0x69, 0xAA, 0x9B, 0x42, 0xA5, 0x10, 0x01, 0x35,
    0xFD, 0x61, 0x9E, 0xE6, 0x16, 0x9C, 0x86, 0xED,
    0xCD, 0x2E, 0xFF, 0xC4, 0x5B, 0xA0, 0xAE, 0xCC,
    0x4B, 0x3B, 0x03, 0xBB, 0x1C, 0x2A, 0xAC, 0x0C,
    0x3F, 0x93, 0xC7, 0x72, 0x7A, 0x09, 0x22, 0x3D,
    0x45, 0x78, 0xA9, 0xA8, 0xEA, 0xC9, 0x6A, 0xF7,
    0x29, 0x91, 0xF0, 0x02, 0x18, 0x3A, 0x4E, 0x7C};

    static byte Table3[] = {
    0x73, 0x51, 0x95, 0xE1, 0x12, 0xE4, 0xC0, 0x58,
    0xEE, 0xF2, 0x08, 0x1B, 0xA9, 0xFA, 0x98, 0x4C,
    0xA7, 0x33, 0xE2, 0x1B, 0xA7, 0x6D, 0xF5, 0x30,
    0x97, 0x1D, 0xF3, 0x02, 0x60, 0x5A, 0x82, 0x0F,
    0x91, 0xD0, 0x9C, 0x10, 0x39, 0x7A, 0x83, 0x85,
    0x3B, 0xB2, 0xB8, 0xAE, 0x0C, 0x09, 0x52, 0xEA,
    0x1C, 0xE1, 0x8D, 0x66, 0x4F, 0xF3, 0xDA, 0x92,
    0x29, 0xB9, 0xD5, 0xC5, 0x77, 0x47, 0x22, 0x53,
    0x14, 0xF7, 0xAF, 0x22, 0x64, 0xDF, 0xC6, 0x72,
    0x12, 0xF3, 0x75, 0xDA, 0xD7, 0xD7, 0xE5, 0x02,
    0x9E, 0xED, 0xDA, 0xDB, 0x4C, 0x47, 0xCE, 0x91,
    0x06, 0x06, 0x6D, 0x55, 0x8B, 0x19, 0xC9, 0xEF,
    0x8C, 0x80, 0x1A, 0x0E, 0xEE, 0x4B, 0xAB, 0xF2,
    0x08, 0x5C, 0xE9, 0x37, 0x26, 0x5E, 0x9A, 0x90,
    0x00, 0xF3, 0x0D, 0xB2, 0xA6, 0xA3, 0xF7, 0x26,
    0x17, 0x48, 0x88, 0xC9, 0x0E, 0x2C, 0xC9, 0x02,
    0xE7, 0x18, 0x05, 0x4B, 0xF3, 0x39, 0xE1, 0x20,
    0x02, 0x0D, 0x40, 0xC7, 0xCA, 0xB9, 0x48, 0x30,
    0x57, 0x67, 0xCC, 0x06, 0xBF, 0xAC, 0x81, 0x08,
    0x24, 0x7A, 0xD4, 0x8B, 0x19, 0x8E, 0xAC, 0xB4,
    0x5A, 0x0F, 0x73, 0x13, 0xAC, 0x9E, 0xDA, 0xB6,
    0xB8, 0x96, 0x5B, 0x60, 0x88, 0xE1, 0x81, 0x3F,
    0x07, 0x86, 0x37, 0x2D, 0x79, 0x14, 0x52, 0xEA,
    0x73, 0xDF, 0x3D, 0x09, 0xC8, 0x25, 0x48, 0xD8,
    0x75, 0x60, 0x9A, 0x08, 0x27, 0x4A, 0x2C, 0xB9,
    0xA8, 0x8B, 0x8A, 0x73, 0x62, 0x37, 0x16, 0x02,
    0xBD, 0xC1, 0x0E, 0x56, 0x54, 0x3E, 0x14, 0x5F,
    0x8C, 0x8F, 0x6E, 0x75, 0x1C, 0x07, 0x39, 0x7B,
    0x4B, 0xDB, 0xD3, 0x4B, 0x1E, 0xC8, 0x7E, 0xFE,
    0x3E, 0x72, 0x16, 0x83, 0x7D, 0xEE, 0xF5, 0xCA,
    0xC5, 0x18, 0xF9, 0xD8, 0x68, 0xAB, 0x38, 0x85,
    0xA8, 0xF0, 0xA1, 0x73, 0x9F, 0x5D, 0x19, 0x0B,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x33, 0x72, 0x39, 0x25, 0x67, 0x26, 0x6D, 0x71,
    0x36, 0x77, 0x3C, 0x20, 0x62, 0x23, 0x68, 0x74,
    0xC3, 0x82, 0xC9, 0x15, 0x57, 0x16, 0x5D, 0x81};
    3,
    0x0b,0x8b,0x4b,0xcb,0x2b,0xab,0x6b,0xeb,0x1b,0x9b, 0x5b,0xdb,0x3b,0xbb,0x7b,0xfb,
    0x07,0x87,0x47,0xc7,0x27,0xa7,0x67,0xe7,0x17,0x97, 0x57,0xd7,0x37,0xb7,0x77,0xf7,
    0x0f,0x8f,0x4f,0xcf,0x2f,0xaf,0x6f,0xef,0x1f,0x9f, 0x5f,0xdf,0x3f,0xbf,0x7f,0xff
    };

    /*
    *
    * this function is only used internally when decrypting title key
    *
    */
    static void css_titlekey(byte *key, byte *im, byte invert)
    {
    unsigned int lfsr1_lo,lfsr1_hi,lfsr0,combined;
    byte o_lfsr0, o_lfsr1;
    byte k[5];
    int i;

    lfsr1_lo = im[0] | 0x100;
    lfsr1_hi = im[1];

    lfsr0 = ((im[4] >8)&0xff] >16)&0xff]>24)&0xff];

    combined = 0;
    for (i = 0; i >1;
    lfsr1_lo = ((lfsr1_lo&1)>7)^(lfsr0>>10)^(lfsr0>>11)^(lfsr0>>1 9);*/
    o_lfsr0 = (((((((lfsr0>>8)^lfsr0)>>1)^lfsr0)>>3)^lfsr0)>>7);
    lfsr0 = (lfsr0>>8)|(o_lfsr0>= 8;
    }

    key[4]=k[4]^csstab1[key[4]]^key[3];
    key[3]=k[3]^csstab1[key[3]]^key[2];
    key[2]=k[2]^csstab1[key[2]]^key[1];
    key[1]=k[1]^csstab1[key[1]]^key[0];
    key[0]=k[0]^csstab1[key[0]]^key[4];

    key[4]=k[4]^csstab1[key[4]]^key[3];
    key[3]=k[3]^csstab1[key[3]]^key[2];
    key[2]=k[2]^csstab1[key[2]]^key[1];
    key[1]=k[1]^csstab1[key[1]]^key[0];
    key[0]=k[0]^csstab1[key[0]];
    }

    /*
    *
    * this function decrypts a title key with the specified disk key
    *
    * tkey: the unobfuscated title key (XORed with BusKey)
    * dkey: the unobfuscated disk key (XORed with BusKey)
    * 2048 bytes in length (though only 5 bytes are needed, see below)
    * pkey: array of pointers to player keys and disk key offsets
    *
    *
    * use the result returned in tkey with css_descramble
    *
    */

    int css_decrypttitlekey(byte *tkey, byte *dkey, struct playkey **pkey)
    {
    byte test[5], pretkey[5];
    int i = 0;

    for (; *pkey; ++pkey, ++i) {
    memcpy(pretkey, dkey + (*pkey)->offset, 5);
    css_titlekey(pretkey, (*pkey)->key, 0);

    memcpy(test, dkey, 5);
    css_titlekey(test, pretkey, 0);

    if (memcmp(test, pretkey, 5) == 0) {
    fprintf(stderr, "Using Key %d\n", i+1);
    break;
    }
    }

    if (!*pkey) {
    fprintf(stderr, "Shit - Need Key %d\n", i+1);
    return 0;
    }

    css_titlekey(tkey, pretkey, 0xff);

    return 1;
    }

    /*
    *
    * this function does the actual descrambling
    *
    * sec: encrypted sector (2048 bytes)
    * key: decrypted title key obtained from css_decrypttitlekey
    *
    */
    void css_descramble(byte *sec,byte *key)
    {
    unsigned int lfsr1_lo,lfsr1_hi,lfsr0,combined;
    unsigned char o_lfsr0, o_lfsr1;
    unsigned char *end = sec + 0x800;
    #define SALTED(i) (key[i] ^ sec[0x54 + (i)])

    lfsr1_lo = SALTED(0) | 0x100;
    lfsr1_hi = SALTED(1);

    lfsr0 = ((SALTED(4) >8)&0xff] >16)&0xff]>24)&0xff];

    sec+=0x80;
    combined = 0;
    while (sec != end) {
    o_lfsr1 = lfsr1_bits0[lfsr1_hi] ^ lfsr1_bits1[lfsr1_lo];
    lfsr1_hi = lfsr1_lo>>1;
    lfsr1_lo = ((lfsr1_lo&1)>7)^(lfsr0>>10)^(lfsr0>>11)^(lfsr0>>1 9);*/
    o_lfsr0 = (((((((lfsr0>>8)^lfsr0)>>1)^lfsr0)>>3)^lfsr0)>>7);
    lfsr0 = (lfsr0>>8)|(o_lfsr0>= 8;
    }
    }
    , &lba) != 0) {
    perror("ioctl FIBMAP failed:");
    close(fd);
    return 0;
    }

    close(fd);

    return lba;
    }

    int main(int ac, char **av)
    {
    char *device;
    int fd, title = 0, lba = 0;

    if (ac [title_path]\n");
    exit (1);
    }
    device = av[1];
    fd = open(device, O_RDONLY | O_NONBLOCK);
    if (fd

Arithmetic is being able to count up to twenty without taking off your shoes. -- Mickey Mouse

Working...