Berkeley CSUA MOTD:Entry 13734
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2024/11/23 [General] UID:1000 Activity:popular
11/23   

1998/2/25-3/25 [Computer/SW/Languages/Perl, Computer/SW/Unix] UID:13734 Activity:very high
3/25    Any easy ways to calculate median via UNIX utils like bc?
        \_ use awk
        \_ use Statistics::Descriptive;
                \_ descriptive.pm not found.
                        \_ get it from CPAN
        \_ whatever happened to BLSS? That had all sorts of cool statistics
           applications.
           \_ can we scam a license off of the STAT dept? Think they'd want
              porting help, or a BSD platform to build on?
                \_ Mail to blss@stat.  Can't hurt to ask.
        \_ #!/usr/local/bin/perl
           @sorted = sort {$a <=> $b} @ARGV;
           print $sorted[$#sorted/2], "\n";

           or, if you prefer,
           perl -e '@sorted = sort {$a <=> $b} @ARGV;' \
           -e 'print $sorted[$#sorted/2], "\n";' 6 23 9 1 0 23.3 4
              -emarkp
           \_ Just curious: if I've got "1 2 3 4" is "2" the correct response,
              according to any math texts?  -math ignorant
              \_ Yes, "2" is the correct answer, because Soda is really an
                 Apple ][ Plus running Apple Integer Basic.
                 \_ It's true!  Yes, the lottery scheduler is _THAT GOOD_.
          \_ I think, actually, that it should be the average of 2 and 3
             (i.e. 2.5).  Oh well, back to the drawing board.  -emarkp
           \_ can we scam a license off of the STAT dept? Think they'd want
              porting help, or a BSD platform to build on?
                \_ Mail to blss@stat.  Can't hurt to ask.
                \-the BLSS people seemed pretty amenable to work with us
                        \_                     watch your gramar^
                when i dealt with them on behalf of the ocf. --psb
                \_ Mark is pretty cool.  If he can do it legally, he will.
                \_ If there's an even number of items in the array, take the
                   middle two ($#sorted/2 and $#sorted/2 +1), add and div by 2
          \_ okay, here we go:
             perl -e '@sorted = sort {$a <=> $b} @ARGV; \
             $half = $#sorted/2;  \
             print (($#sorted % 2) ? ($sorted[$half]+$sorted[$half+1])/2 : \
                 $sorted[$half]); print "\n";' 1 2 3 4
        \_ My version :-)
           Truly, a work of art.  :)
                #!/usr/local/bin/perl5 -w

                @sorted = sort {$a <=> $b} @ARGV;

                $len = $#sorted +1;

                if ($len /2 == int($len /2)) {
                        $avg = (@sorted[($len /2)] + @sorted[($len -1) /2]) /2;
                        print $avg . "\n";
                        }
                else {
                        print $sorted[$#sorted/2] . "\n";
                }
        \_
        use Statistics::Descriptive;
        $stat = new Statistics::Descriptive::Full;
        $stat->add_data(@ARGV);
        printf("the median of [%s] = %s\n", join(',', @ARGV), $stat->median);
        \_ show off.  mine is easier to read. :-)
        \_Can't locate Statistics/Descriptive.pm in @INC at ./test.pl line 3.
          BEGIN failed--compilation aborted at ./test.pl line 3.
ERROR, url_link recursive (eces.Colorado.EDU/secure/mindterm2) 2024/11/23 [General] UID:1000 Activity:popular
11/23   

You may also be interested in these entries...
2008/3/4-7 [Computer/Networking, Computer/SW/Languages/Perl] UID:49324 Activity:moderate
3/4     Does anybody have some code or know of a program that will take a
        network/mask and return the list of address in that CIDR block?
        e.g. "iplist 10.10.10.0/24" and return 10.10.10.0 ... 10.10.10.255
        [I have a way to do this, but it involves distributing a large
        amount of code, which is kind of a hassle. Looking for something
        lightweight and either standard or easdy to rpm/port/yum install.]
	...
2007/9/10 [Computer/SW/Languages/Perl] UID:47986 Activity:low
9/10    Hi.  I'm running a package based linux distro.  Should
        I install perl CPAN modules through the provided packages,
        or through sudo cpan> install modulename etc ?
        Opinions?
        \_ Depends on the package system you're using, you may have to
           deal with both.  I had an experience where I installed via
	...
2007/8/7-13 [Computer/SW/Languages/Perl, Computer/SW/Unix] UID:47555 Activity:nil
8/7     I'm trying to figure out whether it's possible for get wget to
        authenticate to a web page protected by a login form ('post'
        method to send username/pass, and cookies.)  Cookies don't seem
        to be the problem, with --save-cookies and --keep-session-cookies
        but getting the username/password submitted isn't doing it.  On
        this particular page, getting to a link, let's say 'example.aspx',
	...
2006/6/29-7/3 [Computer/SW/Languages/Perl] UID:43527 Activity:nil
6/29    Visual Programming in Perl:
        http://search.cpan.org/dist/Acme-EyeDrops/lib/Acme/EyeDrops.pm
	...
2005/9/2-3 [Computer/SW/Languages/Perl] UID:39466 Activity:nil
9/2     Hey motd I used to have perl w/DBI 1.42 & DBD 2.9003. After
        upgrading Perl, DBI 1.48, & DBD 3.0002_1 I'm seeing something
        really weird. The following used to work:
        $dbh=$DBI->prepare("INSERT INTO data VALUES(\?)");
        for ($i=0; $i<10; $i++) {
          if (!$dbh->execute($i)) {
	...
2005/8/31 [Computer/SW/Languages/Perl] UID:39376 Activity:nil
8/31    Looking for an XML parser for Perl, preferably one that
        doesn't require installation (something already built in).
        If it's not already built in, I prefer something that doesn't
        require C compilation, and that I can just stick the *.pm
        to use. I'm looking for portability, not performance. Thanks.
        \_ What's wrong with using CPAN?
	...
2004/4/10-12 [Computer/SW/Languages/Perl] UID:13128 Activity:nil
4/10    In perl, how do I get time precise to the milisecond? The CPAN module
        requires recompilation and root access to install it, I'm looking for
        something more portable. Thanks!
        \_ If you need to know the time, there's no portable way to do it
           without modules.  However, if you just want a sub-second delay,
           you can do it with select -- for example, select "", "", "", 0.1;
	...
2004/4/12 [Computer/SW/Languages/Perl] UID:13154 Activity:nil
4/12    What's a good perl module (cpan) that strips off all the html
        tags and javascript crap? And perhaps be smart enough to strip
        off menus and ads? Thanks.
        \_ lynx -dump <pagename>
        \_ s/<[^>]*>//g
	...
2004/3/29-30 [Computer/SW/OS/FreeBSD, Computer/SW/OS/OsX] UID:12920 Activity:high
3/29    I'm installing binaries for both OsX and Linux and I'd like all the
        users to have /usr/bin/<files> to be accessible. I thought about
        /usr/bin/<files> for generic stuff (like scripts) and
        /usr/bin/<platform>/<files> for platform specific things.
        What is the correct approach to this?
        \_ there are obviously several ways to do this, and "correct" is mostly
	...
2004/3/30 [Computer/SW/OS/FreeBSD, Computer/SW/OS/OsX] UID:29888 Activity:high
3/29      I'm installing binaries for both OsX and Linux and I'd like all the
          users to have /usr/bin/<files> to be accessible. I thought about
          /usr/bin/<files> for generic stuff (like scripts) and
          /usr/bin/<platform>/<files> for platform specific things.
          What is the correct approach to this?
        \_ there are obviously several ways to do this, and "correct" is mostly
	...
2003/8/29-2004/2/14 [Computer/SW/Languages/Perl, Computer/SW/Unix] UID:12252 Activity:nil
2/13    Does perl have a "diff" facility? I have something that requires a
        lot of diff but file I/O using unix diff would be too slow. Thanks.
        \_ Text::Diff?  Really.  You could search cpan for this sort of thing.
	...
2003/9/9 [Computer/SW/Languages/Perl] UID:10121 Activity:high
9/8     Any recommendations for a text-based Yahoo instant messanger app
        for linux that logs.
        \_ Yahoo::Messenger
           \_ what do you mean, there isn't a CPAN module by that name.
              \_ Sorry, Net::YahooMessenger, but really, you could have
                 tried searching.
	...
2012/8/29-11/7 [Computer/SW/Security] UID:54467 Activity:nil
8/29    There was once a CSUA web page which runs an SSH client for logging
        on to soda.  Does that page still exist?  Can someone remind me of the
        URL please?  Thx.
        \_ what do you mean? instruction on how to ssh into soda?
           \_ No I think he means the ssh applet, which, iirc, was an applet
              that implemented an ssh v1 client.  I think this page went away
	...
2012/8/30-11/7 [Computer/SW/Apps, Computer/SW/Unix] UID:54470 Activity:nil
8/30    Is wall just dead? The wallall command dies for me, muttering
        something about /var/wall/ttys not existing.
        \_ its seen a great drop in usage, though it seems mostly functional.
            -ERic
        \_ Couldn't open wall log!: Bad file descriptor
           Could not open wall subscription directory /var/wall/ttys: No such file or directory
	...
2012/3/29-6/4 [Computer/HW/Memory, Computer/HW/CPU, Computer/HW/Drives] UID:54351 Activity:nil
3/29    A friend wants a PC (no mac). She doesn't want Dell. Is there a
        good place that can custom build for you (SSD, large RAM, cheap video
        card--no game)?
        \_ As a side note: back in my Cal days more than two decades ago when
           having a 387SX made me the only person with floating-point hardware,
           most machines were custom built.
	...
2012/1/27-3/26 [Computer/SW/Unix] UID:54299 Activity:nil
1/27    Interesting list of useful unix tools. Shout out to
        cowsay even!
        http://www.stumbleupon.com/su/3428AB/kkovacs.eu/cool-but-obscure-unix-tools
        \_ This is nice.  Thanks.
	...
2011/11/20-2012/2/6 [Computer/Companies/Apple, Computer/SW/Unix] UID:54237 Activity:nil
11/20   Are there tools that can justify a chunk of plain ASCII text by
        replacing words with words of similar meaning and inserting/removing
        commas into the text?  I received a 40-line plain text mail where
        all the lines are justified on left and right.  Every word and comma
        is followed by only one space, and every period is followed by two
        spaces.  The guy is my kid's karate instructor which I don't think is
	...
2011/10/26-12/6 [Computer/SW/Unix] UID:54202 Activity:nil
10/24  What's an easy way to see if say column 3 of a file matches a list of
       expressions in a file? Basically I want to combine "grep -f <file>"
       to store the patterns and awk's $3 ~ /(AAA|BBB|CCC)/ ... I realize
       I can do this with "egrep -f " and use regexp instead of strings, but
       was wondering if there was some magic way to do this.
       \_ UNIX has no magic. Make a shell script to produce the ask or egrep
	...