in reply to Re^5: Smart match in p5
in thread Smart match in p5

or is it actually backed up a sampling of Perl modules from CPAN?

CPAN is not a good source of information, as ~~ (as short form of "scalar") is used mostly in one liners. That use is still valid, except with the weird print syntax. But ~~ was never meant like this anyway. ~ Just happens to be a reversible operation that works losslessly on both strings and numbers.

Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

Replies are listed 'Best First'.
Re^7: Smart match in p5
by demerphq (Chancellor) on Mar 14, 2005 at 16:48 UTC

    Thing is its not good enough to say "CPAN is not a good source of information" nor is it good enough to say "probably wont break anything".

    If CPAN isnt good enough then what is better? If there isnt anything better then CPAN is all you have. If you can turn around to P5P and say gee whiz, in 5000 CPAN modules ~~ isnt used once then you have an argument, if you say to them "CPAN isnt a good source of information as ~~ is only used in one liners and this patch probably wont break anything" then I would have to assume they will not take your efforts seriously. Nor should they and nor should you expect them to...

    ---
    demerphq

      I walked into this one by catching mention of '~~' and of a count of how many modules might contain it as the discussion was ending for a while in the CB, and was unable to come up with the numbers before it ended. Here, however, are my numbers and methods, in hopes they may be of help.

      • Version of perl: 5.8.3, installed on Mandrake 10.0 from RPM.
      • Command used to generate listing: perl -MCPAN -e 'autobundle;'
      • Number of modules installed (perl -ne 'print if (m/CONTENTS/..m/CONFIGURATION/ and not m/^\s+/ and not m/^=/);' ~/.cpan/Bundle/Snapshot_2005_03_14_00.pm | wc -l): 3_566
      • Number of files under /usr/lib/perl5 (find /usr/lib/perl5 -type f | wc -l): 8_982
      • Number of lines in files under /usr/lib/perl5 (find /usr/lib/perl5 -type f -exec cat "{}" \; | wc -l): 3_298_000
      • Number of files containing '~~' (find /usr/lib/perl5 -type f -exec grep -il '~~' "{}" \; | wc -l): 93
      • Number of lines containing '~~' (find /usr/lib/perl5 -type f -exec grep -i '~~' "{}" \; | wc -l): 170
      • Number of files containing '~~', by type (find /usr/lib/perl5/ -type f -exec grep -il '~~' "{}" \; | xargs file | gawk '{FS=":"; print $2;}' | perl -pe 's/^\s+//;' | sort | uniq -c | sort -n):
        1ASCII Java program text
        1ELF
        1GIF image data, version 87a, 60 x 60
        1GIF image data, version 89a, 60 x 60
        1gzip compressed data, was "ArcBall.pm", from Unix, max compression
        1gzip compressed data, was "Cartography.pm", from Unix, max compression
        1gzip compressed data, was "Char.pm", from Unix, max compression
        1gzip compressed data, was "Complex.pm", from Unix, max compression
        1gzip compressed data, was "Core.pm", from Unix, max compression
        1gzip compressed data, was "FlexRaw.pm", from Unix, max compression
        1gzip compressed data, was "Image2D.pm", from Unix, max compression
        1gzip compressed data, was "Misc.pm", from Unix, max compression
        1gzip compressed data, was "PP.pm", from Unix, max compression
        1gzip compressed data, was "Primitive.pm", from Unix, max compression
        1gzip compressed data, was "Transform.pm", from Unix, max compression
        1gzip compressed data, was "Window.pm", from Unix, max compression
        1ISO-8859 C program text
        1ISO-8859 English text, with CRLF line terminators
        3data
        3Perl5 module source text
        11ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), not stripped
        13ASCII English text, with CRLF line terminators
        20ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), stripped
        25ASCII English text

      In looking through those files (minus those ending in '.so'), all cases I could find of '~~' appeared either in format statements, as delimiters, or in comments.

      I do not know if this information is of use, but I hope it will prove helpful. (The list of modules and versions is below.)

      Update: 14 Mar 2005
      The listing was too long; therefore, the remainder of the list will be appended as a response to this node.

        The remainder of the listing, for those who may be interested, is provided below.

        Thank you very much for doing this research. This saves me some work (downloading a mini CPAN finished only an hour ago).

        And thanks for splitting it, because now I can ++ you twice! :)

        Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

        hum, I've downloaded a few of those modules, but I haven't yet found any '~~' in any of them:
        xmath@quoose cpan/build$ ls Algorithm-Annotate-0.10 Algorithm-Evolutionary-0.53 Algorithm-BinPack-0.4 Algorithm-Evolve-0.03 Algorithm-Bucketizer-0.10 Algorithm-FastPermute-0.07 Algorithm-CheckDigits-0.38 Algorithm-FloodControl-1.00 Algorithm-ChooseSubsets-0.01 Algorithm-GDiffDelta-0.01 Algorithm-Cluster-1.28 Algorithm-GenerateSequence-0.02 Algorithm-Diff-1.1901 TransitiveClosure-1.4 Algorithm-Diff-Apply-0.2.3 xmath@quoose cpan/build$ grep -rs '~~' * xmath@quoose cpan/build$

        Am I missing something, or did you do something wrong with the search?

        addendum: oh, this is a list of all modules checked? If so, I misunderstood. (a list of modules where you found ~~ would have been more useful to save downloading those which don't :-)