Re: Unique Dir Listing

2004-04-08 Thread Jeff 'japhy' Pinyan
return if $seen{$File::Find::dir}++; # skip if we've already seen it print DEST "$File::Find::dir\n"; } } -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.

Re: What is happening here

2004-03-31 Thread Jeff 'japhy' Pinyan
On Mar 30, R. Joseph Newton said: >Jeff 'japhy' Pinyan wrote: > >> The main problem is the PRECEDENCE. Your ? : line is run like so: >> >> ((++$count) ? ($count += $count--) : $count) += $count++; > >Have you tested this? I don't see the pr

Re: What is happening here

2004-03-30 Thread Jeff 'japhy' Pinyan
he third line multiplies by 2 and adds 1. The net result is adding one to $count, and then multiplying it by 4 and subtracting 1. my $count = 0; while (1) { $count = ($count + 1) * 4 - 1; print "$count\n"; exit if $count > 60_000; } -- Jeff "japhy" Pi

Re: string change problem

2004-03-29 Thread Jeff 'japhy' Pinyan
- it enforces safer coding practices print "Enter your name: "; chomp(my $name = ); # chomp removes the ending newline my $old_name = $name; $name =~ s/\W.*//; $name = lc $name; print "Old = $old_name\n"; print "New = $name\n"; -- Jeff "japh

Re: Regular expression with lookbehinds question

2004-02-26 Thread Jeff 'japhy' Pinyan
On Feb 26, Boris Shor said: >$e1 = ','; >$aye =~ s/(? >So this expression replaces spaces with newlines except when they are >immediately preceded by a comma. But when I change > >$e1 = ',|R\.' > >(English: comma or "R."), I get "Variable length lookbehind not implemented >in regex" Because ',' a

Re: Regular expression with lookbehinds question

2004-02-26 Thread Jeff 'japhy' Pinyan
On Feb 26, James Edward Gray II said: >On Feb 26, 2004, at 3:20 PM, Jeff 'japhy' Pinyan wrote: > >> s/(?:(? >??? I don't think that's gonna work. Let me check... No, doesn't >seem to. There is always NOT going to be a proceeding comma OR NOT >

Re: Reg. 'repeated pattern' matching

2004-02-25 Thread Jeff 'japhy' Pinyan
ing =~ m{via:\s*(\d+\.\d+\.\d+\.\d+)}g) { print "value = $1\n"; } or use it in list context like this: @values = $string =~ m{via:\s*(\d+\.\d+\.\d+\.\d+)}g; -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 htt

Re: Checking for calling context

2004-02-14 Thread Jeff 'japhy' Pinyan
quot;scalar context\n" } } foo(); $x = foo(); @y = foo(); -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y/// stand for? why, yansliterate of course.

Re: Array containment

2004-02-10 Thread Jeff 'japhy' Pinyan
On Feb 10, Jeff 'japhy' Pinyan said: >On Feb 10, James Edward Gray II said: > >>I said I cannot fix the grep() version. I'm just not that cool. > >I guess I'm cooler than you. ;) > > sub find { >my $wanted = shift; >my $found

Re: Getting croak or carp into variable ?

2004-02-10 Thread Jeff 'japhy' Pinyan
ou want Carp::shortmess(). perldoc Carp -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y/// stand for? why, yansliterate of course. [ I'm looking for programm

Re: Array containment

2004-02-10 Thread Jeff 'japhy' Pinyan
On Feb 10, James Edward Gray II said: >I said I cannot fix the grep() version. I'm just not that cool. I guess I'm cooler than you. ;) sub find { my $wanted = shift; my $found = 0; { grep $_ eq $wanted && ++$found && last, @_ } return $found;

Re: getting rid of space at beggining of variable

2004-02-09 Thread Jeff 'japhy' Pinyan
placements on the right. But you might just want to do $names[1] =~ s/\s+//g; -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y/// stand for? why, yansliterate o

Re: Method invocation arrow (LPORM)

2004-02-09 Thread Jeff 'japhy' Pinyan
hank you for the feedback. I'll note that for a future edition of the book. >That's also very similar to the way I have it in "perlboot", but nobody >noted it there yet. :( I would have, but I didn't think it necessary. When the question was asked, I went to the perlbo

Re: Method invocation arrow (LPORM)

2004-02-07 Thread Jeff 'japhy' Pinyan
nimal::speak(); in your case becomes Animal::speak($class); except that it becomes that DYNAMICALLY. >And when Perl does not find Animal::speak in Mouse, to: Ah, here's the confusion. This isn't looking for a method named 'Animal::speak' in 'Mouse'; it's lo

RE: Reg. string matching using reg-exp

2004-02-06 Thread Jeff 'japhy' Pinyan
't need to do anything special in Perl. $string = "This is a very long string that spans many lines"; Or you can use a 'here-doc'. $string = << "END OF STRING"; this is a very long string that spans many lines END OF STRING -- Jeff "japhy" P

Re: formatting and syntax

2004-02-05 Thread Jeff &#x27;japhy&#x27; Pinyan
C G A C G _ _ _ _ _ _ _ bob Ack. You're mixing the input with the output! -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y/// stand for? why, yansliterate of

Re: Make this into a script to parse?

2004-02-04 Thread Jeff &#x27;japhy&#x27; Pinyan
On Feb 4, John McKown said: >On Wed, 4 Feb 2004, Jeff 'japhy' Pinyan wrote: > >> > foreach $i (@grok) { >> > chomp($i); >> > >> >($item_num,$item_desc,$b1,$b2,$b3,$b4,$cc,$vn,$qoh,$qc,$qor,$bc,$sc,$yp) >> >= split(/\|/,$i); >>

Re: removing all elements in an array

2004-02-04 Thread Jeff &#x27;japhy&#x27; Pinyan
s to affect the arrary in that >it wont take any element assignments afterwards. Then you're doing something wrong. @array = (); is the proper way to do it. Show us your code. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brothe

Re: Make this into a script to parse?

2004-02-04 Thread Jeff &#x27;japhy&#x27; Pinyan
Oh good God. Do you know what that for loop is DOING? for each element in @grok: remove the newline split it on pipes into some variables print $inv, those variables with pipes in between, and add a newline That is terribly insane. > close FILE; >} Here's my rew

Re: formatting and syntax

2004-02-04 Thread Jeff &#x27;japhy&#x27; Pinyan
entered by the user while () { my ($name) = / >(.+)/;# get the line name chomp(my $DNA = ); # get the next line (the DNA) # add $size - length() dashes to the end of $DNA $DNA .= "-" x ($size - length $DNA); # print the DNA with spaces, then a tab, then th

Re: How to use the arguments to use() in the package being used

2004-02-04 Thread Jeff &#x27;japhy&#x27; Pinyan
On Feb 4, Rob Dixon said: >That's an interesting point Jeff. You're right that it's > > Module->import() > >instead of > > Module::import() > >as 'import' will be inherited in the (common) case that >Module ISA Exporter. And also, '

Re: How to use the arguments to use() in the package being used

2004-02-04 Thread Jeff &#x27;japhy&#x27; Pinyan
; sub import { my $class = shift; print "You gave me (@_)\n"; } It's up to you to do something with @_. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/

Re: In what order does a program run..??

2004-02-04 Thread Jeff &#x27;japhy&#x27; Pinyan
>Line3 >Sub1 >Subcode1 >Subcode2 >Endsub1 >Line4 >Line5 >Line6 calls sub1 >Line7 >Does the execution sequence go like this: > >Line1, line2, line3 line 4 line5, line6, sub1, subcode1, subcode2, >endsub1 line7 Yes. -- Jeff "japhy" Pinyan [EMAIL PROT

Re: FW: special vars

2004-02-03 Thread Jeff &#x27;japhy&#x27; Pinyan
, you need to select() FOO and then set $| to 1. my $old_fh = select FOO; $| = 1; # now FOO is unbuffered select $old_fh; # go back to whatever filehandle was previous selected -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734

Re: what is a pseudohash

2004-02-03 Thread Jeff &#x27;japhy&#x27; Pinyan
: Don't use psuedohashes. Use an array with >constant indexes. Its faster in the general case, its more guaranteed, and >generally, it works. > >"The long summary is that I've done some work to get this working with >modules that use psuedo hashes, but its still broken in th

Re: using grep in perl

2004-02-03 Thread Jeff &#x27;japhy&#x27; Pinyan
nated Those sound like Perl error messages. Show us your code, please. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y/// stand for? why, yansliterate of course. [ I

Re: how to initialize an array of unknown size to 0?

2004-02-01 Thread Jeff &#x27;japhy&#x27; Pinyan
That's all you need. Save it as TAZ.pm if you want. use TAZ; tie @x, 'Tie::Array::Zero'; print $x[5]; # 0 -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/

Re: Writing to file

2004-02-01 Thread Jeff &#x27;japhy&#x27; Pinyan
print DAT "$line\n"; } I might even do without $line: for (@members) { print DAT join(":", @$_), "\n"; } Then, since it looks like that, I might use an inverted for loop: print DAT join(":", @$_), "\n" for @members; I request th

Re: How to tell if subroutine param is filehandle

2004-02-01 Thread Jeff &#x27;japhy&#x27; Pinyan
$arg)) { # it's an open filehandle } -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y/// stand for? why, yansliterate of course. [ I'm looking for progra

Re: Array subtraction, like sets

2004-01-31 Thread Jeff &#x27;japhy&#x27; Pinyan
On Feb 1, Robin Sheat said: >On Fri, Jan 30, 2004 at 10:33:27AM -0500, Jeff 'japhy' Pinyan wrote: >> sub array_diff { >> my ($first, $second) = @_; >> my %diff = map { "@$_" => 1 } @$second; >> return [ map !$diff{"@$_"

Re: Perl Style

2004-01-31 Thread Jeff &#x27;japhy&#x27; Pinyan
On Jan 31, Robert said: >When they say "uncuddled else" are they meaning: A cuddled else is: if (...) { ... } else { ... } Anything other than THAT is an uncuddled else. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/

Re: map?

2004-01-31 Thread Jeff &#x27;japhy&#x27; Pinyan
and then show us code you've tried with it. If you need help with what you use it FOR, I can give you some advice and some pointers. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.o

Re: Array subtraction, like sets

2004-01-30 Thread Jeff &#x27;japhy&#x27; Pinyan
it's efficient. It also prevents you from doing the icky for this (set a) { for that (set b) { compare this and that } } -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.

Re: sort from the smallest number to the highest number

2004-01-30 Thread Jeff &#x27;japhy&#x27; Pinyan
that's what I'm about to show you: my @sorted = map $_->[0], # get back the original string sort { $a->[6] <=> $b->[6] } # sort on 5th field (0 is the original) map [ $_, split ],# array ref [string, fields] @data; Read it fr

Re: style of functions with complex arguments

2004-01-30 Thread Jeff &#x27;japhy&#x27; Pinyan
dn't it make more sense to pass the triplets as array references like so: $network->pW(network => 1, [0,1,3], [0,2,2], [3,2,2]); sub pW { my $self = shift; my ($net, $delta, $src, $dest, $layer); # and then deal with @$src, @$dest, @$layer } That'd be my strategy.

Re: function that reads line numbers?

2004-01-30 Thread Jeff &#x27;japhy&#x27; Pinyan
ompare that with ($x, $y) = (5, 10); while () { print if $x .. $y; # prints all the lines } If you're using variables, you'll need to compare to $. explicitly. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #73

Re: Build multidimensional array from arrays

2004-01-29 Thread Jeff &#x27;japhy&#x27; Pinyan
On Jan 29, Kevin Old said: >On Thu, 2004-01-29 at 12:34, Jeff 'japhy' Pinyan wrote: >> On Jan 29, Kevin Old said: >> >> >@one = qw(A B C D); >> >@two = qw(E F G H); > >Well, no that wasn't what I was looking for, but it's a nice pi

Re: Build multidimensional array from arrays

2004-01-29 Thread Jeff &#x27;japhy&#x27; Pinyan
; If you need an explanation, feel free to ask. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y/// stand for? why, yansliterate of course. [ I'm looking for p

Re: function that reads line numbers?

2004-01-29 Thread Jeff &#x27;japhy&#x27; Pinyan
On Jan 29, Rob Dixon said: >Jeff 'Japhy' Pinyan wrote: >> >> while () { >> print "small " if 1 .. 10; >> print "medium " if 6 .. 15; >> print "big " if 11 .. 20; >> print "\n"; >>

Re: function that reads line numbers?

2004-01-29 Thread Jeff &#x27;japhy&#x27; Pinyan
On Jan 28, John McKown said: >On Wed, 28 Jan 2004, Jeff 'japhy' Pinyan wrote: > >> while () { >> if (10 .. 20) { >> print; # displays lines 10 through 20 >> } >> } > >Wouldn't the following be slightly faster?

Re: What is eval?

2004-01-29 Thread Jeff &#x27;japhy&#x27; Pinyan
ou tried dividing by zero.\n" } Basically, if we didn't use eval { } here, the program would die if the user entered the number 0. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan

Re: error but code works

2004-01-29 Thread Jeff &#x27;japhy&#x27; Pinyan
ot;line=$_" if $DEBUG > 0; $found = 1, last if /$localpart:/; } Here, we exit the loop immediately when $found is set. This lets us use a simply while clause () which assigns to $_ and tests for defined-ness implicitly. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http:

Re: How to import symbols and semantics from one namespace into another

2004-01-29 Thread Jeff &#x27;japhy&#x27; Pinyan
7;t defined until Perl reaches them when EXECUTING your program. And since the first thing Perl executes is the 'import' call, those arrays are defined too late to help. One way to fix this is with a BEGIN block: SomePackage->import('foo'); foo(); BEGIN { package So

Re: Subroutine interaction

2004-01-29 Thread Jeff &#x27;japhy&#x27; Pinyan
nd::name; return 0 unless $pathname =~ /\.html$/; # definition of the file path relative to the $gedicht_path $relative_path = $pathname; $relative_path =~ s#$gedicht_path/##; # do stuff with hashes and arrays }; find ($read_poem, $gedicht_path); print

Re: Two-liner to one-liner

2004-01-29 Thread Jeff &#x27;japhy&#x27; Pinyan
; As for shrinking them my @teilzeilen = split /\n/, ($eingabe =~ /Teilnehmer:\n\n(.+)/s)[0]; should work. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y/

Re: Passing several arguments

2004-01-29 Thread Jeff &#x27;japhy&#x27; Pinyan
return ONE element. Getting all of them from @_ is the way to do it. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y/// stand for? why, yansliterate of course. [ I&

Re: function that reads line numbers?

2004-01-28 Thread Jeff &#x27;japhy&#x27; Pinyan
your program, you can just write it as: while () { if (10 .. 20) { print; # displays lines 10 through 20 } } For more on the subject, please read 'perldoc perlop' and look for 'Range Operators'. -- Jeff "japhy" Pinyan [EMAIL PROTEC

Re: [Q] How to eval an EXPR once and make it stick

2004-01-28 Thread Jeff &#x27;japhy&#x27; Pinyan
lt;>) { > last if $blank_lines xor /\S/; > print if $output; >} > } That might work in this specific case, but if you want to be able to change the course of events like that without constant re-evaluation, I'd suggest using code references: my $code = \&first

Re: regex question "match everything that does not include the string ''

2004-01-26 Thread Jeff &#x27;japhy&#x27; Pinyan
either 'one or more non-<' or 'a < that is not followed by /font' zero or more times". -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y///

Re: hash of hash of array slices

2004-01-26 Thread Jeff &#x27;japhy&#x27; Pinyan
On Jan 26, Paul Kraus said: >foreach ( @{($hash{$key1}{$key2})[9..1]} ) It should be: foreach ( @{ $hash{$key1}{$key2} }[1 .. 10] ) { ... } based on your other email. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brothe

Re: interfacing with Python using Perl

2004-01-23 Thread Jeff &#x27;japhy&#x27; Pinyan
ram to use Gentoo Linux's Portage API which is >written all in Python. I believe you can do just that with Inline::Python, on CPAN. http://search.cpan.org/author/NEILW/Inline-Python-0.20/Python.pod It's from 2001, though... just so you know... -- Jeff "japhy"

Re: Need help with a regex

2004-01-23 Thread Jeff &#x27;japhy&#x27; Pinyan
}x; What this does on a string like "peach Georgia fruit" is this: the first \S+\s+ matches "peach ". Then we capture "Georgia fruit" to $1. However, the REST of the regex still has to match, but it can't, so the (?:\s+\S+)* backtracks -- it gives up on

Re: File::Copy

2004-01-21 Thread Jeff &#x27;japhy&#x27; Pinyan
on't need to \ the . in either case, and you don't need quotes around $ARGV[0] as the first argument to copy(). copy($ARGV[0] => "$ARGV[0].bak"); -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.

Re: Sub not working as it should

2004-01-21 Thread Jeff &#x27;japhy&#x27; Pinyan
rrorno, $fh) = @_; print $fh "error $errorno $machine\n"; } Where did you pick up your current idea about Perl's subroutines? -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http

Re: Day of the week by accepting date from User

2004-01-20 Thread Jeff &#x27;japhy&#x27; Pinyan
# day of week (0-6) my $day_name = $days[$dow]; # name of day of week -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y/// stand for?

Re: get rid of whitespace around pipes??

2003-12-17 Thread Jeff &#x27;japhy&#x27; Pinyan
e string and such. Then split on /\s*\|\s*/. That regex reads "zero or more whitespace, a |, then zero or more whitespace". @fields = split /\s*\|\s*/, $line; -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734

Re: RE : Regular expressions

2003-12-17 Thread Jeff &#x27;japhy&#x27; Pinyan
r ($_ =~ /two three/)) { ... } You want either if ($text =~ /one two/ or $text =~ /two three/) { ... } or if ($text =~ /one two|two three/) { ... } -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/

Re: Converting using a hash

2003-12-17 Thread Jeff &#x27;japhy&#x27; Pinyan
: s/brian/jones/g; s/on/off/g; then we'd get "this is off joffes". It's just something to keep in mind. >I omitted the sort command since all patterns consist of a single (8-bit) >character, so I guess your caveat is not applicable. My original message >

Re: Converting using a hash

2003-12-16 Thread Jeff &#x27;japhy&#x27; Pinyan
regex: $re = qr/($re)/; The qr// operator (in perlop) gives you a compiled regex; it's good for efficiency in certain situations (although this isn't really one of them). $text =~ s/$re/$enctabelle{$1}/g; That replaces all keys with their values. -- Jeff "japhy" Pinyan

Re: String Date to apoch

2003-12-12 Thread Jeff &#x27;japhy&#x27; Pinyan
,0,12) = noon Ta da. No big clunky modules, nothing to download from CPAN. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y/// stand for? why, yansliterate of course

Re: md5 function

2003-12-11 Thread Jeff &#x27;japhy&#x27; Pinyan
b "modules"; which does what you show above, plus a little more (see the lib.pm docs). However, if @INC has been set up so that lib.pm can't be found... then you're in a world of hurt. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~

Re: recursive replace command line

2003-12-11 Thread Jeff &#x27;japhy&#x27; Pinyan
On Dec 11, George Georgalis said: >On Thu, Dec 11, 2003 at 09:05:20AM -0500, Jeff 'japhy' Pinyan wrote: >>On Dec 10, George Georgalis said: >> >>>giving my perl a retry, I found some hints on a website to recursively >>>replace text >>> >

Re: recursive replace command line

2003-12-11 Thread Jeff &#x27;japhy&#x27; Pinyan
all non-alphanumeric metacharacters don't use backslashes. That means [...] for character classes, not \[...\], and + for " 1 or more", not \+, and so on. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://ww

Re: This seems to ease

2003-12-08 Thread Jeff &#x27;japhy&#x27; Pinyan
uits; grep() does not. grep() will keep going through the ENTIRE list, even if the FIRST element matches. There's always the first() function from List::Util. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.

Re: This seems to ease

2003-12-08 Thread Jeff &#x27;japhy&#x27; Pinyan
\.[0-9]+)?|$ph))\sin\s/in $1, /g; >}; >This seems to work. >Can someone test some more and give some bugs? >Is there a generic module for doing operators? I've never used Filter::Simple, so I don't know what $ph is representing, so I'd like to know if your mod

Re: remove control chars

2003-12-03 Thread Jeff &#x27;japhy&#x27; Pinyan
c( ch, stdout ); >} else { > putc( ' ', stdout ); >} > } perl -pi.bak -e 'tr/\040-\176\n/ /c' file That'll change all characters that are NON between 0040 and 0176 and \n into spaces. -- Jeff "japhy" Pinyan [EMAIL PROTECTED]

RE: Creating uniqueness in complex data structures

2003-11-24 Thread Jeff &#x27;japhy&#x27; Pinyan
'T123 Here's one for the first thread', 'T237 Here's a different one', # <-- duplicate, not entered ); for (@stuff) { chomp; my ($thread, $data) = split ' ', $_, 2; push @{ $server{$thread} }, $data unless grep $_ eq $data, @{ $se

Re: Pattern Matching

2003-11-19 Thread Jeff &#x27;japhy&#x27; Pinyan
On Nov 19, Rob said: >This is what I finally came up with, but it too seems rather clunky. > >my $cnt = 0; >$_ = $notes; >$cnt = tr/\n//; Yeah; why not: my $count = ($notes =~ tr/\n//); -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy

Re: Perl optimization tools

2003-11-19 Thread Jeff &#x27;japhy&#x27; Pinyan
module. It gives you specific profiling information about your program. Read its docs to see how to use it. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y/// stand for

Re: pagination of dbi results on html browser

2003-11-17 Thread Jeff &#x27;japhy&#x27; Pinyan
# do stuff with $rec } $sth = $dbh->prepare($n_query); $sth->execute($arg); # if this is not the FIRST set of records print qq{<<<} if $prev != $offset; # if there are more rows to show after these print qq{>>>} if $sth->rows; I exp

Re: While or For

2003-11-17 Thread Jeff &#x27;japhy&#x27; Pinyan
note that while () { ... } is identical to while (defined($_ = )) { ... } which only reads ONE line at a time, whereas for () { ... } reads ALL the lines of the file at once, into a list. A for loop is best used for iterating over a list of values, or, in the C-style loop, running through

Re: selecting select as an option was Re: first steps with perl, a log reader

2003-11-16 Thread Jeff &#x27;japhy&#x27; Pinyan
line. { local $| = 1; # ... } -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y/// stand for? why, yansliterate of course. [ I'm looking for programming work. If

Re: selecting select as an option was Re: first steps with perl, a log reader

2003-11-16 Thread Jeff &#x27;japhy&#x27; Pinyan
at's the intended usage? Probably for when you're using code that you haven't written that writes to the default output filehandle. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://ww

Re: selecting select as an option was Re: first steps with perl, a log reader

2003-11-16 Thread Jeff &#x27;japhy&#x27; Pinyan
with "select", except as > permitted by POSIX, and even then only on POSIX > systems. You have to use "sysread" instead. That's out of context; that warning is for the multi-arg for of select(). -- Jeff "japhy" Pinyan [EMAIL

Re: first steps with perl, a log reader

2003-11-16 Thread Jeff &#x27;japhy&#x27; Pinyan
he message that print has an unopened filehandle ERRORLOG >at line 7. Right, because there is no ERRORLOG filehandle, only ER and EL. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.or

Re: Question on grep search

2003-11-16 Thread Jeff &#x27;japhy&#x27; Pinyan
hat's because you're assuming the test is implicit; it's not: unless grep $_ eq $another_name, @{$names{TEST}}; The grep() condition doesn't necessarily HAVE to be "the element equals X", so you have to give it explicitly. -- Jeff "japhy" Pinyan [E

Re: text replacement+

2003-11-14 Thread Jeff &#x27;japhy&#x27; Pinyan
change{$block} and exists $change{$block}{$attr}) { s/\Q$attr\E.*/$attr $change{$block}{$attr}/; } # print the attribute print; } } Let me know if you understand it, or if you need more explanation. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http:/

Re: How do you dynamically assign array names?

2003-11-14 Thread Jeff &#x27;japhy&#x27; Pinyan
On Nov 14, Douglas Houston said: >On Fri, 14 Nov 2003, Jeff 'japhy' Pinyan wrote: > >> On Nov 14, Douglas Houston said: >> >> >I am trying to initialize a dynamically-named array, i.e. with the >> >following test code (if I type "script.pl char&q

Re: How do you dynamically assign array names?

2003-11-14 Thread Jeff &#x27;japhy&#x27; Pinyan
se warnings; # perl5.6+ my %data; my $name = shift; $data{$name} = [1,2,3]; # or # @{ $data{$name} } = (1,2,3); And your "while (<$ARGV[0]>)" is weird, and not working why you think it works. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.c

Re: references and objects

2003-11-14 Thread Jeff &#x27;japhy&#x27; Pinyan
$tempres[3]; You'd need $tempres[1] and $tempres[2], since arrays are 0-based, but you'd also need ${ $tempres[1] } and ${ $tempres[2] }, since you're returning references to those scalars. Using my return values, you'd do: my ($start, $end, $listref) = $event->Even

Re: Parsing for base domain

2003-11-14 Thread Jeff &#x27;japhy&#x27; Pinyan
ght of the last dot. Here's one way: ($last_part) = $domain =~ /.*\.(.*\..*)/; A slightly more verbose way is: $last_part = substr( $domain, 1 + rindex($domain, '.', rindex($domain, '.')) ); -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http:

Re: external sub routine

2003-11-13 Thread Jeff &#x27;japhy&#x27; Pinyan
eason is that Perl needs a true value to be returned from the file to signal that it was compiled properly. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y/// stand for?

Re: Replace with regular expression

2003-11-13 Thread Jeff &#x27;japhy&#x27; Pinyan
ace what we've matched (which isn't anything, we've only LOOKED) with a +, for all occurrences". -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y///

Re: regexp matching- real simple!

2003-11-13 Thread Jeff &#x27;japhy&#x27; Pinyan
ching either a digit, a -, or a + as the first character in $diff. If you wanted to match a POSITIVE number, you'd be better with /^+?\d/, but WHY are you using a regex for a MATH problem? if ($diff > 0) { ... } -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.

Re: Package Help

2003-11-13 Thread Jeff &#x27;japhy&#x27; Pinyan
uot;}."'"); You don't need quotes around keys to hashes, if they're simple strings like the ones you've shown. Specifically, that last line could be: $debug->cp3Debug("htmlHelper::new", "src='$sysData->{SRC}'"); Oh, and I don't kn

Re: Perl Equavlent

2003-11-13 Thread Jeff &#x27;japhy&#x27; Pinyan
you have -2.9, you get -2. If you were to write int() as a function of ceil() and/or floor(), you'd have to say: sub int { my $x = shift; $x > 0 ? floor($x) : ceil($x); } -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734

RE: Help with Error Message: Can't use an undefined value as a hash reference

2003-11-12 Thread Jeff &#x27;japhy&#x27; Pinyan
gt;{...} # or do: my %hash = %$href; ... } But I'd just use $href. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y/// stand for? why, yanslitera

Re: Matching/replacing

2003-11-12 Thread Jeff &#x27;japhy&#x27; Pinyan
expecting tabs and spaces, but I'll include carriage returns and formfeeds. I'd be tempted to change these THREE regexes: # pick ONE of the following TWO: tr/\r\t\f / /s; # squashes consecutive [\r\t\f ]'s to a single space # or s/\s+/ /g; # then do both of the f

Re: Classes, hashes, objects and references

2003-11-11 Thread Jeff &#x27;japhy&#x27; Pinyan
27;}, >$user->{'phone'}, > $user->{'email'}) = @_; > my $loginName = $user->{'loginName'}; > $self->{'users'}->{$loginName} = $user; <== This is line 47 And since $self is a string, and strict is on, $

Re: Is it Possible: Caching Perl Compilations

2003-11-09 Thread Jeff &#x27;japhy&#x27; Pinyan
On Nov 9, Dan Anderson said: >Is it possible to cache Perl compilations on a web server so that it >runs faster? Yes, it's called mod_perl, and it's a module for the Apache web server. See the Apache web site (http://www.apache.org/). -- Jeff "japhy" Pinyan [

Re: Why would objects change

2003-11-09 Thread Jeff &#x27;japhy&#x27; Pinyan
o => "bar"}, "bar"; >when the modules constructor was called by another module. I have a feeling you've done Module::new(args...) instead of Module->new(args...) The first way is erroneous. The second way is correct. -- Jeff "japhy" P

Re: Regex search question

2003-11-06 Thread Jeff &#x27;japhy&#x27; Pinyan
) { Remember to reverse $1, though. You could also do /.*VALUE=(\d+)/ -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y/// stand for? why, yansliterate of course.

Re: Is foo qw (arg1 arg2) equivalent to foo (arg1, arg2)?

2003-11-06 Thread Jeff &#x27;japhy&#x27; Pinyan
On Nov 6, Dan Anderson said: > >> Dan> So: foo->bar qw(foo bar); is equivalent to foo->bar("foo","bar"); ? >> >> Only in recent Perls. > >Do you know exactly how recent? Are we talking 5 or better or 3 or >better? Without check pe

Re: Is foo qw (arg1 arg2) equivalent to foo (arg1, arg2)?

2003-11-06 Thread Jeff &#x27;japhy&#x27; Pinyan
bject->method(...) When you use qw(this that those), Perl changes that to ('this', 'that', 'those') Perl splits the qw(...) on spaces, and returns the raw data, single-quoted. This means no variables. You can't even escape a space: qw( abc\ def ) bec

Re: Is foo qw (arg1 arg2) equivalent to foo (arg1, arg2)?

2003-11-06 Thread Jeff &#x27;japhy&#x27; Pinyan
or method if >called with a package name), and I use qw() it takes all words seperated >by spaces, and passes them in as arguments. > >So: foo->bar qw(foo bar); is equivalent to foo->bar("foo","bar"); ? > >Thanks in advance, > >Dan > > -- Jeff

RE: Why is parsing your own form data a bad idea?

2003-11-05 Thread Jeff &#x27;japhy&#x27; Pinyan
I believe you are forming a non-standard HTTP request >which is why CGI.pm doesn't have (at least I don' think) a way to pull Incorrect. The 'url_param' does it. Look for "MIXING POST AND URL PARAMETERS". -- Jeff "japhy" Pinyan [EMAIL

Re: Why is parsing your own form data a bad idea?

2003-11-05 Thread Jeff &#x27;japhy&#x27; Pinyan
D] : $values[0]; } (request_method() eq 'GET' ? *GET : *POST) = \%hash; } >This seems kind of silly. Can anyone explain to me why this is? Do you know how hard it is to do it RIGHT? Do you know how to parse file uploads? And do all the other stuff correctly? -- Jeff "japhy" Pi

Re: ref's to subs

2003-11-04 Thread Jeff &#x27;japhy&#x27; Pinyan
rence to the foo function, but \&foo() is a reference to the return value of the call to &foo(). -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y/// stand for?

Re: cksum question

2003-11-04 Thread Jeff &#x27;japhy&#x27; Pinyan
ing a checksum: while (<>) { $checksum += unpack("%32C*", $_); } $checksum %= 65535; -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does

Re: Need help speeding up an algorithm...

2003-11-02 Thread Jeff &#x27;japhy&#x27; Pinyan
re = ( some_genre => [ entry, entry, ... ] ) # each entry is a hash reference push @{ $by_genre{$genre} }, { genre => $genre, artist => $artist, album => $album, disc => $disc, file => $file, fullpath => $full, }; warn << "DEBUGGING" if

<    1   2   3   4   5   6   7   8   9   10   >