Computer SW Languages Perl - Berkeley CSUA MOTD
Berkeley CSUA MOTD:Computer:SW:Languages:Perl:
Results 151 - 300 of 431   < 1 2 3 >
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2024/11/23 [General] UID:1000 Activity:popular
11/23   

2004/5/31 [Computer/SW/Languages/Perl] UID:30503 Activity:insanely high
5/30    Let's say I have a directory full of subdirectories, each of which
        has a number of files in it. How can I delete all subdirectories that
        have, say, less than 10 files in them?
                   \_ fewer
        \_ There's no single standard command that will do this.  You'll
           need to write something that will count files per directory,
           make a list of targets and pass that to rm.
           \_ might the "find" command help?
              \_ That is one part of one possible solution.  What I would do
                 is write the whole thing in perl.  Perl has a built in
                 find-like function, can opendir() and readdir(), and allow
                 you to easily maintain state and lists of target dirs.  It's
                 a simple two phase process: 1) make target list, 2) kill
                 targets.  Obviously, you'll want to test your code in a
                 test directory or you risk removing the wrong files.
                 \_ mosquito.  SLEDGEHAMMER!  <BABAMMMM!!!!!!>
                    \_ Uhm, yeah, the following are any different?
        \_ Exactly 80 chars:
for(grep{!/^\.\.?$/&&-d}<*>){opendir D,$_;unlink if@{[readdir D]}<12;closedir D}
           --dbushong
        \_ More than 80 chars:
        sub z{my @a=`find $_[0] -type d -maxdepth 1 -mindepth 1`;chomp @a;@a};
        for (z(".")) { print "$_\n" if scalar(z($_))>$n; } # --darin
        \_ A bit shorter and more correct:
           use File::Path;
           for(grep{-d}<*>){rmtree $_ if <$_/*> < 10}
           --dbushong
                                           \_ I don't think this works.
                                              scalar(<$_/*>) does not return
                                              the file count. In any event,
                                              the script deleted stuff it
                                              wasn't supposed to and didn't
                                              delete stuff it should. Good
           \_ I don't think this works.  scalar(<$_/*>) does not return
              the file count. In any event, the script deleted stuff it
              wasn't supposed to and didn't delete stuff it should. Good
              thing I backed up. -- op
              \_ Yeah, it needs @{[ ]} around it like mconst's... but use his.
                 And yeah, anytime there's a "shortest perl" contest on the
                 motd, Caveat Executor.  --dbushong
        \_ @{[<$_/{.,}*>]}<12&&`rm -r \Q$_`for<*>       # --mconst
        \- hmm, there are some interesting ways to do this ...
           the exact details vary slightly based on things like, are all
           the dirs only one deep, do you count sub-subdirs are files etc.
           i think it is better to do this modularly rather than trying to
           save characters. here is one different approach:
           find -type f | xargs -n 1 dirname | sort | uniq -c |
               egrep -v '[0-9][0-9]' | grep /
           there are some obvious shortcuts or changes to make more
           robust [e.g. if there are spaces in name], if you are going
           to do this once or mutiple times, performance etc. [yes i know
           the dirname call is expensive ... that can be replaced, but if
           this is a one shot thing, debugging time is more expensive
           than machine cycles]. --psb
           \-and it admittedly relied on a hack to deal with the "less
                 than 10 part" ... but all this is easily remedied. --psb
2004/5/24-25 [Computer/SW/Languages/Perl] UID:30393 Activity:moderate
5/24    Perl question:
        I have a match m/foo(.*?)bar(.*?)baz/;
        I want to format that into an output like "output $0,$1\n";
        But I also want it generic for different patterns, so I can say:
        $pattern = "m/foo(.*?)bar(.*?)baz/";
        $output = 'output $0,$1\n';
        while ($input =~ m/$pattern/ig)
        {
          #put use current $0,$1 in $output here somehow
        }
        What's a good way to do this?
        \_ Not sure if this is what you want, but it's an idea:
        $input2 = $input; # make a copy
        while ($input2 =~ s/$pattern/$0:$1/ig) { # extract $0 & $1
          ($var1, $var2) = split($input2, ":");
          sprintf($output, $formatString, $var1, $var2);
        }
        \_ while ( $input =~ m/"$pattern"/ig)
           # will get perl to expand $pattern before using it in the test
           \_ The matching is working fine.  That's not the question. -op
           \_ You don't need ""s
        \_ This modifies $input2 on the first pass, and with multiple matches
           in the string (note the /g option) this will return wonkey results.
           -op
           \_ This works:
              $pattern = 'foo(.*?)bar(.*?)baz'
              $text = "foo1bar2baz\nfoo3bar4baz\nfoo5bar6baz\n"
              while ($text =~m/$pattern/ig) { print "$1, $2\n"}

              Part of your problem might be that $n references starts at 1, not
              0. --scotsman
              \_ Oops.  I screwed up when typing it up in the motd.  In my
                 original code it's $1 and $2, not $0 and $1.  I've corrected
                 it above.  But the point is I want the output string formatted
                 as well.  Like:
                 $output = 'The $1 is a result of $2.';
                 or
                 $output = 'I won't $1 before $2 o'clock.';
                 -op
                 \_ okay then, replace "print" with "$output=".  Wait.  I'm
                    misreading.  Gimme a sec.  Ah. sprintf will do what
                    you want.  --scotsman
                    \_ No it won't, at least not if I don't know the number of
                       matches ahead of time.  This DOES work though:
                       $output = eval qq{sprintf qq{$format}; };
                       -op
                       \_ And there ya go.
                          \_ Thanks for the suggestions BTW. The sprintf turns
                             out to be superfluous.  This works too:
                             $output = eval qq{ qq{$format}; };
2004/5/12-13 [Computer/SW/Languages/Perl] UID:30196 Activity:very high
5/12    Perl question, I want to replace nnn with xxx, ie, \nnnn -> \nxxx
        (that's a backslash followed by n, not a newline), s/nnn/xxx/
        gives me \xxxn!! What to do? I want the replace to change everything
        except a literal \n that should stay as is...
        \_ I think s/(\\n)?nnn/$1xxx/ will do it.  That's "match an optional
           backslash-n and nnn and replace nnn with xxx".
           \_ Alternatively, s/(?<!\\)nnn/xxx/ explicitly matches any "nnn"
              that isn't preceded by a backslash.  You may or may not find
              this more intuitive.
                \_ ?<! is the syntax? how weird.
                   \_ It's based on the older syntax of ?!, which looks ahead
                      in the string: /foo(?!bar)/ matches foo but not foobar.
                      When they added the ability to look behind, matching
                      bar but not foobar, /(?<!foo)bar/ seemed like the least
                      bad choice.

                      Yes, it's a mess.  The tentative perl6 syntax for this
                      is /<!after foo>bar/, where <!after foo> is read "not
                      after foo" and means "assert that the current position
                      in the string is not immediately after something that
                      matches foo".  --mconst
                      \_ I must say the introduction of actual English keywords
                         (in regexps, no less!) instead of line noise is a
                         philosophical novelty for Perl.  Or maybe they added
                         so much functionality that the pigeonhole principle
                         hit them pretty hard, and they had no choice. -- ilyas
                         \_ Heh.  You might actually enjoy reading some of
                            Larry Wall's rationale for the new regexp syntax;
                            it includes quotes like:

                                It should not be considered acceptable to
                                define new constructs that contain a plethora
                                of punctuation, but we've become accustomed
                                to constructs like (?<=...) and (??{...}) and
                                [\r\n\ck\p{Zl}\p{Zp}], so we don't complain.

                            Check out http://csua.org/u/7af starting at "First, let
                            me enumerate some of the things that are wrong
                            with current regex culture."  --mconst
                            \_ But I *like* line noise!  It makes me look
                               brilliant at work.
2004/5/7 [Computer/SW/Languages/Perl] UID:30089 Activity:moderate
5/7     What's up with this?
        PID USERNAME PRI NICE  SIZE   RES STATE  TIME   WCPU    CPU COMMAND
        63318 jenly     59   0 19648K 1192K RUN  625:30 67.53% 67.53% perl5.005
        \_ What's with the anonymous question? -emarkp
        \_ you too can run the ps command.
           \_ make sure to use the -w flag
              \_ www
        \_ That has eaten up 11 hours of CPU time in the past 29 hours.
        \_ got pics?
        \_ looks like out of control spamassassin
        \_ is it a girl or a guy? If a guy, he needs to be squished. If a
           girl, I would like to touch her.
           \_ "Jennifer Ly" sounds like a girl.
2004/5/6 [Computer/SW/Languages/Perl] UID:30061 Activity:nil
5/6     Good job blowing away the motd, emarkp:
emarkp   77172  0.0  0.2  1908 1380  DO  I+    4:39PM   0:00.07 /usr/local/bin/p\
erl /home/sequent/emarkp/bin/clean.pl /etc/motd.public
        \_ restored.
        \_ isn't changing the motd.public via a script squishable?
2004/5/5 [Computer/SW/Languages/Perl] UID:30027 Activity:nil
5/5     Why are huge perl processes getting run every few seconds?
        \_ show us show us! Who's abusing power?
           \_ I dunno, soda seems real slow to me today and I saw a few on
              'top' taking a bunch of cpu but not right now.
        \_ It's not motdedit, is it?
        \_ Most likely spamassassin
2024/11/23 [General] UID:1000 Activity:popular
11/23   

2004/5/4 [Computer/SW/Languages/Perl] UID:29993 Activity:high
5/4     In perl, how do you know if an argument given is a scalar, hash,
        or array?
        \_ generally, the use to which it's being put.  And the behaviour
           you see if you use it as a scalar.  Maybe use strict or -wT
           might give you some helpful messages.  -beginning/intermediate
                                                   perl user
        \_ TYPES ARE FOR THE WEAK!
           \_ or for coders who don't know what they are coding
        \_ More to the point is why do you think you'd need to know in perl?
           \_ say you want to overload a method so it takes different
              arguments for backward compatibility. CGI.pm does that.
           \_ Don't know enough about perl to know, but perhaps for things
              like polymorphic function arguments? Perl is pretty ambigious
              about stuff like this... which is why I avoid using it for
              "real" code in projects.
        \_ in some cases you might be able to use ref($var) to find out
           what "type" of variable was passed: some of the return values
           are SCALAR, ARRAY, HASH and REF. (man perlfunc and search for
           ref).
2004/4/29-5/1 [Computer/SW/Languages/Perl] UID:13473 Activity:nil
4/30     My CGI script has gone from .120us to about .250us. How can I
        profile my Perl code without adding too much trash? For example,
        how much savings do I get by taking out "use strict", use modules,
        and other stuff?
        \_ WHY DO YOU HATE AMERICA?
2004/4/27-28 [Computer/SW/Languages/Perl, Computer/SW/Unix] UID:13418 Activity:moderate
4/27    How do I sort the output of lastlogin by time?
        \_ cool, we can figure out who are the motd posters!!
        \_ try /usr/bin/last instead
           \_ no, that's not the output i want. I really just want
              each person's last login.
              \_ learn perl.
              \_ foreach user (`cut -d: -f1 /etc/passwd`)
                 last -1 $user
                 end
              \_ grep -v "^#" /etc/passwd | cut -d: -f1 | xargs -I% last -1 %
                 Pipe it again to sort as needed.  Need more pipes!!!
        \_ /usr/bin/lastlog on linux.  Trivial perl script on anything else.
           [why does someone keep deleting this?]
2004/4/26-27 [Computer/SW/Languages/Perl] UID:13388 Activity:nil
4/26    Trying to compile Perl on Darwin, I'm stuck on this line:
        ar -rc bar2.a bar2.o bar1.o
        Any reason why? ok thx
        \- did you run into problems with the case-insensitivity on the
           mac file system? that's probably a different problem but somthing
           i ran into building perl a while ago. --psb
           \_ Starting with 10.3, you can turn "on" case-sensitivity on HFS+,
              but there is no gurrantee that it won't create more problems
              than it solve.  By the way, how did you manage to compile perl
              eventually?
              \- the general view seems to be fmting the fs with
                 the case sensitivity option is asking for trouble as a
                 number of tools dont expect this, such as some backup
                 software. re: perl ... not's not hard to get around once
                 you figure out what is doing on, e.g. configure = Configure =
                 CONFIGURE. --psb
        \_ mac osx doesn't have perl included as a default??
           \_ he's referring to Darwin, not OS X.
2004/4/26 [Computer/SW/Unix, Computer/SW/Languages/Perl] UID:13379 Activity:nil
4/26    How do I use sed or perl, etc. to delete all lines from a file
        before or after some pattern.  For example, in vi, I could type
        /<pattern>dG or 1Gd/<pattern>.  But how do I put this into a
        script?
        \_ I believe sed '/<pattern>/d' will do what you want.
           \_ No, that only deletes the line with the pattern.  It doesn't
              do anything to the lines before or after it.
              \_ Sorry.  Misread the question.
        \_ in perl you want something like:
           $skip = 0;
           open(INFILE,$infile);
           open(OUTFILE,">$outfile");
           while (<INFILE>) {
                $skip = 1 if (/[pattern]/);
                print OUTFILE $_ unless ($skip);
           }
           close (INFILE);
           close (OUTFILE);
           \_ one line form:
              perl -ni -e'$skip=1 if /PATTERN/; print unless $skip' FILENAME
                Change "unless" to "if" if you want to print after the PATTERN
              \_ Thanks.
        \_ manning sed should reveal addresses. you can do:
            sed '/moo/,$d'
           to delete all lines after finding a line that matches the regexp
           /moo/. -ali
2004/4/20 [Computer/SW/Languages/Perl] UID:13276 Activity:nil
4/19    yay!  Next version of boost::regex will support more Perl-like (or
        Javascript-like) pattern matches:
        http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1429.htm
        \_ what?  boost?
           \_ http://www.boost.org
              It's a popular set of C++ template libraries.
              \_ Popular doesn't exactly describe it.  It's the short list for
                 inclusion into the next C++ standard.
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/4/10-12 [Computer/SW/Languages/Perl] UID:13129 Activity:nil
4/10    In perl, can I make the program more portable by first checking if
        a module is available, then "use" or "require" it later?
        \_ I think you can do this with an exec call.  Checking.
           no.  i think i was thinking of using an eval block, but i
           can't quite get it to work.
        \_ You can set up a variables using single quoted strings with
           embedded use/require statements and necessary subroutine
           calls and then use eval to figure out which ones work at
           runtime. Here is a short example that returns a hash of @_
           using either MD5 or SHA1 (which ever is found first, unless
           a search order is specified via $MODE):

        sub doHash
        {
           my $hashCmdMD5 = 'use Digest::MD5 qw(md5 md5_hex md5_base64);';
           $hashCmdMD5 .= " md5_hex('@_'); ";

           my $hashCmdSHA1 = 'use Digest::SHA1 qw(sha1 sha1_hex sha1_base64);';
           $hashCmdSHA1 .= " sha1_hex('@_'); ";

           my $hashCmd = ($MODE eq "MD5" ? $hashCmdMD5 : $hashCmdSHA1);
           my $hash = eval $hashCmd;

           if ($@ || !defined($hash) || $hash eq "") {
              $hashCmd = ($MODE eq "MD5" ? $hashCmdSHA1 : $hashCmdMD5);
              $hash = eval $hashCmd;
           }

           return ($@ || !defined($hash) ? "" : $hash);
        }
        \_ nice.  where's that code from?  yours?
           \_ This is modified from some code I wrote for work. I added
              $MODE for this example, so that one can get an idea about
              how this can work.
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;
           will pause for a tenth of a second.  --mconst
        \_ you can always install modules as a user and add the libs to your
           perl lib path.
2004/4/10-11 [Computer/SW/Languages/Perl] UID:13124 Activity:low
4/9     Can one write a filename expansion pattern that, say, match all
        filenames without a '.' in it?  This would be trivial in regexp but
        I can't see how to do it in sh.
        \_ I don't think you can do it directly (at least, not in a practical
           way). You can always run the output of ls through sed easily
           enough. Finer shells like zsh also have ways to negate wildcards,
           which may help here somewhat.
        \_ something silly like [A-Za-z0-9 _]*  (etc,etc), but it really
           depends on your shell.  in /bin/sh?  eh....  This sounds like
           another of those motd problem where you're better off asking how
           you should solve the real problem instead of asking the tedious
           detail you got stuck on because you're lost in the forest looking
           at the trees.
           \- right. use ls,find,echo |fgrep -v . to generate the list. --psb
           \_ psb is right.  sh's pattern is different from regexp so that
              char class cannot have wild card multiplier.
              \_ yes I know that but if you read what I said the point is I
                 think he's doing the wrong thing.  if he tells us what he's
                 trying to do at a higher level this whole regexp problem will
                 go away if he has a better general plan.  his original q.
                 seems silly.  he could just as easily call perl or some
                 other regexp compatible parser at that point in his /bin/sh
                 program but that doesn't seem to be the point, does it?
                 \_ I am not doing SA.  I am just doing some spring cleaning
                    of the hard drive on my home pc and wondered if there is
                    a oneliner solution to a simple problem.  It's faster to
                    visually inspect than to learn perl.
                    \- use emacs dired-mode --psb
                    \_ ok then use either of psb's answers or use a different
                       shell that can deal with a regexp.
2004/4/7-8 [Computer/SW/Languages/Perl] UID:13054 Activity:low
4/7     Is there a convenient way to get WHOIS information stripped of all the
        disclaimers and legalese?
        \_ perl.
           \_ Of course there are programming ways of doing it, but is there
              anything easy like a website or a flag or some alternate whois
              client?
        \_ grep
2004/3/30-31 [Computer/SW/Languages/Perl] UID:12925 Activity:kinda low
3/17    In Perl, how do I make variables have static types and type check
        for valid parameter/actuals? I realize that variables are untyped
        in Perl ($var can be 0.001 or "hello") but I'd like to have more
        strict checking so that errors would be caught ahead of run-time,
        Thanks,                                                 -java guy
        \_ use java.  Seriously.  You don't use perl if you want strong
           typing.  If you want to clean user input, use regexps.  But
           the closest thing perl has to typing is its data structures.
           The content of those structures can be... anything. --scotsman
           \_ Oh yes, as opposed to those lists of Objects Java has, where you
              have to use instanceof and casting to get what you want.  Java is
              bad.  Naturally any language in the ML family will work, as will
              Lisp strangely enough.  Yes, Lisp actually has a fairly powerful
              type system that most people never use (using 'declare' and so
              on).  -- ilyas
              \_ I only said "use java" because he signed as "java guy"
                   --scotsman
                 \_ You know, Ben, just because someone signs as
                    'heroin addict', doesn't mean you should give him bad
                    advice. -- ilyas
                    \_ You're always coming down on heroin, Ilya. -geordan
                       \_ That's "coming down off heroin," geordan.  Get yer
                          drug lingo right.
              \_ you don't use java much, do you. it's not great, but it's not
                 that bad either. i very rarely use instanceof, and 1.5 has
                 parameterized containers.
                 \_ You are right, I no longer use Java much, I am proud to
                    report.  While I am happy you almost never use instanceof
                    and casting to get things out of lists in Java, it turned
                    out to be a common enough problem that made them add
                    templates.  I mean my example is precisely the one given
                    on Sun's site to explain why templates are useful.  There
                    are other problems with Java's types, for instance you can
                    google for 'type spoofing.'  I won't even get to other
                    things wrong with Java.  I think Paul Twohey has a long
                    rant stored somewhere on this subject, on everything from
                    primitive type handling to floating point. -- ilyas
                    \_ Java Generics are not templates...
                       Java Generics are not templates...
                       \_ Yup, weaker than C++ templates.  Though you know,
                          the word 'template' is pretty ... generic.  It's not
                          like it applies exclusively to C++ stuff. -- ilyas
        \_ One way to find mistakes in perl is to 'use strict;' and to run
           with #!/usr/bin/perl -wT. At least this way you can find the
           obvious mistakes with input validation. Once you fix those, the
           only other thing you can do is to perform input validation in all
           of your subroutines.
           The biggest problem I find with perl is the lack of prototypes,
           which forces you to manually check @_ in every subroutine to make
           sure that the correct number of args were specified. There are
           extensions to perl that add this, but they aren't available on
           every system which makes it hard to write portable perl code using
           them.
           \_ You make this sound so difficult.  "warn if (@_ != n)"
                \_ That doesn't do type checking for you. If you need the
                   first two entries in @_ to be ints, the next two to be
                   string, &c. its not do-able without manually checking
                   each entry in @_. Prototypes (ansi-c style) provide that
                   level of support for you.
                   \_ Irrelevant.  This is perl.  use something else if you
                      want typing.
           BTW, for the java-types, sometimes you don't have a choice. Ex. if
           you need to write a cli program java is a terrible choice due to
           the jvm startup penalty, the resource requirements (jvm needs ~
           10mb of ram compared with 700k or less for perl), and its lack
           of integration with libc (using Runtime.exec() in order to change
           file ownership, create symlinks, remove files, &c. is not workable).
           \_ So write in in C and stop bitching about it. -williamc
                \_ I used to write everything in C, but having to roll
                   binaries for every odd-ball os/hw type just became
                   a pita. Perl was a compromise, it is portable and
                   has just enough system support for the things that
                   I need to do.
           \_ Um, prototypes are built into perl and have been for a while:
              sub foo($$@) { ... }
              foo takes two scalars and a list
                \_ WHAT? What is the name of the variable then? It's a lot
                   more clear if you use "sub foo($a, $b) { ... }"
                   \_ The variable is, as always, @_.
2004/3/25-26 [Computer/SW/Languages/Perl] UID:12845 Activity:nil
3/25    I'm trying to get mysql working on my machine. I don't have root so
        I have to install DBI and other packages. How do I find out if the
        package is included in the default Perl distribution? I'm asking
        because test suites are failing due to not having certain *.pm
        files (DBD.pm, DBI.pm, etc etc). Thanks.
        \_ Look in /usr/lib/perl5, most sites install the stock perl modules
           there. The DB* stuff (except for DBD-File) isn't part of the def.
           perl distribution.
2004/3/25-26 [Computer/SW/Languages/Perl] UID:12844 Activity:nil
3/25    Do you need to install a special DBI module for PostgreSQL or it's
        built in Perl5 already?
        \_ AFAIK, you need the correct DBD module (Pg.pm) for PostgreSQL.
           This isn't part of Perl. On RH you can install a perl-DBD-Pg-1.x
           rpm which should include everything you need. On FreeBSD make
           install in /usr/ports/databases/p5-DBD-Pg should give you
           everything you need.
           \_ and of course apt-get install libdbd-pg-perl
2004/3/20-22 [Computer/SW/Languages/Perl] UID:12778 Activity:nil
3/19    In Perl, how do I do file descriptor jumps. I'm asking because I
        want to implement my own "tail -f" or "tail -100" where I can just
        find out the size of the file, then jump towards the end, and
        move around the files. THanks.
        \_ jumps?  you mean seek() and/or fseek()?
        \_ tell me why would the UN want to give up its exploitation of
        making millions off Saddam and the Oil for Food program?
        what incentive for the UN to get rid of IRAQ's saddam when they
        are making millions. You want nothing more than to put the
        Iraqi people back under oppression so that the UN can make millions
        more off the poor Iraqi people exploiting the Oil for Food program.
2004/3/19-20 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Perl] UID:12756 Activity:nil
3/19    When I do substr($string, x, 1) eq "c" in Perl, is it smart enough
        to do (string[0]=='c') in lower level, or is it dumb to do it
        like strcmp(string, "c")==0? In another word how much optimization
        does Perl perform? I'm asking because performance is an
        issue but I don't want to use C. ok thx
        \_ umm...why do you think strcmp(string, "c") would be so slow?
           oh, right, because you're an idiot.
        \_ Profile your code.  You will almost certainly be surprised to learn
           where the real slowdown is. -- ilyas
           \_ it won't be in this trivial string comparison, that's for sure.
              \_ Indeed not. -- ilyas
                 \_ makes me wonder what they're teaching in Berkeley CS these
                    days....
        \_ Use C or another REAL programming language.
2004/3/18-19 [Computer/SW/Languages/Perl] UID:12746 Activity:nil
3/18    In Perl, I'm using a hash of a hash like the following:
        my $w=$CATEGORY{$c};
        my %w=%$w;
        But after turning on strict, it no longer works and reports
Can't use an undefined value as a HASH reference at bin/categorize.pl line 72.
        What am I doing wrong? Thanks.
        \_ What does $CATEGORY{$c} return? A hash?  you probably want a
           reference to it, not a copy.  And that would help you sort out
           the access on the next line.
        \_ You probably mean "%w = %{$w}", but why not just use the pointer?
           -scotsman
                \_ I'd like to use %w like $w{$key}=$val. So can I actually
                   reference/deference in Perl? Problem with Perl is I don't
                   know when I'm copying by value or copying by reference...
                   \_ Well, the first line there is copying by reference.  My
                      correction of the second line copies by value.  The %{}
                      is a dereference as well as a "cast". -scotsman
                        \_ same problem even with cast, whats wrong?
                        \_ ok I just found out that when I set to use strict,
                           %CATEGORY becomes empty even though I made it
                           public by "use vars qw (%CATEGORY)". So now
                           I'm just scratching my head...
                NEVERMIND I found it's a logic problem and _/
                has NOTHING to do with use strict. I really
                like "use strict"! I've caught a lot of bugs
                with it.
2004/3/17 [Computer/SW/Languages/Perl] UID:12736 Activity:nil
3/17    In Perl, when I "use strict;", how do I declare a global array
        or global hash? use vars qw (@ASSOC, %KEYHASH); doesn't work...
        \_ At the start you can declare "my @array", and everything in that
           scope or below will see it. --scotsman
        \_ It should be:
           use vars qw(@ASSOC %KEYHASH);
           (no comma)
           I believe in perl >= 5.6 you can say:
           our (@ASSOC, %KEYHASH);  --dbushong
2004/3/17 [Computer/SW/Languages/Perl] UID:12735 Activity:nil
3/17    Say I have a CGI in Perl and I want to call another script, and it
        happens to be another Perl script. How to invoke it without using
        system(...), which will actually make it slow?
        \_ make the other script a module and import it.
        \_ ``, system, or as the person above said, create a module and
           import it
2004/3/16 [Computer/SW/Languages/Perl] UID:12696 Activity:nil
3/16    In perl how do I make it so that it checks for variable undeclared
        because it's really annoy how it ignores errors like that. ok thx
        \_ #!/usr/local/bin/perl -w
           use strict;
        \_ I prefer #!/usr/bin/env perl  and   $^W=1; (or $WARNING is clearer)
2004/3/15-16 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Perl] UID:12666 Activity:low
3/14    Is there a function that takes a string and then escape all spaces
        and control chars in it and return a string suitable for use as
        say a filename in a shell?  tia.
        \_ "function" in what, c, the shell, ...?
           \_ in some more or less widely available library of C functions?
              \_ Something like perl's quotemeta? --scotsman
              \_ No. But if you want to look at an example look in
                 openbsd's ksh. IIRC, the function is called x_escape
                 and is in edit.c.
                 \_ Thanks.  One would have thought something has useful as
                    this should make it way to some standard lib.  Not that it
                    is that difficult, but why reinvent the wheel or copy
                    other's work?
2004/3/9-10 [Computer/SW/OS/Linux, Computer/SW/Languages/Perl, Computer/SW/Security] UID:12588 Activity:nil
3/8     Where can I find the definitions of the 3 timestamps associated
        with a file on a linux system: "Access  Modify  Change"
        \_ On most OS's that informaion is in the ls man page. Or do you
           need something more detailed?
           \_ Yes, I need to know the exact technical definition
              of "Changed" in this context. I'm trying to track down
              when/how my /usr/bin/perl file got changed from the debian
              "stable" version to the "testing" 5.8.2 version. Thanks.
              \_ is man 2 stat sufficient?
                 \_ Yes siree. Perfect. Thank You!
2004/2/27-29 [Computer/SW/Languages/Misc, Computer/SW/Languages/Perl] UID:12439 Activity:high
2/27    In perl, say I have a @list of strings, how do I print the first
        character of those stings, concatinated? For example, if @list is
        ['hello','world',123], I want an output of hw1. I can do a loop,
        substr, and the .= operator, but it looks lame...
        \_ what's wrong with just doing what works?
        \_ TMTOWTDIT, but foreach $item (@array) { print substr($item,0,1) }
           is one way. -tom
           \_ map { print substr($_,0,1) } @array
              or
              $output = map { substr($_,0,1) } @array
              \_ The latter doesn't work, because it calls map in scalar
                 context; you need $output = join "", map { substr($_,0,1) }
                 @array.
              \_ (dolist (i array)(print (char i 0))) -- ilyas
                 \_ gee you're clever.
                    \_ Array.map (fun x -> print_char x.[0]) array
                       p([[X|_]|Y]):-print(X),p(Y).
                       Incidentally, I know of multiple cases where a Perl
                       programmer benefitted from seeing a solution in another
                       language.  But I respect your anonymous snide remark
                       anyways. -- ilyas
                       \_ Because we all know that anyone posting anonymously
                          is also less intelligent and has invalid points.  I
                          post anonymously to cloak my inferiority to you and
                          others who are so smart because you sign your names.
                          Really, it's just jealousy.  Anonymity is a form of
                          envy.  I think I'll start signing all my posts so I
                          envy.  I think I'll start signing all my posts so I
                       anyways. -- ilyas
                          can be just as smart and well likde as you!
                          can be just as smart and well liked as you!  -- ilyas
                          \_ you're pathetic. -intelligent, valid anonymous guy
              \_ wow I can't believe how many ways there are to do this.
                 Here is the ultimate question. After parsing, internal
                 representation, and optimization in Perl, which one of the
                 above gives you the quickest runtime?
                 \_ Depends on the size of your array.  Generally map is faster
                    as length @array gets larger.
                     \_ what are you implying, that the function "foreach"
                        expands the representations in memory (extra malloc
                        maybe?) and then goes through the elements? For
                        example "foreach $a (1..10000)" does an expansion,
                        and that "foreach $a list" does the same thing?
                        \_ I'm not implying anything.  Everything I say is
                           emperical experience.  I leave the internals as
                           an exercise to the reader.
        \_ That's all bullshit.
           array.each {|i| print i[0].chr}
           \_ Prolog is shorter:
              p([[X|_]|Y]):-print(X),p(Y). -- ilyas
              \_ I'm not convinced that's really shorter. How is that used? I
                 don't know much about Prolog. Given a list called "Array",
                 how do you print it?
                 \_ p(Array). -- ilyas
                    \_ As I suspected. So it ain't shorter!
                       \_ In some sense, 'array' in your code and
                          '[[X|_]|Y]' in mine are equivalent.  Both are
                          internal variable names for some data.  What you were
                          asking me to do is something else, namely provide
                          a function call wrapper to the code, which isn't what
                          your code does.  I think the original stands as an
                          equivalent to yours. -- ilyas
                          \_ In some sense, that code and your code are
                             given the same input.  You rule!
                             equivalent because they produce the same output
                             given the same input.  You rule!  -- ilyas
                                \_ Well I could say
                                   [].each{|i|putc i[0].chr}
                          \_ Given an array "array", it prints the characters.
                             It's a function call. No? (It's ruby, for anyone
                             who doesn't know...)
                             \_ Given an array "[[X|_]|Y]", it prints the
                                characters.  Prolog names can have structure
                                built in.  -- ilyas
                                      \_ cool. btw i shortened it again.
           array.each {|i| print i[0].chr}
                                built in.  -- ilyas
                                \_ Well I could say
                                   [].each{|i|putc i[0]}
                                   [].map{|i|putc i[0]}
                                   Is that longer than Prolog? I'm no ruby
                                   expert so I'm not sure if there's anything
                                   better there.
                                   \_ Yup, you win.  You can look here for more
                                      examples me, dbushong and some others
                                      came up with:
                                      http://www.bushong.net/david/comparisons
                                      \_ cool. btw i shortened it again.
                                         \_ you rock!  -- ilyas
                                        -- ilyas
                                      \_ cool. btw i shortened it again(2)
2004/2/24-25 [Computer/SW/Languages/Perl] UID:12378 Activity:nil
2/23   I need to come up with some sort of scriptable solution for controlling
       various hardware-- we already have an interface that accepts
       string-based commands over a socket, but no way to control it via script
       (e.g. with variables, if/then/else/while, error recover/reporting).
       Would perl be good for this sort of thing, or are there simpler, more
       focused languages/modules available?
        \_ I'm not exactly sure what your situtation is, but FORTH is often
           used as a language to control hardware. It's small, effecient
           and easy to write interpreters for (there are quite a few
           embeddable forth interpreters out there).
        \_ Python 1.5 runs on vxWorks, if you are running that OS.
        \_ Expect.
        \_ perl is good to know in any case.
2004/2/21-23 [Computer/SW/Mail, Computer/SW/Languages/Perl] UID:12341 Activity:low
2/21    What's the best tool to convert raw network traffic captured on the
        wire into something useful?  I'm currently reading the unparsed
        output from ngrep, tcpdump and similar tools but I'd like to see that
        turned into the real thing.  For example, I want to see an output log
        that says machine X went to host/port Y/y to grab URL Z for http
        connections.  I want emails going by saved out in mbox or other
        human readable format.  Does such a thing exist?  I started to write
              \- yes, but you have to email me --psb
                 \_ why not posted it on the web?  I was looking for something
                    \- because as a general matter these anon requests are
                       annoying. i can understand for a dumb question or a
                       contentious issue but not in a case like this. i suppose
                       if you are widely disliked on sloda, that might be one
                       reason to ask for help anonymously. --psb
                       \_ maybe some people don't want their name attached
                          with looking for software to read raw network
                          traffic.  the world just isn't as open minded and
                          understanding as you are, partha.
                    like that monitoring LAN network to spot abuses on
                    company's network, mainly to spot p2p client use at the
                    office   --kngharv
                             \- if you want to look for p2p, that is a
                                matter of looking for the protocol. as a
                                general matter compliance issues are easier
                                to deal with because you can do offline rather
                                than realtime detection [offline = run on
                                tracedumps]. of course if you want to use
                                something like kazaa obliterator, then you
                                need to detect in realtime ... or not too
                                lagged batch proc. what is this "web" you
                                speak of. --psb
        my own in perl but then realised I can't be the first person to ever
        need this.  Thanks!
        \_ fantastic GUI utility called Ethereal. Available binaries for
           windows, linux, solaris. source available. I've used it only
           for reading traffic at the packet level, but perhaps if you want
           application level stuff (eg, emails as opposed to SMTP packets
           or whatever) perhaps you could write that yourself since its
           open source.                         - rory
        \_ Etherpeek
        \_ If it doesn't have to be graphical, you might want to consider
           hogwash (snort-based IDS.)  Also, although it's more of a toy
           than a tool, take a look at Etherape.  -John
           \_ use Etherape before.  I find it not as useful as I would like
              to be.  Only thing cool about it is that it color coded traffic
              from different ports.  This feature allow me to spot p2p
              client (most people uses p2p don;t bother with port changes),
              and it is pretty good for detecting infected computer which
              eat up all the bandwidth.
                \_ Like I said, it's sort of a toy, although useful to get
                   an overview of traffic patterns.  What I find really
                   hilarious (almost totally useless as a tool) is driftnet.
2004/2/11-12 [Computer/SW/Languages/Perl] UID:12211 Activity:nil
2/11    What's the best way to compare the similarity of 2 files using the
        Bayes NSP package: http://www.d.umn.edu/~tpederse/nsp.html ?
        count.pl gives me a lot of useless numbers...
2004/2/2-3 [Computer/SW/Languages/Perl] UID:12077 Activity:nil
2/2     Trivia of the day: what does this do?
        n = ((n >>  1) & 0x55555555) | ((n <<  1) & 0xaaaaaaaa);
        n = ((n >>  2) & 0x33333333) | ((n <<  2) & 0xcccccccc);
        n = ((n >>  4) & 0x0f0f0f0f) | ((n <<  4) & 0xf0f0f0f0);
        n = ((n >>  8) & 0x00ff00ff) | ((n <<  8) & 0xff00ff00);
        n = ((n >> 16) & 0x0000ffff) | ((n << 16) & 0xffff0000);
        \_ [formatd]
        \_ I'm just guessing, but possibly reverse the order of the bits in n.
                \_ um, are you sure it's O(n)? ARE YOU SURE???
                   \_ um, wtf are you responding to?
                      \_ um, he doesn't know!  he ISN'T SURE!
        \_ nothing interesting but if I cared I could run it through perl or
           wrap it in C syntax but I don't care.
2004/1/30-31 [Computer/SW/Languages/Perl] UID:29772 Activity:nil
1/30    Was Larry Wall a real person?
        \_ Still is.
        \_ He was when he autographed my 1st. Ed. Programming Perl.
        \_ Yes, I was.  --Larry Wall
           \- "I AM" --lwall@netlabs.com
2004/1/30 [Computer/SW/Languages/Perl] UID:29770 Activity:nil 61%like:12025
1/29    Looking through some Perl files, and I noticed some files with
        a line consisting of just a "1;" at the end.  What does that
        mean?  - perl newbie
        \_ return code.
           \_ thanks.
        \_ When you "require" another file, it runs through and expects a
           "true" value at the end.  ergo, 1;.  It's in effect a return code,
           but for a different reason.
           \_ thanks, makes sense now.
2004/1/30 [Computer/SW/Languages/Perl] UID:12025 Activity:nil 61%like:29770
1/29      Looking through some Perl files, and I noticed some files with
          a line consisting of just a "1;" at the end.  What does that
          mean?  - perl newbie
        \_ return code.
           \_ thanks.
        \_ When you "require" another file, it runs through and expects a
           "true" value at the end.  ergo, 1;.  It's in effect a return code,
           but for a different reason.
           \_ thanks, makes sense now.
2004/1/29-30 [Computer/SW/Languages/Perl] UID:11993 Activity:moderate
1/29    I have a bunch of ^\ chars in my (allegedly XML) file.  I'd like
        to squash them with perl or php or some such.  How can I?
        \_ I assume you mean "control backslash". Just use perl regex
        \_ I assume you mean "escape backslash". Just use perl regex
           to replace. Regex for escape is \cX where X is character after
           escape sequence. So perl -pe 's/\c\\//' filename -williamc
           \_ tnx, perfect.  (i didn't know \c and the per tutorials i
           to replace. Regex for escape is \cX where X is character after
           escape sequence. So perl -pe 's/\c\\//' filename -williamc
           escape sequence. -williamc
        \- ObEmacs
                looked at didn't say) -top
        \- ObEmacs
        \_ ObSed
2004/1/15-16 [Computer/SW/Languages/Perl] UID:11785 Activity:kinda low
1/14    I'm trying to flush output to disk after each write. This never writes
        to disk. What am i missing here (the file is being created):
        #!/usr/bin/perl
        $|=1;
        open(TEST,">test.txt") || die "Can't open: $!";
        print TEST "Testing\n";
        while(1) {}
        \_ call system's synch ?
           \_ $|=1 is supposed to flush after every print/write...
                \_ You forgot to call "select STDOUT" or "select TEST",
                   because $| bind to the last selected file descriptor.
                        \_ dear motd god, you're suppose to delete
                           useful replies. where are you?
                           \_ not even the censorbotidiot has the nerve to
                              kill this perfectly helpful response.
2004/1/10-11 [Computer/SW/Languages/Perl, ERROR, uid:11740, category id '31298#3.875' has no name! , ] UID:11740 Activity:nil
1/9     Stupid chick. If you're bored and want to put her in her place, write
        to Beverley_Sweeney@birdville.k12.tx.us.
        http://www.dfw.com/mld/dfw/news/columnists/dave_lieber/7643262.html
        \_ That's what you get for using Windows... Thankfully they
           didn't install Linux/BSD on their machines and have someone
           discover wall....
           \- i guess you young'un dont know about the time jordan hubbard
              "rwalled the whole internet" from evans hall ... including
              either the head of DARPA or the IG, something like that. --psb
              \- googling for jkh and rwall ... --psb
      http://www-mice.cs.ucl.ac.uk/multimedia/misc/tcp_ip/8702.mm.www/0310.html
        \_ May I ask how you even heard about this in the first place? Do
           you live in Dallas?
           \_ It was on slashdot yesterday.  Anyway, it was the principal's
              decision to suspend; he should take a good part of the blame
              too. - !op
              \_ It was on fark; I don't recall seeing it on slashdot, but
                 who knows. Anyway, she, not the principal, is supposed to be
                 the computer teacher, and I'd assume she's the one that
                 did most of the convincing that it wasn't harmless, but was
                 (here I would wiggle my fingers and say ooooh) "hacking." -op
              \- The CSUA ought to send a letter about this. --psb
                 \_ Like what? "We, the members of CSUA, an official
                    and prominent organization of Berkeley's CompSci/EECS
                    dept. think you are an idiot. Have a nice day"
                    \- what do you suggest the CSUA do to justify itself?
                       anything beyond running a wall apppliance and
                       various junk-food related activities? if you dont
                       think there is more to say than "you are an idiot"
                       well i suppose i'll be charitable and not recyles
                       those words and just suggest maybe you should not be
                       the one to write the letter. --psb
                       \_ You gotta be kidding me, right? I mean, if you want
                          the CSUA to do something worthwhile then I can
                          think of ten things better than writing a letter
                          to a middle-aged elementary schoolteacher about
                          the nuances of hacking. I mean, if you really have
                          that much time on your hands to bother the poor
                          woman why don't you do something like go teach
                          a class on Perl open to all? Wouldn't that be
                          much more fucking constructive than spamming
                          an obviously close-minded and pea-brained
                          bible-belter? And yes, I have donated my
                          time to teaching DeCal classes in the recent past.
                          How does contributing to the slashdot flamefest she's
                          already getting really change anything? Get a clue.
                          -williamc
                          \_ Because we don't have to send the typical idiotic
                             slashdot spam crap.  Making a small change in the
                             social fabric for the better is way more important
                             than teaching some friday Perl classes.
                \_ That's not a bad idea actually.
                   \_ You write it Partha and I will sign it.
2003/12/30-31 [Computer/SW/Languages/Perl] UID:11615 Activity:nil
12/30   When the forecast says 50% raining at 10AM, does it mean it will or
        will not rain? I'm asking because most of the time when they say
        50%, it doesn't rain, so it's definitely not 50/50.
             \- it depends wheather it is a Baysian weatherf'caster or a
                a Frquentists F'caster. --psb
                \_ that was actually very funny -nivra
                   \_ i don't get it.
        \_ if you don't work at sea and you listen to the weather forecast,
           you are a pussy.
             \- it depends wheather it is a Baysian weatherf'caster or a
                a Frquentist F'caster. --psb
                \_ why the fuck can't you format your posts like everyone
                   else?  do you hit the tab key two extra times in each line
                   when you write code also?
                   \_ easy: he's a lazy SOB and thinks he's better than the
                      rest of us.
                      \_ or he just doesn't know how to configure his editor
                         properly.
                      \_ He has yet to see evidence to the contrary in most
                         posts to the motd. --psb #1 fan
                \_ CONVERT OR DIE.  -- Bayesian
                \_ that was actually very funny -nivra
                   \_ i don't get it.
                      \_ u are swine to psb's perl.
        \_ It means that weather forecasting is impossible.
        \_ It doesn't mean anything.  Those numbers are essentially yanked
           out of their asses.
        \_ It means that given the present conditions in the past, 50% of the
           time it has rained.
        \_ Rain, rain, go away!  Come again some other day!
           \_ We need the water.
              \_ Let it rain when I'm not around.  And stop draining so much
                 water from the Colorado.  You use too much.  Fuckers.
2003/12/3 [Computer/SW/Languages/Perl] UID:11304 Activity:very high
12/2    What's a quick way to find the length of the longest line in a file?
        \_ perl -p -e'print length $_; s/.*//' <file> |sort -n|tail -1
           \_ perl -pe 's/.*/length/e'
           \_ perl -pe 's/.*/length $_/e'
           \_ perl -lpe '$_=length'
              however this automatically chomps the trailing newline, so
              you'll need to add 1 to the result if you care about them.
              -geordan
                \_ what does the l do? which perldoc describes cmdline args?
                   \_ man perlrun
           \_ awk '{print length}'
        \_ awk '{L=L>length?L:length}END{print L}' <FILE>
           \_ perl -pe 's/.*/length $_/e'
              -geordan
           no sort or tail needed. beat that!
2003/11/13 [Computer/SW/Languages/Perl] UID:11056 Activity:nil
11/12   I like the proposal below. I motion a Divestiture of MOTD, splitting
        motd.public into baby motd's. Partition it into motd.jokes,
        motd.politics, motd.technical (IMPORTANT), and motd.troll (for misc).
        \_ Ok, whatever.  Might as well just setup a web based message board.
           \_ http://www.csua.org/motd
              \_ Yes?
        \_ Nah. Well, we could start a proposal for people to tag their posts
           with what type of post it is. It could be just two types for now.
           Then use a simple perl-filter script to read the motd.
           \_ Uh, yeah, like that would happen.  How about people just skip
              over the threads they don't find interesting?
2003/11/12 [Computer/SW/Languages/Perl] UID:11036 Activity:nil
11/11   Argh.  Why isn't this working?
        perl -p -i.bak -e 's#\n\n#\n#gsm' foo.cc
        I've got to change
        /* comment */

        int
        TO
        /* comment */
        int
        \_ man perlrun, and look at the explanation of -p. --scotsman
        \_ s/^\n// worked for me. and no emacs needed.
        \- you can use an emacs kbdmacro, then use the macro2elisp
           "complier" and then tweak the function to do this.
           there might be a simpler way to do this with
           query-replace* ... depends on the exact details. --psb
        \_ I wound up doing s/\n/FOOBAR/g; s/FOOBARFOOBARint/FOOBARint/g;
           s/FOOBAR/\n/g; .  That's it.  Fuck this, I'm leaving.  And
           thanks for the suggestions.
           \_ The reason it didn't work is b/c -p only gets one line at a time,
              so the entire string you get to match is, for instance,
              "/* comment */\n", not the 3 lines you were looking for.
              Getting rid of the \n's first let you have it all on one line.
              \_ perl -p -i.bak -e 's#^\n##' foo.cc
2003/11/11-12 [Computer/SW/Languages/Perl, Computer/SW/OS/Solaris, Computer/SW/Unix] UID:11030 Activity:low
11/11   ls -lt lists all files in a directory in chronological order.
        For files nearly a year old, it only lists the date, but not the
        time, of last modification.  But it lists them in non-alphabetical
        order.  Thus, I suspect it is indeed listing them in order of most
        recently modified.  So, then, it presumably knows the modification
        time.  How can I get it to list the modification time, rather than
        the year, for older files?
        \_ get the ls that comes with GNU coreutils. it shows both date and
           time, but only up to hour and minute.
        \_ Try -T, works on FreeBSD
           \_ Whoa, that's really useful, never knew about that; thanks! Too
              bad it's not standard. -!op
          \_ works here, but not on my machine at work.
             \_ which runs....?
                \_ Solaris
                   \_ Solaris follows the POSIX standard
                   \_ Maybe try /usr/xpg/bin/ls ?
        \_ Try tarring up the file and scping it to soda
        \_ As with all problems, this can be solved with perl:  alias ls-lt to:
           perl -e 'chdir$ARGV[0]if@ARGV;opendir D,".";print scalar localtime $_\
->[0]," $_->[1]\n"for sort{$a->[0]<=>$b->[0]}map{[(stat)[9],$_]}grep\!/^\../,readdir D'
           (note the \'ed ! to make your shell happy).  Then you can just say
           % ls-lt /tmp
           % ls-lt
           etc.
           and get the full dates.  --dbushong
           \_ or you might even be able to do tar tf on the tarfile
2003/10/26 [Computer/SW/Languages/Perl] UID:10790 Activity:nil
10/25   The amazing web site reverser!
        Use any http://url.mirror.sytes.org, for instance:
        <DEAD>www.cnn.com.mirror.sytes.org<DEAD>
        Search the web for satanic messages!
        \_ Wow!  Amazing!  They ran web pages through perl's string reverse
           function! Wowowowow!
           \_ Actually, it's a little more interesting than that. The layout
              of the page also undergoes a vertical flip, though with varying
              degrees of success. It would be cooler if they flipped the
              images too.
              \_ They do flip the images.
                 \_ Not on cnn, at least.
              of the page also undergoes a vertical flip.
2003/10/21-22 [Computer/SW/Languages/Perl, Computer/SW/Unix] UID:10725 Activity:moderate
10/21   Hi is there a small utility on unix that can replace a word in a file?
        \_ perl -p -i .bak -e 's/oldWord/newWord/' file.  If you want to replace
           all instances of oldWord with newWord, use 's/oldWord/newWord/g'
           \_ Actually, without the g it will replace the first instance
              of oldWord in each line.  The g makes it replace every
              instance of oldWord per line. -geordan
        \_ Lots. Try sed.
        \_ the oneline perl script works great with one file. Is there a way
           to have it process whole bunch files like *.*?
           \_ Um... perl -p -i .bak -e 's/oldWord/newWord/' *
                \_ uh no, got an "invalid argument" error
                   \_ here's where you copy paste the exact command you used
                      along with exact error you got, and we go from there.
2003/10/21-22 [Computer/SW/Languages/Perl, Computer/SW/Languages/Misc] UID:10722 Activity:kinda low
10/21   I'm trying to write a Perl script with a spam assassin interface
        so that it'll take out trolls. Please keep up the troll keywords
        thread below so that I can make the program as perfect as possible.
        \_ You mean an auto-motd-censor script?  I thought these were grounds
           for sorrying of account.
           \_ it damn well better be.  hey op, go fuck yourself.
              we know who you are.
           \_ no no no, no AUTO motd script. Yes, auto motd scripts can
              get you sorried (case in point dumb ass kchang). My point is
              creating something that allows me to kill threads that I
              personally deem as troll with one push of a button instead
              of having to do it manually. So short of complete automation
              I believe what I am doing has no grounds for sorried account
              \_ it just makes you a fucking asshole.
              \_ If you can do this, then why not create a motd reader
                 that simply doesn't display threads with these words in
                 them?
                 \_ because it isn't about him not seeing it, it's about an
                    infantile need to control what others read.
        \_ how about an auto script that corrects my grammar on motd post?
        \_ how about an auto script that purges your account?
        \_ do you really want to get into scripting wars over the motd?  it's
           been very calm all these years (mostly).  if you turn it into a
           script war you'll find others writing scripts to delete the stuff
           you've deemed worthy of staying.  when we're done the motd will
           be blank most of the day.  suggestion: grow up, you're not the
           smartest kid in your HS anymore.  w3 awl g0t m4d sk1llz!1
2003/10/2-3 [Computer/SW/Languages/Perl] UID:10411 Activity:nil
10/1    In Perl, what does "\%hash" mean?
        \_ delayed evaluation of $hash in some eval code probably
        \_ Perl Reference?
           http://www.uic.edu/depts/accc/seminars/perliii/references.html
2003/9/27-28 [Computer/SW/Languages/Perl] UID:10352 Activity:nil
9/26    in a perl script I'm trying to write a reg exp to replace a
        multiline block of text with another multiline block of text but
        can't seem to get it right. any advice? thanks.
        \_ example?
           \_ if he had an example he wouldn't need help, would he?
        \_ try subbing a variable for another variable, so you don't have
           to worry about how to escape newlines within s// expressions
        \_ i am trying to do the samething without much success.  I am trying
           to remove a mult-line text block with certain pattern (for example
           "Do You Yahoo?..."  Let me know if any of you have any cool idea
           on this supposely simple problem             -kngharv
        \_ http://tinyurl.com/oya1 [removes ads from yahoo msgs]
           I ran this through s2p, did a little cleanup, and have been
           using it in my procmail script for about a year.
        \_ Two things to keep in mind:
           1) You can't do this with a straight perl -pe 's/..../' from the
              command line (without -0777), so I'll assume you have the whole
              text to be substituted on in a scalar ($text or something).
           2) Use /s at the end of your regexp: $text =~ s/.../.../gs;
              This will make things like . match \n as well, so that your
              matches won't fail at the end of a line.  When in doubt, RTFM:
              perlre(1)     --dbushong
2003/9/20-21 [Computer/SW/Languages/Perl, Computer/SW/Unix] UID:10263 Activity:nil
9/19    What's the easiest way to replace text strings in a binary file?
        I have a feeling that sed can't be used with binary files...
        \- uh you can try emacs. anymore is probably beyond the scope of wall.
        \_ perl -pi -e 's/foo/bar/g' is probably pretty safe;
           add in a -0777 first if you want to be paranoid
        \_ If you're replacing same-size strings, any hex editor will do.  If
           you're shrinking them, then fill with spaces.  If you're growing,
           you might break something if it's an executable or some self
           referenced data file like a zip.
           \_ spaces?  Why not null chars?
              \_ because code accessing those strings may run into trouble
                 with nulls/
        \_ Arrr - nold for California Governor!
           \_ Avast Right-Wing Conspiracy!
2003/9/17-18 [Computer/SW/Languages/Perl] UID:10231 Activity:nil
9/16    I have a perl script that forks off children who do some
        IO-bound work and then print a result to stdout.  Each child
        locks the STDOUT filehandle like this
                flock(STDOUT, LOCK_EX);
                 &dump_results();
                flock(STDOUT, LOCK_UN);
        but I still get child A's output mixed in with child B's.  What am
        I doing wrong?
        \_ I recall something in the perl book (I have 1st ed) about switching
           between filehandles for output.  They give some example code.  Sorry
           I can't be more helpful.
           \_ thanks, I put in some "|| die" messages and I got
              "Operation not permitted."  I switched to using an actual
              file and that seems to work.
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.
                 \_ I did search for "Yahoo" at the CPAN list:
                    http://www.cpan.org/modules/00modlist.long.html
                    Why isn't that module listed there? BTW, I'm looking
                    for an application, not a library.
                    \_ Luke!  Use the source!  *WRITE* an application!  You
                       have the power within you!  Feel it!  Reach out to it!
                       Close your eyes, unload the IDE, and just *feel* the
                       code!
2003/9/6 [Computer/SW/Languages/Perl] UID:29522 Activity:high
9/5     Is there a way to get perl to auto-escape all characters of a filename?
           \_ "\Q..\E" http://www.perldoc.com/perl5.8.0/pod/perlre.html
        Something that could be used in
        foreach $file ( <*.txt> ) {
                $escapedFile = superEscapeFunction($file);
                ...
                system("cp $escapedFile ../$escapedFile");
                ... etc.
        }
        Thanks
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/8/26-30 [Computer/SW/Languages/Perl] UID:10018 Activity:nil
8/26    Java, perl, MySQL experience?  20 hr/wk contract available.
        email me if you're interested           -brain
2003/8/13-14 [Computer/SW/Languages/Perl, Computer/SW/Unix] UID:29338 Activity:kinda low
8/13    In tcsh, how do you get * to include subdirectories?  I want to do
        something like perl -p -i -e 's/foo/bar/g' **.c
        and have the command executed on ./*.c, */*.c, */*/*.c and so on.
        \_ You can do something like:
           find . -name '*.c' | xargs perl -p -i -e 's/foo/bar/g'
           might have to play around with that, I haven't tried it  -niloc
           \- you cannot do zsh-style ** recusive globbing in tcsh.
              rather than doing something really ugly
              use find | xargs. there are also various emacs-heavy ways to
              do this. --mr emacs&&tcsh
              do this. --mr emacsbitch
2003/8/6-7 [Computer/SW/Languages/Perl] UID:29249 Activity:very high
8/5     help, there are commas INSIDE the fields of my Comma Separated File
        E.g. column 136, is  "lastname, firstname".  Now, being so
        damn clever, i figured that hey, i'll just make the field separator
        \",\" but that doesn't work 'cause the number fields aren't quotated.
        What should i do? -phuqm
        \_ ~scotsman/bin/csv.pl
           But you could just go through and add quotes around the currently
           nonquoted fields.  I've seen some stupid csv handling in any number
           of products.  Basic csv is: 1) comma separated 2) if field contains
           a comma, surround with "'s 3) if field surrounded by "'s contains
           "'s, escape the "'s as "".  Many people can't get this through
           their skulls.  --scotsman
        \_ clever? use tabs as delimiter
           \_ I didn't generate the file. -phuqm
           \_ self-depricating sarcasm is a sign of maturity. insults are not.
        \_ Find which lines have excessive # of commas and massage those data
           lines differently? Or if ALL lines are "lastname,firstname"
           then just treat it as an additional command-separated field.
           Or convert the data so that the where quotes and commas occur,
           convert them to 3 commas or some OTHER field-separator like
           # or % or something not used anywhere in your datafile
           It's very simple, so maybe i do not understand what ur asking.
           \_ Oh the sanity and simplicity of it all! Can't you make it more
              complex to show your superiority?
        \_ this is a standard CSV format.  the comma is a delimiter but the
           "x,y" is _also_ counted as a single item.  oddly enough, CSV files
           have 2 delimiters and you need to program for both the simple case
           and the "matching double quoted" case.
           \- use (f)lex --psb
              \_ use perl. type perl csv in google.
                 \_ sigh... this was covered in one of my cs60c projects.  now
                    they just type keywords into google and copy the results.
2003/7/23-24 [Computer/SW/Languages/Perl] UID:29108 Activity:high
7/22    Please rate the following languages by their usefulness for
        large programming projects and give your reasons:
        perl, python, ruby, tcl, urdu
        \_ Bangla >> Urdu
        \_ ocaml! -- ilyas
        \_ Don't use tcl.  tk was a cool idea but tcl is just cumbersome to
           use.  Perl and python depend on your own thoughts about what
           a project needs.  I personally would go with python but there are
           strong opinions on either side.  Never heard of ruby, so can't
           help you there.
           \_ and after looking at some ruby docs I have got to say it at
              least looks worth learning.
        \_ Tcl blows.
        \_ don't use tcl.  ruby = 1/2 python, 1/2 perl without perl's huge
           pre-made library at cpan.  perl vs python?  ask a priest.
        \_ Perl:   Extremely powerful and extremely ugly.  People have done
                   amazing things with it, but I find it aesthetically
                   unpalatable and do not use it.
           Tcl:    An excellent language to use to control your c programs
                   and allow users to write scripts.  Tcl's main advantages
                   are that the language structure is pretty simple and
                   compact making it easy to embed into c programs.  I've
                   used TinyTcl to control/test programs written for a DSP.
                   Tcl's main disadvantage is that the core language is
                   too simple and compact; you have to add on lots of extra
                   packages to get classes and other useful libraries.
           Python: A good language with lots of features like lambdas,
                   classes, and plenty of libraries built in.  It's not
                   quite as easy to embed into c programs as tcl, but not bad.
                   Python is my first choice mainly because of the many
                   high quality built-in and third party libraries.  The
                   language itself is also a nice compromise between the
                   simplicity of Tcl and the power of Perl while still
                   remaining quite readable. -emin
        \_ To add to the above comments, Python has reached the community
           critical mass any project like it needs to become useful.  wxPython
           is a joy to work in as well.
2003/7/19-20 [Computer/SW/Languages/Perl] UID:29080 Activity:nil 53%like:28810
7/18    hey mikeh - nice your freaking perl jobs already!
        \_ stfu malcolm.  you're the one running mutella.
2003/7/16 [Computer/SW/Languages/Perl, Computer/SW/Languages/Web] UID:29051 Activity:high
7/15    What's the best language for web scripting these days? Perl? PHP?
        Python? Something else?
        \_ PHP is really fast.
           \_ php is a pos if you need to do anything real. Perl or
              jsp/jsf is the way to go.
                \_ starting a new perl process for each web page
                   being served up will be much slower than php.
                   I'm curious if anybody has opinions on mod_perl.
                   \_ My understanding is that with mod_perl, perl outperforms
                      php--without it, it loses.  But I haven't run any
                      comparisons myself.
                      \_ I've coded in both and supported lots of coders in all.
                         PHP has the quickest dev. times, is easiest to do almost
                         anything and has had the least problems.  (really none).
                         It's just my experience, but i've been on two bigish php
                         projects with no problems and have never dealt with a
                         java or mod-perl project where there wasn't some
                         weirdness that had to be worked through.
        \_ i guess cold fusion is completely dead
        \_ do we have a LAMP set up on soda?
        \_ 'best' for what?  fastest?  more secure?  best supported?  best
           dev environment?  it's like asking if one OS is 'better' than
           another.  is this a somewhat subtle attempt to start a flame war?
           you need something less subtle to get a good flame fest going.
2003/7/10-11 [Computer/SW/Languages/Perl] UID:28994 Activity:nil
7/9     Perl question:
        s#<(/?[A-Z]+)>#<lc(\1)>#ge
        I'm trying to lowercase my HTML tags. that would work if I could get
        perl to execute my lc... the e flag doesn't work because I don't want
        to evaluate the "<>" in the second half of my regex.
        However, it does work when I do something stupid like:
        s#<(/?[A-Z]+)>#$f="<";$f.=lc($1);$f.=">"#ge
        \_ I believe s/<(\/?[A-Z]+)>/<\L$1\E>/g would work.  -niloc
           \_ Thanks, I adjusted it to: s#<(.*)?>#<\L$1\E>#g
              to work for things like <A HREF="yomama">
2003/7/7-8 [Computer/SW/Languages/Perl] UID:28950 Activity:nil
7/7     I want to use perl for some inplace substitution a la
        perl -p -i.bak -e 's/pattern/replacement/g' but I want to know if
        my pattern will be matched correctly.  I've tried
        perl -pe 'print if /pattern/' * but that just prints all the lines.
        What's the right way to do this?
        \_ -p implicitly prints the line. Try -n instead.
           \_ thanks, is there a perl manual section that describes CLI opts?
              \_ from "man perl"
                 perlrun             Perl execution and options
                 so... "man perlrun"
                 \_ argggg.... thanks.
2003/7/3 [Computer/SW/Languages/Perl] UID:28920 Activity:nil
7/3     Cygwin on NT4 question: is there any way to make the following work?

        % ls -l s
        -rwxrwxrwx    1 joeuser  mkpasswd     7512 Jul  3 15:36 s*
        % perl -p -i -e 's/define/FOOO/g' s
        Can't do inplace edit on s: Permission denied.
        % ls -l s
        ls: s: No such file or directory
        So perl says it can't write to the file, but it can, and then it
        deletes it.  This happens on every file I've tried.  TIA.
        \_
        http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=3DA606DD.EEA0B29C%40acm.org
2003/7/3-5 [Computer/SW/Languages/Perl] UID:28917 Activity:moderate
7/3     Stupid Regex question. I am trying to print if the line contains $word:
                print if /[^a-zA-Z]?$word[^a-zA-Z]/;'
        this won't work if the word is the last word on the line. i can't see
        a nice way to do that... what am i trying to accomplish? trying to
        teach someone regexp and show them how things can be more complicated
        than they seem and that
                print if /$word/
        is not sufficient.
        \_ print if /\b${word}\b/
           \_ ahhhhhhhhh. nice.
           \_ The braces aren't necessary. -geordan
              \_ but a semicolon is while we're being pedantic
                 \_ I figured that he was smart enough to figure out the
                    semicolon.  I couldn't remember if the {} were necessary so
                    I put them in.  I hoped he'd read the docs to find out what
                    \b was and all the other goodness there.  Why didn't you
                    answer the original question instead of nitpicking my
                    response?
                    \_ 1) because I didn't care to, and 2) he really
                          could've (and should've) looked in the perl book
                          for 2 minutes and it would've been obvious.
2003/7/3 [Computer/SW/Languages/Perl, Computer/SW/Unix] UID:28909 Activity:nil
7/02    anyone have any idea why NET:FTP would take 60 times longer
        to grab a file than just going throught ftp on the (linux)
        command line.  (but only on one box, my other box goes to
        the same destination fine, similar perl/cmd_line ftp times).
        \_ DNS? totally a guess
2003/7/1 [Computer/SW/Languages/Perl] UID:28875 Activity:nil
6/30    Perl Q: How do I "rewind" when iterating through a file?  I want to
        do something like
        while (<FILE>) {
           if ($_ =~ /pattern1/) {
                search backwards/upwards for pattern2
           }
        }
        What's the best way to do this?  I've tried decrementing $. but that
        doesn't seem to work quite right.
        \_ This is probably a "there's a better way to do this, grasshopper"
           thing.  Search for pattern2 first, then throw it away if pattern1
           doesn't exist.  Perl likes to move forward through files.  The
           suggestion below also applies.
        \_ If the file is small, you can do something like...
           @file = <FILE>;
           foreach (@file) {
             if (/pattern1/) {
               @file2 = @file;
               foreach $inner (@file2) { ... /pattern2/ ... }
             }
           }
           Or do a last and restart a search for pattern2. i don't know
           what exactly you are trying to do. alternatively, you can open
           up a second file handle on the same file...
2003/6/26 [Computer/SW/Languages/Perl, Computer/SW/OS/FreeBSD] UID:28843 Activity:very high
6/25    Oh man, open office completely blows.  It is way worse than any
        M$ product.  It won't let me open my tab seperated file into calc.
        It assumes it is a word document and opens it thusly.  I can't
        even cut and paste into calc.  Surely there must be a solution
        other than having to substitute commas for my tabs in all my files.
        Please help.
        \_ perl -p -i .bak -e 's/\t/,/g' *
        \_ err... how about Word Perfect series?
        \_ It is pretty bad.  Check out Crossover office from Codeweavers--
           it's pretty nice (no FreeBSD yet tho.)  -John
        \_ Ah yes.  Program A doesn't have a feature I like.  So A sucks.
           OOo has a number of features I like that are supierior to MS. YMMV
                \_ No.  OpenOffice and StarOffice both have some very very
                   annoying tendencies, such as munging formatting of a lot
                   of different doc types.  Like it or not, a lot (most)
                   business documentation is done either in .pdf or .doc, even
                   though a lot of us would prefer more people use ascii or
                   html.  And of all the office-type apps out there, MSOffice
                   is currently the least worst.  StarOffice/Openoffice/
                   koffice are a good start, but they have a long way to go
                   before people will start accepting them and tolerating all
                   the annoyances of using them.  -John
2003/6/23-24 [Computer/SW/Languages/Perl] UID:28812 Activity:high
6/23    perl open3 question: according to the manpage, both of these should
        work. The first one does. Why does the second one produce an error
        message?   "open3: wtr should not be null at ./open3.cgi line 20"
          open3(\*WTRFH, \*RDRFH, \*ERRFH, $command);
          open3($wtr, $rdr, $err, $command);
        \_ How did you assign $wtr?
           \_ Do I need to assign a value to them?
              the example just shows declaring them: my ($wtr, $rdr, $err);
              \_ don't breed.
              \_ ill assume for a moment youre not a new form of troll: yes,
                 you need to put something in a variable before passing it as
                 a parameter to a function or subroutine of some sort.  not
                 just in perl but in _most_ languages.  you scheme/lisp freaks
                 and other assorted nuts should count down slowly from 10
                 before replying.
                 \_ Okay, assigning some random value works, but not in
                    "use strict" mode.  I'm not trolling. I'm serious.
                     'Can't use string ("one") as a symbol ref while
                     "strict refs" in use at ./bin/open3.cgi line 27.'
                 \_ Not true, but I'll assume that you're just uninformed.
                    Ever heard of autovivification? Try this on a system that
                    has a resonably recent perl installed:
   perl -e 'open $foo,"</etc/passwd" or die "It didnt work!";print <$foo>'
                    (by the way this won't work on soda since the version
                     of perl on soda is fairly out of date)
                    (by the way this won't work on soda since perl5.00503
                     installed on soda is fairly out of date and doesn't support
                     this feature).
                     \_ Thank you. The machine I'm using open3 on is also
                        an older version of perl. Is there a way to use
                        $variable filehandles, or do I need to stick with
                        the glob notation?
                        \_ See the notes about IO::File in the "open" section
                           of the perlfunc man page. In summary, it's still
                           fairly simple, e.g.:

                           use IO::File;
                           my $handle = new IO::File;
                           open $handle ... blah blah
                     \_ It's a hack.  "Install latest version of perl to
                        avoid sloppy coding" isn't a real answer.
                        \_ autovivification is not a hack. It's a widely
                           used and supported feature. Take a look at the
                           third edition of the Camel book and numerous
                           articles on the net.
2003/6/21 [Computer/SW/Languages/Perl] UID:28795 Activity:kinda low
6/20    The great soda motd is unable to provide a solution or even a decent
        lead to perl scripting a robot...
        \_ Helpful responses deleted.  You're an ass.
        \_ 1) It's not our job to spoon feed you anything,
           2) you were given the right places to go to find what you needed,
           3) the other poster is right.  You're an ass.
2003/6/20 [Computer/SW/WWW/Browsers, Computer/SW/Languages/Perl] UID:28777 Activity:very high
6/19    I want to write a script (or find any workable method) of viewing
        and saving multiple sequential pages on a website.  I can do this
        in perl easily (just extracting data from source) except for cookies.
        I generated frames to let a browser handle the cookie transaction but
        mozilla won't let me save frame source (!?!). Seems like this should
        be easy.  Any advice? -jnat
        \_ have you tried 'wget' or 'curl'?
           \_ wget doesn't seem to work with http://picturetrail.com
        \_ I've thought of doing this too.  Is there a good way to emulate
           a web browser so you don't get in trouble for screen scraping?
              \_ must...supress...urge...to...make...vector...calculus...joke
           \_ curl is what you want.
              \_ must...suppress...urge...to...make...vector...calculus...joke
        \_ for those who are less geeky, there is getleft.
        \_ What do you mean by "multiple sequential pages"?  You can do
           cookies and all other browser emulation in perl.  I'm not sure
           what you're trying to do.  Me and many others have written web
                                        \_ "I"
                                           \_ Nyet, grasshoppa!  In this case
                "Me and many others" is a single plural term.  This is not
                what you were taught but did not learn in 3rd grade about
                "me and jonny were spanked for being bad" vs "I and jonny".
                In the future I'll confine myself to the simpler forms of
                English for you so as not to confuse the masses.
                \_ if you want to be truly pedantic, it's "Johnny and I."
           spidering programs to crawl and rape other people's sites.  It's
           a reasonably well solved problem.
           \_ Okay where do I find out how to do this?  I've been doing
             google searches and reading pages and pages and not seeing
             anything client-side.
             \_ http://cpan.org.  You'll find all the modules for making http
                connections, saving and sending cookies, etc.
2003/6/2-3 [Computer/SW/Languages/Perl] UID:28609 Activity:high
6/1     I'm perl debugging under emacs. Everytime my script tries to open
        "/tmp/foo*" perl complains that it can't find it. But if I run it
        outside of emacs, it works. What gives??
        \_ I suspect that you're trying to access one specific file named
           /tmp/foo*, but perl is interpreting the * some sort of glob.  Email
           me the code where you call open and I'll see if I can figure out
           what's going on -darin.
                \_ open XX, "zcat -f --stdout ${YY} |";
                where YY is "/tmp/foo*" and is meant to be multiple files
                perl correctly interprets it as a glob when executed outside of
                emacs. But under emacs, it complains of file not found.
2003/5/28 [Computer/SW/Languages/Perl] UID:28569 Activity:nil
5/27    In Perl, how would I print a number with leading zeros if it's less
        than a certain number of digits (eg. I want 3 digits, so '2' = '002')
        I can do it an ugly way (have a bunch of 'if length' statements), but
        I'm wondering if there's a more elegant way.
        \_ printf "03%d",$variable;
           \_ always giving it away....  how will they ever learn?
2003/5/17-19 [Computer/SW/Languages/Perl, Computer/SW/SpamAssassin] UID:28467 Activity:nil 54%like:27696
5/17    What am I doing wrong?  spamassassin -r < missed-spam-message
        razor2 report failed: No such file or directory Razor2 report requires
        authentication at /usr/local/lib/perl5/site_perl/5.005/Mail/SpamAssas
        sin/Reporter.pm line 99.
        Did it get to the Bayesian learner or not?
        \_ I don't know if "-r" sends the message through the Bayesian
           learner (I'll have to check the docs). However, you can send
           the message directly with "sa-learn --spam --file missed-spam-msg"
           \_ Yes it does, apparently even with the error above. But
              sa-learn skips reporting to spam archives. Thanks! -op
2003/5/17 [Computer/SW/Languages/Perl] UID:28465 Activity:nil
5/16    Who cares about perl, women with mustaches and politics, the real
        question is how the hell did Neo pull off that crap at the end of
        the Matrix Reloaded?!?! (BTW, did you notice Trinity used nmap and
        ssh? She's pretty '1337.)
2003/5/17-18 [Computer/SW/Languages/Perl] UID:28464 Activity:low
5/16    Newbie perl question.  Does perl on csua have libraries to grab &
        parse HTML files off of remote servers?
        \_ It's been a while but it's called libwww or something like that.
        \_ perldoc LWP
2003/5/15 [Computer/SW/Languages/Perl] UID:28448 Activity:high
5/15    Perl regular expression question:
        I have a list of strings that I want to remove from a file.
        I tried to use s/$string//g for each string, but had problems
        when the $string contained special characters like (, /, etc.
        Is there a way to quote the $string so it will work?  I tried
        qr, but that didn't do the trick.
        \_ s/\Q$string\E//g
2003/5/9-10 [Computer/SW/Languages/Perl, Computer/SW/Languages/Web] UID:28387 Activity:kinda low
5/8     is there a perl equiv of the php "escapeshellarg()" function?
        \_ Tell us what escapeshellarg actually does (I can guess but...).
           I know perl but not php.  I'm sure I'm not the only one.
           \_ I'm trying to untaint a var that i will pass to a shell cmd.
              I think $ARGV[0] =~ s(')('\\'')g  should do it, but <shrug>.
        \_ You may want to look at quotemeta, but this sounds like an ugly
           hack.
           \_ open(FOO,"\Q$tainted\E |");
2003/5/6-7 [Computer/SW/Languages/Perl] UID:28349 Activity:high
5/6     How do I use sed to truncate output lines to say 60char/columns?
        \- helo "man cut" ok tnx. --psb
           \_ command | cut -c1-60
              \_ will truncate, yes, but not useful for wrapping the text.
                 \_ Was text-wrapping requested? No.
                 \_ Um.. if you wanted line wrapping, use fmt.
        \_ perl is the answer to all text modifying or extraction questions.
           \_ Ok fine.  How do I do this in perl?
              \_ command | perl -n -e 'print substr $_,0,60,"\n";' though
                 I suspect this would be trivial with sed.--scotsman
              \_ command | perl -pe 's/^(.{1,60}).*$/\1/;'
        \_ Try "fold".
        \_ Try "fmt".
        \_ Try ED! and counting out to the 60th character on each line and
           deleting everything after it.  Save the file out to a different
           file name if you need the original.
2003/4/24-25 [Computer/SW/Unix, Computer/SW/Languages/Perl] UID:28219 Activity:high
4/24    On systems without Perl, what's the easiest way to obtain the
        same results as perl -e 'print time()'?
                        \_ On systems with perl the easiest way is:
                           perl -e 'print $^T';
        \_ 5 lines of C code using libc gettimeofday
        \_ combine date with awk and do some simple math (in awk or with bc).
        \_ combine date with awk and do some simple math (in awk or
           with bc).
        \_ 'date' has %s time format.
           \_ That gives you the "current second", not the # of seconds
              since epoch time.
                \_ date +%s gives the # secs since Jan 1, 1970 on
                   FreeBSD and Linux. (It doesn't work at all on
                           if you compile gnudate on solaris it will work--psb
                   Solaris)
                        \- this is a gnudate extension.
                           if you compile gnudate on solaris it will
                           work--psb
                           \_ If he can compile stuff, then he
                              can just write a 3 line c pgm to
                              get the info he needs.
2003/4/19-20 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Perl] UID:28170 Activity:high
4/19    What's the closest thing Scheme has to a good standard library and a
        standard interpreter?
        \_ obUsePerl
           \_ Perl is a slow, broken mess.
           \_ there's a reason I like Scheme, and that reason is exactly why
              I can't stand Perl.
              \_ and that is?  If you say consistency I will laugh.
                 \_ a simple, elegant syntax.  and then there are first-class
                    procedures, first-class continuations, proper closures,
                    hygienic macros, ...
                    \_ i would rather read machine code than scheme
                    \_ Oh please.  The macros in CLisp and Scheme are a
                       nightmare.
                       \_ There is no better way to have general macros.
                       \_ ok, what's a language with a better macro system?
                          \_ I'll give you two: make, ant
                             \_ make and ant do not have a macro system.
        \_ r5rs
           \_ R5RS is the language standard.  It does not specify a standard
              library, and it's not an interpreter.
        \_ Is this for BH's project where the homeless guy gloms on to you
           until you get to campus and the campus police object beats him off?
        \_ /usr/ports/lang/scm
2003/4/11 [Computer/SW/Languages/Perl] UID:28087 Activity:nil
4/11    I need to delete a method from a bunch of classes.  How do I do
        do a multiline match and delete in perl or sed or whatever?
        Something like 's/int.*::Foo\(\).*\{.*\}//m', but that doesn't
        work.
        \_ It's been a while since I've done this but I *believe* you need to
           futz with the paragraph marker variable.  I'm sure some other perl
           guru who has done this more recently can provide a full answer.
2003/3/21 [Computer/SW/Languages/Perl] UID:27777 Activity:moderate
3/20    How do you get the error code of a system program in bash (or perl)?
        If I have in my_error.c int main (...) { exit (234); }
        how do I get that 234 in a variable?  In bash,
        ec=my_error  // sets $ec to the string "my_error"
        ec=`my_error` // sets $ec to the stdoutput of my_error
        and I get similar results in perl.  What am I doing wrong?
        \_  $  ./my_error
            $  echo $?
        \_ In perl, assuming the "hello_world" program merely prints
           the text "hello, world!":

            $foo = `./hello_world`; ## $foo now has "hello, world!"
            $exit_val = ($? >> 8);  ## $? contains the exit status as well
                                    ## as exciting flags in the low
                                    ## bits; perldoc perlvar for more.
           -geordan
2003/3/14 [Computer/SW/Languages/Perl, Computer/SW/SpamAssassin] UID:27696 Activity:nil 54%like:28467
3/13    I got the following error:
        spamassassin -r < tmpSpam.txt
        razor2 report failed: Bad file descriptor Died at
        /usr/local/lib/perl5/site_perl/5.005/Mail/SpamAssassin/Reporter.pm
        line 77, <GEN1> line 1.

        What have I done wrong?
        \_ this is a FAQ. you need to create an id with razor-register
           \_ now i really feel stupid.  I did created an ID though.
                I'll look at it again.  thanks
2003/3/12-13 [Computer/SW/Languages/Perl] UID:27671 Activity:low
3/11    In unix what function/lib can I use to translate from a date to an
        integer value (given month/day/year, it returns a value), and
        vice versa? Thanks...
        \_ how about using a search engine? why wait several hours
           for an answer on the motd? i mean even "man -k time" would
           have given you the answer. you loser troll.
        \_ mktime and localtime, respectively.  You might also have a look
           at strftime and strptime, which convert between the integer value
           and human-readable strings.
        \_ Could you clarify what you are using?  Are you writing a C program?
           a perl script?  An sh script?
        \_ You could probably do this using strptime and then futzing around
           with the tm ptr.
        \_ perl
        \_ If you don't care what the integers are, you could concatenate
           the year, month, and day into something like "20030312". Use
           positional string operators to create and extract. You'll have
           Y10K problems if you stick with a 4-digit year. It's not an
           int, but neither are the numbers used in mktime(), etc.
2003/3/8-9 [Computer/SW/Languages/Perl] UID:27626 Activity:kinda low
3/7     How can I get "perl -MCPAN -e 'install module'" to get via http
        or passive ftp? Regular ftp access doesn't go through my firewall.
        \_ perldoc CPAN discusses how to go through firewalls.
        \_ It's been a while but I believe the first time you try this it
           will ask you to config a bunch of stuff including the network.
           \_ That uses non-passive FTP, but this worked:
                 perl -MCPAN -e '$ENV{FTP_PASSIVE} = 1; shell'
                 from "perldoc CPAN"
2003/3/4-5 [Computer/SW/Languages/Perl] UID:27599 Activity:moderate
3/4     perl god, I want to match AAA but not AAAA, so I tried
        perl -ne 'print if /A{3}/'
        How come it still matches both AAA and AAAA?  - perl tyro
        \_ /(?<!A)A{3}(?!A)/
        \_ try /[^A]A{3}[^A]/ (edited)
           your syntax matches AAAA because AAA is within AAAA (ie, it could
           be AAA or AAAA or AAAAA or sdfAAAsdfa, and it'd match). This syntax
           says after the 3 A's, match any character that's NOT A.
           \_ you probably want something like
              /^(.*[^A])?A{3}([^A].*)?$/
              (otherwise you won't match "AAAfgdsfg" or "dsgffdsAAA") -alexf
              \_ This won't match multiple AAA's on the same line, will it?
                 (i'm still a grade schooler in regexp foo)
                 \_ Yes, it will match the first set, so that's still a match.
                    But it makes assumptions about lines and so forth.
2003/2/27-28 [Computer/SW/Languages/Perl] UID:27558 Activity:high
2/27    How do I remove blank lines and comment lines (starting with `#`)
        from a file?     - unix newbie
        \_ sed/awk, perl, java, c, c++, etc
                \_ hi asshole!
                   \_ BWAHAHAHA!  You just made my day!
                \_ how do I use the "etc" command?  I have this thing called
                   "etc" on my computer but I can't run it.  How to run etc?
        \_ grep -ve ^# -e "^[ ]*$" file > newfile
           (this will also remove lines with just whitespaces)
        \_ perl -ni -e 'print unless /^(#.*|\s*)$/' filename
           ...I think.  And there's no real need to delete or overwrite
           my entry unnecessarily just because you don't like perl.
           Note that this will edit the file in place, as the question
           implies.
           -geordan
           \_ What's the perl manpage to see what various commandline args
              do? I use -p, but don't know what -n does.
              \_ perldoc perlrun
                 -n is the same as -p, except it doesn't print $_ at the
                 end of the loop. -geordan
        \_ Thanks for all the help!  - op
2003/2/15-16 [Computer/SW/Languages/Perl] UID:27420 Activity:moderate
2/14    how do people do floating point arithmetic in /bin/sh? i make
        calls to bc, but i was wondering if there's a better way.
        \_ I use awk.
        \_ I use dc.
        \_ use perl!
           \_ too heavyweight
                \_ doing the whole thing in perl is probably more lightweight
                   than doing it in sh and forking off everything you need to
                   fork off to actually accomplish your task.
                   \_ well, that naturally depends on how much floating point
                      arithmetic or other non-native-to-sh stuff you need to
                      do in the script...
2003/1/27 [Computer/SW/Languages/Perl, Industry/Jobs] UID:27209 Activity:high
1/26    I asked my two managers (why do I have two? for double the work!)
        \_ Go one manager up and get one of your managers fired.
           Sounds management-top-heavy:  "too many chiefs, not enough
           (American) Indians."  Managers are essentially overhead.
        to hire another sysadmin to help with the workload they
        are forcing on me.  I asked for an SA with experience and
        who knows some Perl.  Am I being unfair to expect an SA to know Perl?
        They are trying to get me to accept 3 internal candidates of
        which only one even knows bourne shell programming. I feel
        they are trying to dump someone on me which will only make
        my workload worse. They refuse to hire someone external.
        How do I convince my boss(es) of the validity of my concerns?
        I have one meeting with them tomorrow (Monday) before they decide.
        \_ I can't really help you with convincing pointy-hairs about anything,
           but I'd be surprised if any mid to high-level sysadmin didn't
           profess at least familiarity with perl.  On the other hand, if
           they're a decent shell programmer it won't take long to pick it
           up.  -tom
           \_ They will be paid $80K/year. Is that considered
              low or mid level nowadays?
              \_ In this climate, probably mid level.  Can you make the
                 economic case for it?  Perversely enough, even pointy hairs
                 with poor analytical skills tend to buy well reasoned
                 arguments when it comes to money, provided you walk them
                 through slowly.  Something like this:
                 a) You are overburdened.
                 b) This is costing your company money.
                   i. There are a fair number of studies that show employees
                      are more productive when they are not scrambling to
                      smash too many tasks into their day-- find one.  In the
                      worst case, you quit, and they incur the cost of hiring
                      a replacement, which some HR wonks claim this runs as
                      high as 25% of hiring salary (presumably your salary
                      is greater than that of the new sysadmin they will
                      hire/transfer)
                   ii.There are other arguments you can make to support the
                      idea that overworking you will cost your company money
                      in the long run.  Just make sure you don't end up
                      threatening to quit unless you're willing to make good
                      on it.  And don't shoot yourself in the foot by somehow
                      making it look like it's your fault that you are
                      overburdened.
                 c) Thus, you need a junior or co-sysadmin
                 d) If the new sysadmin has any holes in his skill set, then
                    it will obviously fall to you to train him.  Training
                    the new recruit adds to your overburdened status, and
                    though it benefits the new guy, it takes away from time
                    that both of you could be doing productive work that
                    benefits the company at large.
                 And on that note, I may be looking for a job, I know perl,
                 and have references that can vouch for this.  If you do end
                 up looking outside your company, and you'd like to chat
                 further, drop me an email. -dans
               \_ In this climate i'd say someone already there for the last
                  year who is making 80K would be "mid-level".  You can
                  definiteley hire "senior level"  sys admins in this market
                  for 80K.  You CERTAINLY should be able to get someone
                  who knows at least some PERL.  Also, if this was 1 year
                  ago, i'd tell you that you should quit any place that
                  doesn't let YOU as the only Unix admin, have a pretty
                  damn big say in hiring another one.
                  \_ For 80K they should write perl while juggling hot spares
                     on the main file server and hand-crafting packets to get
                     them through the shitty router...  Call me.  I'd love to
                     do just a little perl on top of mid-level SA stuff for
                     80K. --scotsman
                     \_ Starving people are always willing to do whatever while
                        they're starving.  You'll quit the moment the economy
                        improves.  Desperate people stink of it.
                        \_ Um.  80K for midlevel SA is far from starving.
                           hell, it's about average for a senior, non-manager
                           admin.
                           admin. --scotsman
                           \_ Missing point: he's desperate to work for 80k now
                           \_ ...and he's a sysadmin.  enough said.
                              \_ So he gets to manage liquidating capital
                                 equipment?
                              but will quit the moment the economy turns around
                              in the slightest.
                              \_ when the mean goes up to, what, 81k?  if i
                                 like the position, i stay.  the job i have now
                                 was out of sheer desparation, and for a while
                                 it was hell, and i would've taken the first
                                 opportunity that came up.  Over the last 3
                                 months because of changes in management and
                                 raises, it's gotten much better and I'm happy
                                 to stay.  Avg. salaries don't rise as quickly
                                 as you seem to think.  Certainly not enough
                                 to risk my livelihood at "the moment the
                                 economy turns around in the slightest."
                                 --scotsman
                                 \_ You still reek of desperation.  Sorry, but
                                    if it shows on the motd, you're not making
                                    it through an interview until you mellow.
                                    \_ i agree. he should call em up and say
                                       "let me hear you beg, bitch."
                        \_ Dude, you work for a company that pays inflated
                           salaries in a down market.  Don't act so smug.
                           \_ Missing point: he's desperate to work for 80k now
                              but will quit the moment the economy turns around
                              in the slightest.
                           \_ I bet you were one of those bitches who bragged
                              about the six digits they were making in the
                              boom time.
2003/1/26-27 [Computer/SW/Languages/Perl] UID:27204 Activity:high
1/26    I asked my two managers (why do I have two? for double the work!)
        to hire another sysadmin to help with the workload they
        are forcing on me.  I asked for an SA with experience and
        who knows some Perl.  Am I being unfair to expect an SA to know Perl?
        They are trying to get me to accept 3 internal candidates of
        which only one even knows bourne shell programming. I feel
        they are trying to dump someone on me which will only make
        my workload worse. They refuse to hire someone external.
        How do I convince my boss(es) of the validity of my concerns?
        I have one meeting with them tomorrow (Monday) before they decide.
        \_ I can't really help you with convincing pointy-hairs about anything,
           but I'd be surprised if any mid to high-level sysadmin didn't
           profess at least familiarity with perl.  On the other hand, if
           they're a decent shell programmer it won't take long to pick it
           up.  -tom
           \_ They will be paid $80K/year. Is that considered
              low or mid level nowadays?
              \_ In this climate, probably mid level.  Can you make the
                 economic case for it?  Perversely enough, even pointy hairs
                 with poor analytical skills tend to buy well reasoned
                 arguments when it comes to money, provided you walk them
                 through slowly.  Something like this:
                 a) You are overburdened.
                 b) This is costing your company money.
                   i. There are a fair number of studies that show employees
                      are more productive when they are not scrambling to
                      smash too many tasks into their day-- find one.  In the
                      worst case, you quit, and they incur the cost of hiring
                      a replacement, which some HR wonks claim this runs as
                      high as 25% of hiring salary (presumably your salary
                      is greater than that of the new sysadmin they will
                      hire/transfer)
                   ii.There are other arguments you can make to support the
                      idea that overworking you will cost your company money
                      in the long run.  Just make sure you don't end up
                      threatening to quit unless you're willing to make good
                      on it.  And don't shoot yourself in the foot by somehow
                      making it look like it's your fault that you are
                      overburdened.
                 c) Thus, you need a junior or co-sysadmin
                 d) If the new sysadmin has any holes in his skill set, then
                    it will obviously fall to you to train him.  Training
                    the new recruit adds to your overburdened status, and
                    though it benefits the new guy, it takes away from time
                    that both of you could be doing productive work that
                    benefits the company at large.
                 And on that note, I may be looking for a job, I know perl,
                 and have references that can vouch for this.  If you do end
                 up looking outside your company, and you'd like to chat
                 further, drop me an email. -dans
               \_ In this climate i'd say someone already there for the last
                  year who is making 80K would be "mid-level".  You can
                  definiteley hire "senior level"  sys admins in this market
                  for 80K.  You CERTAINLY should be able to get someone
                  who knows at least some PERL.  Also, if this was 1 year
                  ago, i'd tell you that you should quit any place that
                  doesn't let YOU as the only Unix admin, have a pretty
                  damn big say in hiring another one.
                  \_ For 80K they should write perl while juggling hot spares
                     on the main file server and hand-crafting packets to get
                     them through the shitty router...  Call me.  I'd love to
                     do just a little perl on top of mid-level SA stuff for
                     80K. --scotsman
2003/1/22 [Computer/SW/Languages/Perl] UID:27185 Activity:nil
1/21    Talk on "Managing Large Relational Databases With Perl"
        Free.. free food.. some free books.. Wed night in Mountain View
        http://www.mindsource.com/bofs/bof46.html
        questions to shac@csua.berkeley.edu
2003/1/7-8 [Computer/SW/Languages/Perl] UID:27015 Activity:moderate
1/7     Could the Great Gods of Soda Root install the perl RSS module?
        >perl -MXML::RSS -MLWP::Simple -e ''
        Can't locate XML/RSS.pm in @INC (@INC contains:
        /usr/libdata/perl/5.00503/mach /usr/libdata/perl/5.00503
        /usr/local/lib/perl5/site_perl/5.005/i386-freebsd
        /usr/local/lib/perl5/site_perl/5.005 .).
        BEGIN failed--compilation aborted.
        thanks. - a fan
        \_ Mailing root is more effective. --scotsman
           \_ done.  Installed.  Thanks, scotsman and root.
2002/12/29-30 [Computer/SW/Languages/Perl] UID:26935 Activity:insanely high
12/29   I got a gift certificate for xmas.  What is everyone's favorite book?
        \_ Profiles in Courage, something the shrub should read (if possible).
        \_ APUE, by WRS
        \_ http://csua.org/u/746
        \_ the necronomicon
        \_ As I Lay Dying
        \_ Mein Kampf
        \_ "Thank You For Smoking" - danh
           \_ a danh xmas: link:csua.org/u/747
        \_ O'Reilly's advanced perl book.
           \_ fucking nerd.
              \_ *laugh*
           \_ Perl sucks!
              \_ yeah dude i use .bat files for everything! rewlz!
        \_ The Holy Bible, KJ version.
        \_ Ten Things You Can't Say in America
        \_ Ian Banks' Culture books.  Anything by Terry Pratchett.  Anything
           by Tolkien.  If you want 'serious lit,' try Master and Margarita
           by Bulgakov (recommended by every russian alive!).
          \_  "Envy" by Olesha                  -brain
           \- hello. how do you recommend somthing for someone too dumb
              to specify a genre or otherwise narrow the question a little.
              danhimal: is the C. BUCKLEY books a cheap thrill or is it
              actually good? i dont like PJOROURKE-typestuff. Can you read
              "The War on|against cliche" and report back if it holds up?
                    is just awful in english [likw r. tagore is awful in
              'DYING is certainly a fine book, but I suspect OP will throw
              an E_TOOSHORT on it. To RUSSIAN PARTY, if I had to read one
              PUSHKIN, which work would you recommend. Ok tnx.
                \_ I read every genre except "russian literature"  and
                   estrogen-specific books (romance novels, new age tripe,
                   etc. none of which i would expect to be recommended -
                   in earnest - on the motd) and if some soda geek told me
                   that some romance novel REALLY was their "favorite" book
                   (and I believed them)  I might very well go buy/read it.
                   As a general rule I will read any book which any male
                   says is their "favorite" regardless of genre.  This
                   scheme rarely misfires and has led to my reading many
                   good books that i might otherwise have missed. (The
                   few times it has misfired were cases of books i was
                   going to have to read anyway like _Fountainhead_, or
                   recommendations by not overly bright females, which
                   lead to the modification of the rule incorporated above.
                   \_ would you rather read something recommended by a stupid
                      male or a smart female?
                   \_ Stupid troll.  Russian lit isn't a genre.
              \_ Thank You For Smoking is good.  Maybe you read
                  his not so funny book on washington politics.
                  its nothing like that. - danh
              \_ Reading Pushkin in English is kind of like reading Shakespeare
                 in russian -- doesn't work too well.  Onegin is his famous
                 work.
                 \- well i feel i got something out of reading dante/homer/
                    goethe/vergil in english ... although in some cases i
                    could tell you were missign a lot. however i wasnt that
                    blown away by moliere in english. are you saying it
                    is just awful in english [like r. tagore is awful in
                    english] or just non-optimal? i thought karamazov
                    was stunning in english. but that may be more idea-
                    heavy than language heavy. i didnt think much of the
                    E. Onegin opera however. ok tnx.
                    \_ For Moliere in English, there are very few decent
                       translations.  Every once in a while you get lucky.
                       \- "get lucky"? this seems a dumb comment.
                       Try Mamet and Stoppard for russian translations (I
                       know they both did some Checkov.  I don't know about
                       verse)
                    \_ Ugh.  Reading Dostoyevsky is like eating bricks.
                       In any language.  Ugh.  Heavy, heavy guy.  Shakespeare
                       doesn't flow right in russian.  Russian is a 'suffix'
                                     \- your post doesnt "flow right" [sic]
                                        in english :-)
                       language, English is a 'root' language, so stuff
                       really doesn't translate right.  But shrug, give
                       Onegin a try.
                        \_  with dostoyevsky it all depends on the trans-
                            lation.  Stay away from Constance Garnett in
                            my opinion, and it will be a lot better.  One
                            of the best books I read this year was If On
                            a Winters Night a Traveller by Calvino. -sax
                        \_  you might want to try just skipping over all
                            the spiritual and philosophical discussions.
                            sure you will miss out a lot, but reading the
                            soap opera bits of brothers karamazov wasnt
                            sooo heavy.  entertaining, even.
                                 \- uh so you are saying "just see the
                                    movie".
                            \_ His density has nothing to do with subject
                               matter, imho.  He is just gray and depressing
                               like a lead isotope.
              \_ russian jews -> soap and lampshades is a better idea
        \_ Gravity's Rainbow by Pynchon.
        \_ nice troll. subtle.  succict.  Most troll/char ratio.
           \- well strictly speaking much of it turned into
              a reasonable discussion not senseless bickering.
              LEMON -> LEMONADE and all that. --psb
2002/12/21 [Computer/SW/Languages/Perl] UID:26881 Activity:nil
12/20   Perl question:
        # Doesn't work
        my @list = (1, 2, 3);
        my $name = "list";
        print("@$name\n");

        # Works
        @list2 = (4, 5, 6);
        $name2 = "list2";
        print("@$name2\n");
        \_ Short answer: replace the second line with  my $name = \@list;

           Long answer: using a string like "list" to access the variable
           @list is called a symbolic reference.  It works, but there are
           some restrictions -- for example, if the variable @list gets
           garbage-collected, your reference won't work anymore; also, as
           you noticed, it only works with global variables.

           If you use \@list instead of "list", then you get a real (non-
           symbolic) reference, which you can use exactly the same way but
           doesn't have the problems above.  See "man perlref" for details.
           --mconst
           \_ thx for the explanation.  I'm not sure my $name =\@list
              is what I want, because I may want to pass "$name" as a command
              line argument to choose between different lists.  Actually,
              someone may want to do that, not me.  I was just helping.
2002/12/19 [Computer/SW/Languages/Perl, Computer/SW/Unix] UID:26866 Activity:nil
12/19   Newbie question - I'm not a CS or engineering or even a tech major so
        please don't jump all over this.  What I'd like to do is replace all
        occurrences of a word in an original file with a word in an infile,
                                                   ^^^^^^^^^^^^^^^^^^^^^^^???
        and output a new file.  I want to iterate this process for all the
        words in the infile list (the word to be replaced in the original file
        remains the same).  Greatly appreciate any suggestion on which
        utility or script would be most suitable for this kind of job.
        \- emacs, sed, perl can all do this. i dont understand precisely
           what you are trying to do, however. --psb
           \_ ED is the standard text editor.
           \_Thanks for your guys help so far.  What geordan summarized below
                is what I'm trying to do
                \_ I'm not on crack!  Yay!  ...Ohhhh -geordan
        \_ So the original file is basically a template which contains
           one or more words that needs to be replaced, and the infile
           contains a list of words that will be substituted into the
           template file?  It's late and it's hard for me to word that.
           Anyway the output is a bunch of files, one for each word in
           the infile?  I'd use perl. -geordan, who should just go to sleep
           \_ in bash:
                for i in `cat infile`;
                do
                        cat ORIGINALFILE | \
                        perl -p -i -e 's/YOURWORD/$i/g' > \
                        ORIGINALFILE.$i;
                done
              [ reformatted - formatd ]
        \_ i thought grep was the standard quickest solution for this sort of
           thing but okay the above looks fine. or you can grep using the same
           regexp 's/YOURWORD/$i/g' ?  i think
        \_ Uh you sure?  I don't think this is doing quite what the OP was
           asking but I admit I'm not sure what the OP really wanted either.
           \_ I think it's along the lines of what he wants but I'm not
              sure if the $i in the perl regexp will be properly escaped.
              \_ Replace the single quotes with double quotes and it will
                 be interpolated.  Also the -i flag doesn't really make
                 sense as you're not really modifying the file in-place.
                 -geordan
2002/12/13-14 [Computer/SW/Languages/Perl] UID:26807 Activity:nil
12/12   is there any mysql+perl code on soda anywhere?
        \_ obGoogle
           \_ i dont want google, i want some "in production" soda code.
              i've already seen some google examples (non particularly useful).
        \_ just install bugzilla and look at that
2002/12/9-10 [Computer/SW/Languages/Perl] UID:26768 Activity:nil 66%like:26124
12/9    how do i setuid in perl?
        \_ $> = newuid
           (this sets the effective uid; perldoc perlvar for more.) -geordan
2002/12/9-10 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Perl] UID:26764 Activity:moderate
12/9    help, i can't seem to figure out how to get the group info for a given
        user from c.  In perl i'd just do @theuser=getpwnam USERNAME;
        $theuser[3] would be what i'm looking for.  How do i do this in c?
        \_ man getpwent
        \_ getpwnam()
2002/11/27 [Computer/SW/Languages/Perl, Computer/SW/Languages/Misc] UID:26644 Activity:nil
11/26   With procmail, I'd like to pipe some email trough a perl script
        then pass it on to the appropriate mail folder. Is it possible
        to use procmail's function to write the email into the folder
        after the script processes it, or does the perl script have
        to do the final append to the the mail folder?
        \_ Yes, no.  A rule like
             :0 fw:
             | scriptname
           will do this.  The f means pass all mail that hasn't matched
           yet through that script as a filter.  The w means pay attention
           to exit codes and if it fails, go on. man procmailrc for more info.
           --scotsman
           \- mailgent has a perl escape however you maybe be E_TOOSHORT
              to run mailagent. --psb
        \_ I want to do two things to any message that matches a pattern. I
           know how to either file it or pipe it into a program. I'm
           wondering if I can do both in one reciepe: pipe then file.
           Do I need to make two passes to do this? -op
           \_ I've seen some interesting things with re-entrant procmail,
              but your goal is probably simpler than that to accomplish.  What
              is the goal?  Give an example.
           \_ use a {} block.  check ~mconst/.procmailrc for examples.
              --scotsman
2002/11/15-16 [Computer/SW/Languages/Perl, Computer/SW/Unix] UID:26560 Activity:moderate
11/15   What's the best way to print out a certain line number in a file?
        The best I could come up with is something like:
                head -(line # you want) filename | tail -1
        \_ Actually, i think ED is the answer
           \_ close.
           \_ echo number|ed filename
              But it will print the number of bytes in the file when
              ed starts up.  ED is the STANDARD!  Text processor. -geordan
        \_ sed -n <line#>p < filename
           \_ thx!
              \- hola, i think sed is a better tool than pl in this case
                 although a speed check would be interesting.
                 more generally sed -n 'X,Yp' will print out the inclusive
                 range from [X-Y]. On a big file this may be slightly better
                 although perhaps not a real big deal on mondern machines:
                 sed 'Xq;d' ... you do get more "sed intimidation points"
                 for the latter as well. --psb
                 \- i ran some tests on a sun blade 1000 lookin for a pretty
                    deep line on a medium big file ... about 60million lines.
                    here are the relative speeds:
                    wc -l: 1
                    sed: 1.03
                    perl4: 1.59
                    perl5: 3.85
                    stragely some old intuition about sed doesnt seem to
                    apply any more ... maybe it is because memory has
                    grown so much compared to typical files. --psb
        \_ You *know* there's a 1 line perl answer to this....
           \_ perl -ne 'print if $.==number' filename
              -geordan
           \_ ah! but where is the ocaml answer for this?
2002/11/4-5 [Computer/SW/Languages/Perl] UID:26406 Activity:high
11/4    Ok, I rtfm'd and stfw'd. How in perl do I swap 'foo' with 'bar' and
        'bar' with 'foo'? I assume it has to be one s///g statement, but how?
        \_ let the "I can do this in .... notes" olympics begin!
           I'll start.  I think you want:
                perl -pi -e `s/foo/bar` filename
           \_ I wonder if perl is a good candidate for upperbounding kolmogorov
              complexity of various text processing programs.
           \_ I think he wants to swap them.  Not just simple replace.  There's
              probably a more elegant way, but easiest is to use three replaces:
                s/foo/%%placeholder%%/g
                s/bar/foo/g
                s/%%placeholder%%/bar/g
              If it's a complex match, you'll probably want to do grouping,
              and will need some temp variables to save grouping matches across
              s/// statements, --scotsman
              \_ Ah ok. Thx. I was thinking there was some magical perl
                 operator that would do this for me in one statement.
                 \_ s/foo|bar/{foo=>'bar',bar=>'foo'}->{$&}/ge
                    --dbushong
                    \_ niloc's shortened solution:
                       s/foo|bar/$& eq'foo'?'bar':'foo'/ge
                       -geordan
                       \_ Wow, look at all that wasted white space... :-)
                       \_ Neat. Thx again.
                       \_ slight tweak:
                          s/foo|bar/$&gt c?bar:foo/ge
                          -alexf
                          \_ Works only on the "foo/bar" case, but I
                             appreciate the sentiment.  It also gives
                             bareword warnings, I think. -geordan
                             \_ Not in the raw perl -pe context on soda;
                                it'll (naturally) start screaming bloody
                                murder once it's using -w or something like
                                that. A hack's a hack =) -alexf
2002/10/21-22 [Computer/SW/Languages/Perl, Computer/SW/RevisionControl] UID:26264 Activity:high
10/21   At work, i act as a tech support for a small company,
        I am thinking of dump all the manual, release notes,
        and all the problem i have encountered in the past into
        a sort of knowledge DB... I just want able to search
        things by keyword, nothing fancy.
        what kind of open source content management package
        should I use? there are too many of them at sourceforge.
        I would like to hear you guys' experiences
                                -kngharv
        \_ just create HTML pages and let Google search them for you.
        \_ I went through this exercise recently for a client. There are NO
                good open-source KM products but the defintion of KM varies
                widely. Many people find Wiki and search engine acceptable.
        \_ How to use mysql and perl/cgi front end?  How to get into Cal and
           knowing to write English goodly?
           \_ don't be an ass.  he got two words wrong.  How many languages
              can you write fluently?
              \_ thanks man.
              \_ just the one that counts in this country and unlike you I
                 provided an answer.  he didn't get two words wrong.  he
                 butchered the mother tongue.
2002/10/21-22 [Computer/SW/Languages/Perl] UID:26263 Activity:very high
10/20   What's a good data structure / pattern for a winamp-style
        "Jump-To" dialog?  User types in a "foo bar", and the window
        returns existing files such as "Foomatic Hyperbaric", "Bare Food"
        etc.
        \_ I checked out XMMS, and it just uses an iterative approach:
           separate the words by whitespace, then
           foreach filename {
                f = lowercase (filename)
                foreach word {
                        if (!strstr(f, word) return NO_MATCH
                }
                return MATCH
           }
           It turns out that processors are just fast.
        \_ I doubt there's any magic.  I think most likely it just does a
           substring search on each filename.  of course, if you want it to
           be interactive like winamp, you can progressively filter the
           results.
           \_ the poster wants to avoid iterating on each filename
              \_ obviously, but how do you expect to be able to filter on
                 arbitrary strings without it?  You're going to need to go
                 through each filename.  Or maybe you can index all the
                 filenames by what letters they contain; the user types 'f',
                 and the program returns a precalculated list of all items
                 that contain the letter 'f'.
                 \_ duh, perl.
        \_ a trie is good for searching strings with so-and-so prefix.
           don't know if that's so great for your examples though.
        \_ perl.
           \_ Perl is actually one of the slowest languages for regular
              expression matching.
              \_ And the fastest few would be...?
                 \_ C, C++, ocaml.
           \_ wait-- would you really consider this a data-structure?
              \_ no, I don't answer the questions, I provide the solutions.
                 most motd posters who ask detailed and specific technical
                 questions are already in a thought rut and need a kick in
                 the ass to get out and solve the real problem.
                 \_ apparently you miss sarcasm as well.
                    \_ if there was any I would've spotted it.  since this is
                       the motd, i expect people to post stupid things and
                       mean them.
                        \_ Thank you Comic Book Guy!
                           \_ See what I mean?
2002/10/17 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Perl] UID:26228 Activity:nil 72%like:26236
10.17   Primary language used:
        java: .
        c: ..
        c++:  .
        perl: .
        other:
2002/10/16 [Computer/SW/Languages/Perl] UID:26197 Activity:nil
10/15   In perl5 how to do test if a variable is either blank ("")
        or just consists of whitespace? if $foo =~ // || / +/ ?
        \_ Whitespace usually consists of things like tabs as well as
           spaces, \s includes these.  You could do something like
           $foo =~ /^\s*$/
2002/10/15-16 [Computer/SW/Languages/Perl] UID:26193 Activity:nil
10/15   Alright, another perl question (I'm learning...)
        I have a 2D hash of refernces to hashes; is there some way to do the
        following in one line?
                my $ref = $myHash{"a"}{"1"};
                my $dataVal = $$ref{$someIndex};
        Thanks alot.
        \_ I think you want
                my $val = $myhash{a}{1}{$someIndex}
           assuming you have something like
                %myhash = (
                    'a' => {
                        '1' => {
                            'someIndex' => 'someValue'
                        }
                    }
                );
            Basically any hash (or array) dereferences after the first
            assume that you're accessing a reference to an array or hash.
            This means that $foo->{bar}->[baz]->{garply} is equivalent to
            $foo->{bar}[baz]{garply}.  Note that the first dereference
            requires the -> operator if $foo is a reference (in this case,
            to a hash).  Confused yet? -geordan
            \_ Yeah I'm confused.  Where the hell did you come up with garply?
               \_ 'garply' the word or 'garply' the key to an anonymous
                  hash in an anonymous array in an anonymous hash in
                  a hashref?  (Heh.) -geordan
            \_ Actually, I think that makes sense. Thanks. I was trying this:
                   my $val = $$myhash{a}{1}{$someIndex};
               which is more like what I would do if it was a scalar with a
               reference... but I think I understand the distinction now. cool.
                                                                        - op
2002/10/15-16 [Computer/SW/Languages/Perl] UID:26187 Activity:high
10/15   Can you use the "correspond" operator (=>) in perl to initialize a
        a 2D hash? I'm getting some wierd errors. Thanks.
        \_ For major funky data structures and how to build and access them
           read ~scotsman/bin/SearchReport.  Also, use Data::Dumper to see
           what you've actually created/accessed.
           \_ hm... I just want to do this, essentially:
              my %myHash = (
                  "a" => ( "1" => "foo",
                           "2" => "bar" ),
                  "b" => ( "1" => "baz",
                           "2" => "shlep" )
                  );
              \_ All your ()'s here should be {}'s.  --scotsman
              \_ All your ()'s here should belong to {}'s.  --scotsman
                 \_ Actually, I got it to work by replacing all but the outer-
                    most parens with {}. I'm still not clear on when Perl
                    wants an even-length list, and when a map... but oh well...
                    I guess the code works for now. Thanks alot.
                    \_ You should really use {}'s.  These designate specfically
                       that these are HASHES.  If you may eventually add a
                       third dimension, this will trip you up again.  Hashes
                       are basically glorified arrays, which is why your first
                       attempt was so confusing.  Say what you mean and mean
                       what you say. --scotsman
                       \_ Almost right, except that the poster had %myHash
                          instead of $myHash, so in this case ()'s would be
                          correct for the outermost set. {} designates
                          anonymous hashes and returns a scalar (a
                          reference to an anonymous hash). -geordan
        \_ Make everything a global variable!
2002/10/7 [Computer/SW/Languages/Perl] UID:26124 Activity:nil 66%like:26768
10/7    More perl q's:
        \_ sorry, this was a stupid mistake on my part.  It does work as
           advertised.
2002/10/7-8 [Computer/SW/Languages/Perl] UID:26119 Activity:high
10/6    Perl question: I want to use something like
        @files = readdir(DIR);
        and get the a list of files, not just the first one in DIR.
        How do I tell readdir to give me the whole list, not just one?
        I rtfm'ed and it only said this behavior was possible.
        \_ perl works better if you don't treat it as C.
           @file = readdir($DIR);
                            \_ perl morks better if you have a clue.
                               readdir takes an open FILEHANDLE, not a var.
                               \_ Believe it or not, with IO::Dir, it is
                                  possible to generate anonymous references to
                                  directory handles which you can then assign
                                  to regular variables.
        \_ why not just write a trivial function that does this (preferably
           using readdir)? Also, have you considered using perl's glob()?
           It could be what you need ..
        \_      opendir(DIR, $somedir) || die "can't opendir $somedir: $!";
                while( $name = readdir(DIR))
                  {
                  next if( $name eq ".");
                  next if( $name eq "..");
                  push( @files, $name);
                  }
                closedir (DIR);
            \_ or if what you really want is just the files in that
               directory:
                    opendir DIR, $somedir;
                    @files = grep {-f} readdir DIR;
                    closedir DIR;
               -geordan
                 \_ You are rad.
                \_ What is that grep {-f} doing?  That was what I didn't
                   get in the perlfunc example.
                   \_ It's the function for grep to check for truth.  in this
                      case it's the "test" function, -f, which tests if the
                      argument is a normal file. --scotsman
                      \_ You could also use this to get just directories
                         (-d), links (-l), sockets (-S)... see the perlfunc
                         page for the rest of the flags. -geordan
        \_ or:
           @files = <$somedir/*>;
                \_ even more rad.
           \_ Note that this will return all entries that would be globbed
              by the shell for *, including directories, links, sockets,
              etc.  Also I believe this actually forks off a shell process
              to run the glob, so it might be slower if you care. -geordan
2002/10/2 [Computer/SW/Languages/Web, Computer/SW/Languages/Perl] UID:26073 Activity:high
10/1    I am trying to modify an application with a pretty complicated post and
        i seem to be missing the variable names or the values that i got from
        just reading the source.  Is there a way I can change the file it posts
        to to "myfile.[php||pl||sh||whatever" and have "myfile" just dump
        exactly what is being posted to it?
        \_ if you're using the CGI library in perl,
           you can dump out all post values the page is receiving
           easily, i think the syntax is something like
           print $query->dump; - danh
            \_ Undefined subroutine CGI::dump
                \_ and actually i just tried the below
                   on a different machine and i got the same error,
                   it works on soda though - danh
                   \_ Was it a linux box? Mine is.  But your are right it works
                      fine on soda and i can just post to a .cgi here. - tnx.
                \_      #!/usr/bin/perl

                        use strict;
                        use CGI;
                        my $query = new CGI;
                        print $query->header();
                        print $query->dump;
2002/9/13-14 [Computer/SW/Languages/Perl] UID:25875 Activity:nil
9/13    Can someone install perl6 on soda?
        \_ Isn't it still beta?
2002/9/12 [Computer/SW/Languages/Perl] UID:25856 Activity:very high
9/11    Is there a way to get seconds from the epoch with a shell command
        on Solaris? Like date +%s?
        a. Solaris 2.6/7
        /usr/bin/truss /usr/bin/date 2>&1 | /usr/bin/awk '/^time/ {print $NF}'
        b. Solaris 8
        /usr/bin/perl -e 'printf "%d\n", time;'
        \_ perl -le "print time()"
           \_ damn you dave, beating me to it.  no, wait, that can't
              be dave.  he wouldn't have bothered with the ()'s.
              perl -le 'print time'
              --scotsman
           \_ perl -le 'print $^T'
              \_ is that mconst?
                 \_ no.
        \_ install GNU date
2002/8/25 [Politics/Domestic/911, Computer/SW/Languages/Perl] UID:25678 Activity:high
8/25    http://web.lfw.org/jminc/Zilla/http://www.cnn.com
        \_ Ok so someone can figure out the one line of perl required to
           replace 99% of cnn's front page with "Zilla".  So?
           \_ Do Not Question Ping. Ping Is Leeter Than Thou. -ping #1 fan
           \_ i dunno. it's funnier at 1 am on a friday. there was also
              something kind of deep about the absurdification of the bin laden
              news but I forgot what it was.
        \_ Malkovich malkovich?
2002/8/16 [Computer/SW/Languages/Perl] UID:25579 Activity:very high
8/15    My cousin wants to learn to program, but there's no CS classes
        at his highschool.  I Any suggestions on what he should study?
        I told him to study PERL, because it would help him get a good
        job.
        \_Scheme.
        \_ Personally, I learned most things I know about computer science and
           programming by writing code.  Perhaps a better way to motivate
           your cousin's education is to encourage him to code up some sort of
           project.  The trick is to reign it in so he's not trying to do
           something that's likely out of his capacity ('I want to write a
           Quake clone!').  Once you know what he wants to accomplish, choice
           of language should be straightforward.
           \_ I agree.  How about writing a game?  Java?
        \_ I'd suggest Python.  Very easy to learn, has good tools for free
           (especially wxPython), and has great online books.  See
           http://www.greenteapress.com/thinkpython.html
           for example (though this book also comes for Java).
        \_ When I was a kid we didn't have CS at HS either, so I went to
           a junior college in the evenings. You might try that. There
           might also be summer CS camps, like at stanford or other univ.
           \_ that won't work. he's in juvy.
        \_ I learned programming by reading the manual of a Casio PB-100 which
           had a 11-character display and RAM space for 27 variables and 544
           bytes of BASIC code.  I wrote a simplified version of Pac Man on it.
           (That's in 1982 and I was 12.)  So I think he should start with
           something very simple like the basic BASIC in the old days, not the
           fancy BASICs we have now.  Once he doesn't lose interest, he can
           move up to one of today's languages.  But then I don't know where
           you can find a simple BASIC these days.  -- yuen
2002/8/15-16 [Computer/SW/Languages/Perl] UID:25575 Activity:moderate
8/15    I'm looking for details on an old ACM publication.  It was something
        about "ah-ha!" programming.  It was two small, slim books but had some
        great stuff in it about how to re-think coding problems and write
        smart/fast code.  Anyone have any idea what I'm talking about?  I'd
        like to buy a copy of both books but I don't know the name.  Thanks!
        \- not programming perls and more programming pearls?
           \_ oh that sounds familiar.  thanks!  back to amazon again.
           \_ Yes.  That was exactly it.  Big thanks!
              \- oh yes PP and MPP are good books. is bentley still writing
                 a column ? the csua does/used to own them. and that should
                 be "ok tnx". i think CODE COMPLETE is an interesting book
                 too.
2002/8/15-16 [Computer/SW/Languages/Perl] UID:25570 Activity:kinda low
8/15    To the sodan who warned me about Perl CGI...What weaknesses are there
        and how do I defend?  Can you point me to a book/url/etc. for more
        information?
        \_ stfw
           http://www.google.com/search?q=perl+cgi+security
           \_ Sorry...assumed there was something specific.
2002/8/14 [Computer/SW/Languages/Perl] UID:25555 Activity:high
8/13    Do you respect Perl?  Are you a sysadmin type or a software engineer
        type?
        \_ I had a theory: sysadmins love Perl.  Software Engineers
           don't respect perl.  Is this generally true? -op
        \_ depends, which one gets me a job?    -jobless sysadm+programmer
           \_ your opinion is meaningless if you're not tall enough to
              be employed.
              \_ uhhhhhh?
        \_ do i respect a language that encourages crap to be written
           in an obfuscating manner, so that eventually i will have to debug
           some 13 yr old's attempt at stylistic prose using perl?  No.
           I'd rather read/modify something sane like java, lisp, or python.
           \_ paolo is that you?
           \_ And you're what?  15?  All languages can be written like crap.
              I've seen ancient line number oriented BASIC written beautifully.
              It isn't the language, it's the programmer.  You can't deny the
              power perl provides or the huge support base available on the
              net.  Your examples are ridiculous.  I've seen plenty of crap
              written in java and lisp.  Get out more (or would that be 'less'
              in this case?).
              \_ Wow,so the only code you'll ever have to read is the stuff you
                 write yourself?  I should be so lucky!  Look, if you have a
                 language that h1b's use, shouldn't it be a language that
                 they can't shoot YOU in the foot with after they've left
                 the country?  You do not live in a vacuum, my republican
                 friend. - I know you'd like to think so, but you don't.
                 OTHER PEOPLE'S CODE AFFECTS YOUR LIFE.  sometimes you have
                 to debug it.  Wouldn't you rather minimize that time?
                 \_ Poorly written code is often poorly working code.  If
                    it's really worth using, it's worth parsing.  If your
                    project lead is allowing shitty code from an underling
                    it's time for a talk.
                 \_ Maybe you didn't get it the first time.  I'll try again.
                    Shorter this time: shitty code can be written in *any*
                    language.  And what's up with the republican line?  Are
                    \_ and if anything, i'd think perl were more left-wing...
                    you trying to say something about Larry Wall?  Is there
                    something naturally republican about perl?  I always
                    thought languages were political party neutral.  How does
                    this change for non-American programmers?
                    \_ and if anything, i'd think perl was more left-wing...
        \_ The biggest beef I have about Perl is the nasty OO syntax.  I'm
           currently using it to develop some CGI apps and it rocks.
           Especially the large body of free libraries on CPAN, etc.
           \_ Careful with your perl CGIs.  It's very easy to write a big
              exploitable hole.  Trust *nothing*.
              \_ As opposed to other cgis?  writing for web publication
                 presupposes that you understand the security risk (or
                 should.  damn underqualified developers)
2002/8/13 [Computer/SW/Languages/Perl] UID:25548 Activity:nil
8/12    I am looking for Perl coding standard.  Does such a thing
        exist?
        \_ yes.  Grab a  2400 Baud modem.  Run telix or minicom.
           connect to another modem.  Now rip the phoneline out
           you see thost characters on the screen?  That's the universal
           perl coding standard.
        \_ standards?  If you want standards use python.
        \_ man perlstyle
2002/8/10-11 [Computer/SW/Languages/Perl] UID:25534 Activity:nil
8/9     Just curious, how many of you find perl on windows to be useful?
        I find myself writing lots of unix perl but never seem to write
        windows perl even though I keep my activestate up to date.
        \_ When i'm forced into a windows environment (like the last few
           months), it's nice to have something that i can still fall back
           on.  i still use unix perl alot.  i find a cygwin installation
           more comforting than just perl.
2002/8/5-6 [Computer/SW/Languages/Perl, Computer/SW/Unix] UID:25500 Activity:moderate
8/5     What is a good egrep regular expression for a IPv4 address?
        '^[0-9]*[.][0-9]*[.][0-9]*[.][0-9]*$'   ??
        \_ Really depends on how "good" you need it to be.  You could
           do [0-9]{1,3} if you were worried about clutter.
                \_ ([0-9]{1,3}\.){3}[0-9]{1,3}     BEAT THAT SUCKERS!!!
                   \- in my experience there are some inconsistnecies in
                      which egrep can do {} matchers ... at least between
                      sunos4, solaris and gnu. --psb
        \_ ED! er uh no... PERL!  PERL ON LINUX WHILE RIDING BIKE! YES!
2002/7/11-12 [Computer/SW/Languages/Perl] UID:25331 Activity:moderate
7/11    So, Linux doesn't allow suid shell scripts to work properly.  However,
        i've got plenty of suid binaries and they evidently work.  Will PERL
        suid programs work the way they should?  Is there a good URL i can go
        to and have this all cleared up for me?
        \_ yes, suid perl scripts work fine. (They work only when setuid shell
           scripts are disabled in the kernel--for security reasons).  -tom
        \_ suid shell scripts are disabled because it's really hard to block
           out every single way someone could exploit a shell script into
           doing something unintended, (changing LD_LIBRARY_PATH, IFS, PATH,
           SHELL, etc etc etc)
2002/6/29-30 [Computer/SW/Languages/Perl, Computer/SW/Unix] UID:25243 Activity:high
6/28    I have been repeatedly warned *not* to write shell scripts in
        csh/tcsh.  Is there any validity to these warnings? If so, why?
        \_ Warned by?  I write all my personal stuff in whatever the fuck I
           want (csh/tcsh/perl).  I write anything for init.d in /bin/sh
           because /bin/sh should always work so the scripts are 100%
           guaranteed portable. (heh).  /bin/sh pretty much sucks and has
           near-zero useful features but it's there.
        \_ Instead of posting your question to the motd try putting it
           to google. http://www.faqs.org/faqs/unix-faq/shell/csh-whynot
           is the classic article that explains why it's not a great idea.
           \_ For starters let's note this was written in 1996.  A lot of the
              bugs he's picking on aren't out there anymore.  A lot of the
              examples he's using are a bit contrived.  I agree csh is not the
              best thing to write in if you're going to stick it in /etc/init.d
              or write a large script that does something important but for a
              quick hack, why not?  It's there, you know it, use it and throw
              it out.  Anything longer than 5 or 10 lines is probably a Perl
              job anyway.  /bin/sh for /etc/init.d, tcsh for fun, Perl for
              real work.  Just one man's world view.
              \_ When are you people going to move to Ruby?  Perl sucks.
                 \_ When Ruby has something that looks like CPAN so I don't
                    have to reinvent the wheel everytime I want to do something
                    interesting.  I started Perl at 4.015.  Lemme know when
                    Ruby is as useful as Perl was 5+ years ago.
                    \_ CPAN ugh. That is the worst thing to happen to perl
                       with the possible exception of the stupid OO crap.
                       Perl 4 was the last great perl, it had everything that
                       was missing from Perl 3 without any of the messy
                       non-sense of Perl 5 (about the only thing that Perl 5
                       add that is of any value is my).
                       \_ CPAN is bad uh how?  And Perl5 added real structures
                          to the language making it much more useful.  If all
                          you wanted was sed/awk, use sed/awk.  Some of us are
                          too busy to reinvent the wheel or fucking around with
                          the broken data structures in Perl4.
              \_ It was written in the 80s
                 \_ Even more so then.  The date inside the URL said 96.
                    \_ It's just as relevant now.  csh still can't do basic
                       stuff like redirect STDOUT and STDERR to different
                       places.  It's a fine login shell, but it sucks for
                       programming.  -tom
                       \_ Uhm, on that point in particular, you're wrong:
                          (command >stdoutgoeshere) >&stderrgoeshere
                          (admittedly, it can't, say, juxtapose the two, but
                          that's not needed too often)             -alexf
                       \_ Why would anyone want to use (t)csh in a world
                          where ksh and bash exist?
                   Who uses ksh? _/
                          \_ Because bash is broken and stupid?
                       \_ uh... % ( some-command > someplace ) >& other-place
                      \_ I've never wanted to do the obscure shit he's talking
                         about csh not supporting.  That's what perl is for
                         anyway.  /bin/sh and perl covers everything.
                         \_ if /bin/sh and perl covers everything, why are
                            you programming in csh?
                            And really, it's pathetic that csh can't handle
                            trivial, obvious syntax like:
                            "if ( "$foo" == "bar" )".  You run into shit like
                            that all the time with csh.  -tom
                                 \- writing stuff in csh to me is like using
                                    vi for quick edits ... no matter how quick
                                    or trivial you think it will be, about
                                    half the time you get started doing
                                    something more involved and regret not
                                    starting out doing it right ... however
                                    if you want an objective list of drawbacks
                                    and gotchas in csh, that is a decent list.
                                    when it comes to tcsh there are some bugs,
                                    but everything has bugs ... those things
                                    in the famous doc are mostly design flaws.
                                    if csh works you you, do what you want.
                                    a very imporant piece of "code" at lbl
                                    consists of 3024 lines of csh ... it was
                                    supposed to be a 20 line program.
                                    "bill joy has a lot to answer for"
                                    --psb
2002/6/18-19 [Computer/SW/Languages/Perl] UID:25141 Activity:low
6/18    I'd like to do some perl programming on a contract basis.  Anyone
        have suggestions on where to go to get hooked up?
        \_ http://jobs.perl.org --scotsman
2002/5/15 [Computer/SW/Languages/Perl] UID:24838 Activity:very high
5/15    How do you use find and xargs together (correctly) if your find doesn't
        support -print0?
        \_ perl! perl! perl is the STANDARD! ...find parser.
        \_ In Bourne shell you can try omething like this:
           find . -name '*.java' > .files
           cat .files | \
           while read LINE ;
           do
               echo rm -f "'$FILE'" ;
           done
           Note this is much slower than xargs, but it is the only
           reliable way. It is also more reliable than -exec since
           not all find's understand quoting properly for -exec.
           Note that this is much slower than xargs, but it is the
           only reliable way. It is also more reliable than -exec
           since not all find's handle quoting properly for -exec.
        \_ find . -name '*.java' |xargs rm -f
           equivalent to:
           rm -f `find . -name '*.java'`
           \_ I know, but that doesn't really help me much.
              find . -name "*pl" | xargs file
              won't work if a pl file has a space in it.
              find . -name "*pl" -print0 | xargs -0 file
              works but I don't have the -print0 option on my Solaris box.
                \_ how about find . -name '*pl' |sed -e 's/\ /\\/g'|xargs ...
                   \_ Other characters like ' would also ahve to be removed.
              \_ Install gnu find on your box.
           \_ No it is not. Command expansion (``) is limited by MAXARGS.
              If your `` expand to more than MAXARGS words, then command
              expansion will fail. xargs makes sure that it never invokes
              a command with more than MAXARGS arguments so it always
              works.
2002/5/8 [Computer/SW/Database, Computer/SW/Languages/Perl] UID:24749 Activity:kinda low
5/7     Contract position working with a Perl/MySQL installation at Sonoma
        State available.  Mail tom if interested.
        \_ Will they blame me when MySQL peuks all over their data?
2002/4/23 [Computer/SW/Languages/Perl] UID:24538 Activity:high
4/23    Is there some fast way to find the number of files in a
        directory?  I'm trying to do this in a dir with over
        over 10,000 files and "ls -l | wc -l" is taking forever.
        \_ ls | wc -l
        \_ ls -1 | wc -l
        \_ echo * | wc -w (assuming no spaces in filenames)
           \_ This won't work if there's a lot of file names.
              \_ obgetabettershell
                 \_ Ok, what's your religion?  Some of us work in real places
                    and don't feel like installing tons of 'kewl' crap on
                    do this that work everywhere with the l8st kewl sh3ll.
                    every box.  There's perfectly good standard unixy ways to
                    do this that work everywhere without the l8st kewl sh3ll.
        \_ obPerl
           \_ perl -we 'use strict; my $d = shift @ARGV; if (defined $d &&
                        opendir(D,$d)) { my $n=0; foreach (readdir(D)) {
                        $n++ if (-f "$d/$_"); } closedir(D) ;
                        print "$n\n"; }' <dir>
                        \_ Wouldn't it be nice to be able to access $. for
                           directory reads?
                           \_ yes
              You can make is shorter if you leave out -w, use strict, my
              and closedir.
        \_ find . -ls | wc -l   RTFM on your version of 'find' for details.
        \_ find <dir> -type f -print | wc -l
2002/4/17-18 [Computer/SW/Languages/Perl] UID:24461 Activity:kinda low
4/16    What's the best way for my Perl program to get the TAI-UTC difference?
        That being the total number of leap seconds.
        \_ What's TAI?  You can get your UTC offset with:
           use POSIX 'strftime';
           $off = strftime('%z',localtime);
           which will give you a string like '-0700'
           Don't know of an easier way...  --dbushong
           \_ Thanks, but that's not what I'm looking for.
              TAI : Temps Atomique International. (International Atomic Time)
              It's currently 32 seconds ahead of UTC. It counts continuous
              seconds. Leap seconds are added to UTC to keep UTC
              synchronized with earth's rotation. It's explained
              under "Leap Seconds" at http://hpiers.obspm.fr/eop-pc
              \_ $TIA = $UTA + 32;    ;-)
2002/4/5 [Computer/SW/Languages/Perl] UID:24331 Activity:nil
4/4     Perl Quesiton: How do I print only the first 15 characters of a
        string? -perl-newbie
        \_ substr
2002/4/4-6 [Computer/SW/Languages/Perl] UID:24329 Activity:nil
4/5     Part time perl from home job.
        http://www.craigslist.org/sfo/sfc/sof/3398327.html
        Not for me but I figured some of you might be into it.
2002/4/3-4 [Computer/SW/Languages/Perl] UID:24305 Activity:nil
4/2     Looking for perl/script based virus. Where to find them?
        \_ Uh, you realize the difficulty a perl-based virus would have
           propagating, right?  Why not write it yourself, it wouldn't be
           hard.
        \_ d00d, u should b l00king 4 a java virus.  write once, run anywhere!
           \_ d00d, don't u know that there is no such ting as a java virus.
              java is 100% safe and secure, Scott McNealy told me so.
        \_ Why would you want such a thing anyway?  And do you want a virus or
           a worm?  There's a difference the so called 'tech' media can't
           figure out.
2002/3/16-17 [Computer/SW/Languages/Perl, Computer/SW/Languages/Misc] UID:24131 Activity:high
3/15    with I.E. I want view source to use my emacs binary.  Anyone know how
        to modify my registry to do this?
        \_ you'll probably have better luck setting emacs as the default
           HTML editor and use File > Edit instead of View Source
           \_ Yah I got that working, but not being able to change the default
              View Source program bothers me, and I'm sure it can be done.
              As a side note when loading a program via gnuclient emacs
              doesn't seem to be colorizing the document based on the correct
              mode (i.e. html-mode in this case).  Is that because html-mode
              isn't being turned on for some reason?  Is there any easy way
              to fix this?
        \_ http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/configuration/clientreg/clientregistrylayout.asp
           \_ this is kind of dumb.  If you put "<path>\foo.exe" "%1" as the
              command, IE will complain that it can't find '"<path>\foo.exe"
              "%1"'.  If you leave out the "%1", then IE will send pass the
              full path to the cached HTML file, unquoted (which causes
              problems if the path contains spaces, which it almost always will)
              "%1"'.  If you leave out the "%1", then IE will send the full
              path to the cached HTML file, unquoted (which causes problems
              if the path contains spaces, which it almost always will)
              Oh, and since View Source gets files directly out of IE's cache,
              it won't have an extension, which breaks color-coding.  Yay.
              I'll stick with File > Edit.
                \_ yah it is lame, but a quick search found a visual basic
                   program to get around this problem.  The lack of file
                   extension sucks too but hey, it works.  And this way I
                   can view source for a frame and not have it pop up the
                   totally useless notepad.exe
              \_ "Use the source!"  -- oh wait, you cant. poor you.
        \_ Use Opera--you can select the viewer program.
        \_ Use perl!  Ok to be honest I'm not sure how perl would really fit
           in to this but I'm sure active perl can be used here somewhere....
2002/3/14 [Computer/SW/Languages/Perl] UID:24111 Activity:moderate
3/13    Does anybody know a command to display the current Julian Date?
        \_ man cal
             \_ the "Julian Calendar" is not the "Julian Date"
                cal shows the Julian Calendar. the Julian date for right
                now is about: 2452347.59
                \- the power of emacs:
                (calendar-print-julian-date)
                Show the Julian calendar equivalent of the date
                under the cursor.
                 \_ The Julian period (and the Julian day number) must
                    not be confused with the Julian calendar.
                    The Julian period starts on 1 January 4713 BC
                    This is what I'm looking for.
                    \- you can do this using "astronomical date"
                    that is M-x calendar-print-astro-day or something
                    like that in emacs
                     Astronomical (Julian) day number (at noon UTC): 2452347.0
                    The emacs calenday can pretty much do anything, although
                    in some cases you might have to write some el based but
                    the primitives are all there. UTSL. ok tnx --psb
                        \_ Thanks, but how about something simple I can run
                           from the command line? By the way, how do I get
                           the number of seconds since the UNIX Epoch?
                                        \_ perl -e 'print time . "\n"'
                                           \_ perl -e 'print "$^T\n"'
                                              \- (gnu)date +%s. i think there
                                            is a program called ctime too.
                                            if you need from shell there are
                                            various astro-calculation oriented
                                            libs you can use to convert between
                                            date fmts also support for sideral
                                            time periods and such. dunno if it
                                            excists for high level lang like
                                            perl but assume so. ok tnx --psb
        \_ Everything can be done in perl.  If it can't be done in perl, you
           didn't really need it done anyway.
           \_ I'd like to see you write a device drive in perl.
2002/3/2 [Computer/SW/Languages/Perl] UID:24015 Activity:nil
3/2     Whoa, sorry about all those zombies.  Stupid Perl script bug.
        Weird -- nobody who bitched on the MOTD actually thought to mail
        me...  - bronson
2002/2/14-15 [Computer/SW/Languages/Perl] UID:23864 Activity:high
2/13    How I catch the user hitting control-c or control-d in perl?
        \_ Surveillance cameras.
        \_ system(qw(/path/to/stty raw));   --dbushong
2002/2/4-5 [Computer/SW/Languages/Perl, Computer/SW/Unix] UID:23768 Activity:low
2/3     i have the same directory twice in my PATH (the first and last
        entry). how can i remove the first entry?
        \_ set your path to null, then reset it.
           \- this is a pretty strightfwd shell programming exercise.
           the exact syntax depends on the shell. you can google for
           "uniqpath" although that may not work for you. ok tnx --psb
        \_ PATH=`echo $PATH|perl -lapF: -e'$_=join":",grep{!$p{$_}++}@F'`
           (also maintains the order)  --dbushong
2002/2/3-4 [Computer/SW/Languages/Perl] UID:23762 Activity:nil
2/3     perl is ded.
2002/1/25-26 [Computer/SW/Unix, Computer/SW/Languages/Perl] UID:23668 Activity:high
1/24    Is there a way to do the substr function in a shell script?
        I want do command | foo 4 10 to get the 4th to 10th character
        of output.  Thanks!
        \_ printf(1) might work
        \_ cut -c 4-10 if you want 4th through 10th of every line; otherwise
           you'll probably need some sed/perl hack since most UNIX utils
           treat lines as separate records. -alexf
        \_ Try awk '{print $x}' | cut -c 4-10  where x = your item in the line.
           If you need to do something with the rest of the line you can start
           playing with 'tee' and shit like that but perl is probably a better
           long term choice.
        \_ awk has a substr function.
           # substr($2,9,7) picks out characters 9 thru 15 of column 2
           {print "imarith", substr($2,9,7) " - " $3, "out."substr($2,13,3)}
           --dim
2002/1/17 [Computer/SW/Languages/Perl, Computer/SW/Languages/Misc] UID:23579 Activity:high
1/16    I want to write a simple monitoring script for a webservice that I
        have running. I Was thinking of doing something like just telnet'ing
        to port 80, doing a GET, and grep'ing for a word to indicate that all
        is running smoothly. Is there a way to script such a telnet usage?
        If so, how? Is there a better way to do this? Thanks.
        \_ perl has various ways to contact web servers.  See CPAN.  -tom
        \_ go to http://kernel.org and look for 'mon'.  don't rewrite code someone
           else has already done for you.  there's no pretty gui for it though.
        \_ google for Netsaint and thoth.
           \- lynx -dump URL > /dev/null || mail warning --psb
              \_ curl -s URL | grep -q whatever \
                    || mail -s 'warning' person </dev/null   --dbushong
                 \_ Sure but the above methods will spam the crap out of you if
                    you run them often enough to be useful (from cron maybe).
                    Use a real monitoring tool.
           \_ wget  \- not everyone needs a complicated tool. a little shell
                       hack works for a lot of stuff. --psb
2002/1/11-12 [Computer/SW/Languages/Perl] UID:23534 Activity:high
1/11    What is the Right Way to check if a program is in the user's path
        from a perl script?  I want to use ci and co in the path otherwise
        use /usr/local/bin/ci,co.  I know klugy ways to do this but was
        wondering what the recommeneded way was.  Thanks!
        \_ $ENV{PATH} .= ":/usr/local/bin";
        \_ `which ci`[motd indent god was here]
            \_ which is horrible. use type as god and steve intended.
        \_ system("ci $flags || /usr/local/bin/ci $flags");
           is the "kludgey" way (oh no, you're using the shell!)
           system('ci', @flags);
           system('/usr/local/bin/ci', @flags) if $? >> 8;
           is slightly more efficient
        \_ Just write yourself a type/which sub in perl:
           sub type {
                   local($dir,@files,$file);
                   return "" unless (defined $_[0] && $_[0] ne "");
                   foreach $dir (split(/:/,$ENV{'PATH'})) {
                              opendir(DH,"$dir") || next;
                              @files = grep(!/^\.\.?$/,readdir(DH));
                              closedir(DH);
                              foreach $file (@files) {
                                 return "$dir/$file" if ($file eq $_[0] &&
                                                         -f "$dir/$file" &&
                                                         -x "$dir/$file");
                                }
                        }
                        return "";
                }
                \_ are you sure there is no perl module that does this already?
                   \_ http://www.cpan.org  Go look and let us know.  Thanks!
                   \_ yeah, let me download yet another totally bizarre
                      perl module from http://cpan.org that was written by a
                      recently civilized shepard in outer mongolia on
                      his linux box and then let me download the 86
                      other modules his module depends on rather than
                      write a few lines of code.
2002/1/9 [Computer/SW/Languages/Perl] UID:23500 Activity:nil
1/8     Soda slow?

  PID USERNAME PRI NICE  SIZE    RES STATE    TIME   WCPU    CPU COMMAND
 9706 celia     58   0  4808K  3188K RUN     20.9H 82.08% 82.08% perl
2001/12/5 [Computer/SW/Editors/Emacs, Computer/SW/Languages/Perl] UID:23146 Activity:high
12/5    I want to use Cascading Style Sheets to force the display of code
        between <code> directives to have eight spaces for every tab. I've
        searched the web, but haven't managed to find any useful links.
        Any help would be appreciated. --twohey
        \_ I don't think CSS will let you specify things like that.
           (w3c discourages using horizontal tabs in preformatted text.
           http://www.w3.org/TR/REC-html40/struct/text.html#h-9.3.4 )  Can't
           you just use emacs or some other tool to replace all the tabs with
           spaces automatically? (If the increased file size bothers you,
           install mod_gzip or something.)
           \_ I want to cut and paste code that's formatted with eight space
              tabs and have it display correctly. It seems absurd that I
              have to translate spaces to tabs for this to work. --twohey
              have to translate tabs to spaces for this to work. --twohey
              \_ it seems absurd that translating tabs to spaces is such a big
                 deal.  just tell emacs to save files with spaces instead of
                 tabs.  get over it.
        \_ perl.  no emacs required.
2001/11/27-28 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Perl, Computer/SW/Unix] UID:23113 Activity:nil
11/26   How do I find file and symlink only that excludes a, b, and c?
        I tried: find . \( -type f -o -type l \) -name a -prune -o
                        -name b -prune -name c -prune -o -print
        and failed miserably.
        \_ find . \( -type f -o -type l \) -print | egrep -v '^(a|b|c)$'
        \_ perl
2001/10/23-24 [Computer/SW/Languages/Perl] UID:22802 Activity:kinda low
10/22   I'm importing a bareword from a perl package (e.g. Math::avogadro) and
        can do things like print avogadro and print Math::avogadro just fine.
        But if I try to use avogadro in a hash, I get the string, not the
        value.
        \_ $hash{&avogadro}    It's because it's not _really_ a constant.
           "variables" without $'s before them in perl are really
           subroutines.  (Sometimes with some more efficient magic)
           \_ Thanks! BTW, where could I have found this information?
              (If I were smarter, I might have been able to intuit it)
              \_ Hmm.  perlsyn(1), maybe?  I mean, it's just kinda general
                 knowledge that anything without anything on the front in
                 perl is a subroutine.
2001/10/19 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Perl] UID:22774 Activity:nil
10/18   How difficult is it in emacs to write a mode to quickly add a
        type to a variable?  I'd like to be able to enter a "typing-mode"
        and, eg, add "const" to the declaration of variables I
        shift-click on.
        \_ you have got to be kidding me
        \_ perl
2001/9/20 [Computer/SW/Languages/Perl] UID:22559 Activity:nil
9/20    For a long time i have been doing silly things like:
        "ls some | myfile.pl" (where myfile.pl starts with "while (<>)..."
        There must be a way to do this inside the perl script.  Please
        supply clue. note:  i tried "while (<system("/bin/ls -t1 some">)"
        \_ foreach $arg (@ARGV) {
               push(@dirs,$arg) if (-d $arg);
           }
           open(CMD,"/bin/ls -t1 @dirs|") || die "Error: $!\n";
           while(<CMD>) { &doStuff() ; }
           close(CMD);

           if you are interested in reading the contents of a directory
           consider using opendir, readdir and closedir instead of ls.
            \_yeah but i already know all the flags to order ls the way
                i want.  Anyway, i'm such a rookie i didn't even know
                you could turn a command into a filehandle, this is
                very cool, thanks.
           \_ what does the | in the open signify? --newbie
              \_ | -> pipe. open(CMD,"cmd|") does a popen() in read
                 mode, while open(CMD,"|cmd") does a popen() in write
                 mode. Note: you can't do open(CMD,"|cmd|"). If you
                 need this take a look at open2(). If you use open2()
                 your *must* save its return code which is the pid
                 of the process that open2() runs on your behalf.
                 You *must* call waitpid(pid,0) on this pid otherwise
                 you will end up with defunct processes.
2001/8/27 [Computer/SW/Languages/Perl] UID:22276 Activity:high
8/27    What is an OS level command equivalent of perl's chomp and chom?
        \_ /* not tested */
           void chomp(char *str) {
                int len;
                if (str == NULL || ((len = strlen(str)) <= 0)) return;
                if (str[len-1] == '\n') str[len-1] = '\0';
           }
           void chop(char *str) {
                int len;
                if (str == NULL || ((len = strlen(str)) <= 0)) return;
                str[len-1] = '\0';
           }
2001/8/22-23 [Computer/SW/Languages/Perl] UID:22206 Activity:kinda low
8/21    What is the emacs equivalent of % in vi? I've tried (require 'paren)
        in my .emacs but it doesn't seem to work.
        \_ You don't need all that shit.  Use ED.  No mode of ED's ever sucked.
        \_ like M-x find-matching-paren or something..
        \_ why use emacs?
           \_ you're joking right? I didn't think people were actually
              debating this stupid issue anymore.
              \- it depends on the question ... a hostile "why should i a
                 vi/pico/jove user use emacs?" is best answered "you use what
                                    \_ as compared to say vi's perl-mode?
                                       \_ Lack of a perl mode is better than
                                          a perl mode that fucks up your
                                          formatting.  -tom
                                       \_ as compared to cperl-mode, which
                                          should be the default --pld.
                 ever ratshit editor you want". a sincere "why would it be
                 worth switching to the OTE" is a reasoanble question ... but
                 the most interesting are more abstract ones like "should cs
                 students today be taught emacs-only? emacs and vi? tex?
              \_ What about stuff like gnus, mh-e, M-x shell, M-x man,
                 etc?
                 \_ Why do you want to use your text editor to do that stuff
                    anyways? there is always :! of course, if you can't just
                    open another xterm.
                 ms word?" ok tnx --psb
           \_ M-x compile, gdb, gnus, mh-e, cc-mode, java-mode, php-mode,
              shell-script-mode, perl-mode, make-mode, etc.
                                 \_ emacs perl-mode sucks.  -tom
                                    \- look, i dont expect you to actually
                                    beatout gods-perl-mode but if you have some
                                    solid suggestions write them up and post
                                    the to gnu.emacs* or comp.emacs ... that
                                    is if you are capable of anything beyond
                                    this incessant braying and carping. --psb
                                    \_ And of course you send all your
                                       suggestions on how to improve vi to
                                       the vi developers.  Idiot.  All you
                                       need to see how bad emacs' perl mode
                                       is is a single << operator and some
                                       HTML.  And that reminds me, emacs
                                       HTML mode sucks too.  -tom
                                       \_ And your comparison is to say
                                          vi's Perl and HTML modes perhaps?
           \_ VIM has something similar to the M-x compile. Syntax highlighting
              and indenting support for most languages is there too. There
              is no integration with gdb however. By the way, where are
              you ED fans? I'd like to hear your opinions..
        \_ either follow what the first poster suggested, or (better),
           look for flash-parens.el on the web. it is superior. also,
           you use emacs because is configurable and allows you to write
           scripts for it. vim doesn't let you do that. -ali
          \_ but Lisp is so slow and nasty, unlike asm... ok tnx -- psb #2 fan
           \_ You can customize vim using its (awkward yet useful) built-in
              language or, if that is not enough, you can compile vim with
              perl and/or tcl support.
              \_ you can also compile nvi (which is much more pleasant on
                 first experience than vim) with perl and tcl support, but it
                 doesn't have all of the (clanging) bells and (piercing)
                 whistles..  it just, well, edits text
                 \_ I wish it were able to, well, edit your (purple) text.
2001/8/14-15 [Computer/SW/Languages/Perl] UID:22108 Activity:very high
8/13    What are people's opinions on large projects written in perl?  I have
        heard from a very reliable source that large (more than a couple of
        tens of thousands of lines) projects collapse under their own weight
        if written in perl.
        \_ Yeah, that's the common wisdom on the subject.
        \_ It's indeed "common wisdom", but not a definitively true statement.
           What kind of project do you have in mind?
        \_ I don't think perl's inherently limited to small projects, but
           its advantages are strongest there.  For large projects, you
           can use strict, use the object-oriented stuff, compile if you
           have to.  There's no particular reason why a large project
           wouldn't work, but support for large projects is kind of tacked
           on, and doesn't make for the kind of fast development that makes
           perl ideal for smaller projects.  -tom
           \_ I'd (annoyingly) agree with tom, and I love perl.  Keep in mind
              that "large project" is relative.  If it's a giant website,
              with lots of pages, but each page has a limited amount of
              work to do, and you want shared components, there are definitely
              systems in place to make perl a good system for that.  If it's
              one big monolithic app, forget it.
              \_ did you mean "annoyedly"?
                 \_ well, if i agree with tom, than by definition i _am_
                 \_ well, if i agree with tom, then by definition i _am_
                    \_ did you mean "then"?
                    being annoying...
                    \_ I'm annoyed.
2001/8/10-11 [Computer/SW/Languages/Perl, Computer/SW/Unix] UID:22070 Activity:very high
8/10    Are there commonly used filename suffixes for sh scripts, csh scripts
        and tcsh scripts?  (e.g. .pl is for Perl scripts; .c is for C files.)
        Thanks.
        \_ Use .sh for sh/bash scripts; never use *csh for any sort of
                       \_ and ksh
           scripting purpose.  It does funny things sometimes-- see Unix
           Power Tools.
           \_ In the words of Tom Christiansen:
              http://www.faqs.org/faqs/unix-faq/shell/csh-whynot
           \_ My script is very simple and it only has several lines of
              commands.  No variable substition, no conditional, etc.  The
              only thing I need the shell to do is some filename expension
              of the form:
                cmd1 ~/foo/{`whoami`_*}/bar/{dir1,dir2,dir3} arg1 | \
                cmd2 ~/baz/`date | cut -d' ' -f1`.txt arg2
              I couldn't get this to work in my crontab file which I suppose
              uses sh syntax, so I ended up putting it in a csh script.  I
              [ Reformatted - motd formatting daemon ]
              know very little about shell scripts anyway.
              [ Reformatted - motd formatting god ]
              \_ It only works in csh because of the ~.  Some other shells
                 will let you use ~, but you should be able to rewrite it in
                 \_ But the {} part doesn't work either.  How do I do
                 sh using ${HOME} instead of ~.
                 \_ But the {} part doesn't work in sh either.  How do I do
                    "bar/{dir1,dir2,dir3}" in sh so that it expands correctly?
                    \_ for i in dir1 dir2 dir3 ; do <stuff> ; done
              \_ DIR="$HOME/foo/`whoami`_*/bar"
                 FILE="$HOME/baz/`date | cut -d' ' -f1`.txt"
                 for i in dir1 dir2 dir3 ;
                 do cmd1 "$DIR/$i" arg1 | cmd2 "$FILE" arg2 ; done
                 \_ But that means running the commands three times instead
                    of running the commands once with the three paths as
                    three arguments.
                    \_ DIR="$HOME/foo/`whoami`_*/bar"
                       FILE="$HOME/baz/`date | cut -d' ' -f1`.txt"
                       for i in dir1 dir2 dir3 ;
                       do MYDIR="$MYDIR $DIR/$i" ; done
                       cmd1 $MYDIR arg1 | cmd "$FILE" arg2
            \_ Actually, .pl is supposed to be for "perl library" files, or
               included snippets of scripts.  Whole perl scripts are supposed
               to be .p, though I never bother putting an extension on them,
               as they're executable in their own right.
               \_ What's your source? Nothing on google that supports your
                  statement, and .pl is absolutely standard usage (with
                  .ph = perl header [mostly perl4 and down] and .pm = perl
                  module [perl5 and up]). Furthermore there's a story floating
                  around about Larry Wall taking the last 2 letters of "BCPL"
                  to complete the sequence of BCPL descendants (.b, .c, .pl).
                  \_ perlcc, for starters.
               \_ In actual usage, I always see .pl as perl executables,
                  and never see .p
                  \_ indeed.
               \_ I thought perl libraries and modules had the .pm extension
                  \_ no, just modules
2001/7/18 [Computer/SW/Languages/Perl] UID:21833 Activity:high
7/17    "Perl is like chewing on chunks of broken glass, only without the tasty
        blood sauce to go with it."
        \_ Uh..
        \_ Ok, I'll bite. How do other programming languages taste like?
           \_ C is like an IV drip.
           \_ Lisp is like a New York steak hand fed to you gram by gram by a
              large breasted supermodel.  Fun and filling, but slow.
              \_ And then the model takes off her mask, and underneath
                 it's . . . RICHARD FATEMAN!!!!!
                                \_ Why, he does make me horny, baby!
                 \_ That's one image I could have done without...
2024/11/23 [General] UID:1000 Activity:popular
11/23   
Results 151 - 300 of 431   < 1 2 3 >
Berkeley CSUA MOTD:Computer:SW:Languages:Perl:
.