Re: [Boston.pm] converting a thing to a number

2022-02-23 Thread Gyepi SAM


The C functions strtol and strtod would seem to be canonical
for this problem.  Accessible through the POSIX module, they
can handle large numbers, a wide range of representations, and
provide both domain and range error checking.

You could use a regex like /^\s*(-|\+)?0(.)/ to match binary, octal,
and hex representations but octal has an implicit base that will need to be
accounted for.  Solving for that makes the regex unnecessary.

After parsing the first few bytes to extract the sign and base into components*,
the rest falls into place:

sub parse
extract input into sign, base, and str_val
convert str_val to numeric value using strto[dl]
handle errors # See man POSIX::strto[dl] 
negate numeric value if sign eq '-'
return numeric value

* Extracting the sign and base will necessarily require a position variable.
Let's call it $i.  The final value for $i can be used to extract the
(absolute) numeric part of the input value with substr($str_val, $i)

In this context, eval is a red herring with a big stench.

-Gyepi

On Wed, Feb 23, 2022 at 08:31:12AM -0600, em...@greglondon.com wrote:
> Copy/pasting a regexp for checking
> would probably work in my situation.
> 
> That numpack idea is great.
> 
> It solves another issue i didnt
> even mention which is that some
> numbers can be arbitrarily huge.
> 
> If i parse one char at a time,
> I should be able to use bignum
> and still get the correct answer.
> 
> A little surprised there isnt a
> way to restrict eval to some
> particular perl grammar subrule like
> "Numeric literal". (Shrug)
> 
> Regexps will be a bit more work
> but will do the job.
> 
> Thanks everyone!
> Greg
> 
> 
> 
> On 2022-02-22 22:01, Jerrad Pierce wrote:
> > There are two things you can do:
> > 
> > a) use regular expressions on the "numbers" to see if they conform
> > to known format, and then eval iff they do; you can then bypass eval
> > for integer/float since +0 will cover it.
> > 
> > e.g; e.g; /\s+0b[01]+\s+/
> > 
> > You should be able to crib RE from RegExp::Common, no need to install
> > and use the full module.
> > 
> > b) use regular expressions to identify the format plus some packing/
> > unpacking and code-point indexing to convert the number without eval:
> > 
> > # binary 285, this implementation is sensitive to leading zeroes--
> > # others may not be--and requires whole bytes. Padding is left as
> > # an exercise for the reader
> > $num = numpack("B*", "000100011101");
> > 
> > #hex 3735928559
> > $num = numpack("H*", "deadbeef")
> > 
> > sub numpack {
> > my($fmt, $val)=@_;
> > my($i, $sum)=(1, 0);
> > 
> > my @char =split //, unpack("a*", pack($fmt, $val));
> > my $bytes=scalar(@char);
> > foreach(@char){ $sum+=ord()<<(8*($bytes-$i++))}; #shift and add bytes
> > return $sum
> > }
> 
> ___
> Boston-pm mailing list
> Boston-pm@pm.org
> https://mail.pm.org/mailman/listinfo/boston-pm

-- 
The shortest answer is the doing the thing. --Author Unknown

___
Boston-pm mailing list
Boston-pm@pm.org
https://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Rakudo.org malware?

2017-01-31 Thread Gyepi SAM

g@d:~$ whois rakudo.org
Domain Name: RAKUDO.ORG
Registrant Name: Andy Lester
Registrant Email: a...@petdance.com

-Gyepi

On Tue, Jan 31, 2017 at 02:38:48PM +, Morse, Richard E.,MGH wrote:
> Hi! When I tried to go to rakudo.org, I got the following warning:
> 
> > This Page Cannot Be Displayed
> > 
> > Based on your organization's access policies, this web site ( 
> > http://rakudo.org/2017/01/30/announce-rakudo-star-release-2017-01/ ) has 
> > been blocked because it has been determined by Web Reputation Filters to be 
> > a security threat to your computer or the organization's network. This web 
> > site has been associated with malware/spyware.
> > 
> > If you have questions, please contact your organization's network 
> > administrator and provide the codes shown below.
> > 
> > Date: Tue, 31 Jan 2017 09:22:09 EST
> > Username: 
> > Source IP: XXX.XXX.XXX.XXX
> > URL: GET http://rakudo.org/2017/01/30/announce-rakudo-star-release-2017-01/
> > Category: Computers and Internet
> > Reason: BLOCK-MALWARE
> > Threat Type: othermalware 
> > Threat Reason: Domain reported and verified as serving malware. 
> > Notification: WBRS
> 
> Does anyone know who I should notify about this, and have contact information 
> for them?
> 
> Thanks,
> Ricky
> 
> 
> The information in this e-mail is intended only for the person to whom it is
> addressed. If you believe this e-mail was sent to you in error and the e-mail
> contains patient information, please contact the Partners Compliance HelpLine 
> at
> http://www.partners.org/complianceline . If the e-mail was sent to you in 
> error
> but does not contain patient information, please contact the sender and 
> properly
> dispose of the e-mail.
> 
> ___
> Boston-pm mailing list
> Boston-pm@mail.pm.org
> http://mail.pm.org/mailman/listinfo/boston-pm

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] website problem

2015-06-28 Thread Gyepi SAM
On Sun, Jun 28, 2015 at 05:44:11PM -0400, dan moylan wrote:
> 1st: in my code:
>   $fll = "/home/moylan/www/cgi-bin/stuff/moyts6.log";
>   $fhl = new FileHandle ();
>   $fhl->open ($fll, "w") or die "couldn't open $fll";
>   $fhl->printf ("# MOYTS6\n\n");
> 
> it was apache trying to write to stuff with permissions
> 755 owned by moylan.moylan.  i added moylan to apache groups
> and set stuff permissions to 775 and that got fixed.
> 
> 2nd: selinux permissive mode was required.
> 
> when those two things were done the script worked just fine.
> 
> now, do you have any suggestions as to how i might adjust
> selinux for my particular problem without putting it in the
> permissive mode?

Is there a special reason why the cgi directory is writable
by the web server?  It's a more usual practice to place log files in
a separate directory from code and make sure that the code directory
is NOT writable by the web server.

One of the benefits of a separate logging directory is that this problem goes 
away
and your system is more secure.

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] boost::format to sprintf, or how do I get a substitution with a substitution in it?

2015-04-04 Thread Gyepi SAM
On Fri, Apr 03, 2015 at 09:48:22PM -0500, Greg London wrote:
> Cool!  15 years of perl and I never used /e
> 
> I got the regexp to convert the first file
> and discovered that sprintf is way more inconvenient
> than I remember. It doesn't return the string,
> it returns pass/fail. And it operates on char* ?
> 
> This may have been why I used boost::format.
> 
> Anyone know of a c++ self contained function that takes
> a format string and returns the result string
> rather than using char*'s and returning the value in
> a char*?

I ran into this problem with C code some time ago.

sprintf and friends do not return the string because that would require
them to allocate the memory for the string, which raises difficult
questions of ownership and memory management.

Instead, you are expected to pre-allocate the memory and pass it in as
a char * argument so sprintf can write to it.

But how do you know how big to make the string? The basic idea is to
call snprintf with a zero length value and it will tell you how big the
string should be so you can make a second call with the correct length.
It works, but is annoying. I suspect most programmers write utility code
to abstract this stuff away.

Here's the code I wrote back then to solve the problem, it's extracted from
my util library so there are references to other util or application
functions but they are pretty obvious. Note that you are expected to
deallocate the string after use.

char *
xvstrfmt (const char *fmt, va_list args)
{
  int size = 0;

  char *str = NULL;

  int n;

  for (;;) {

n = vsnprintf (str, size, fmt, args);

if (n == -1) {
  fatal_sys ("vsnprintf");
}
else if (n < size) {
  return str;
}
else {
  size = n + 1;
  str = xrealloc (str, size);
}
  }

  return NULL;
}

char *
xstrfmt (const char *fmt, ...)
{
  va_list args;

  char *str;

  va_start (args, fmt);
  str = xvstrfmt (fmt, args);
  va_end (args);

  return str;
}

-Gyepi

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] [Discuss] Facebook backups?

2014-04-28 Thread Gyepi SAM
On Mon, Apr 28, 2014 at 10:29:39AM -0400, Bill Ricker wrote:
> And if that doesn't work, then there's Selenium or perl modules to script a
> Firefox session.

Or phantomjs, the headless browser.

-Gyepi

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] GO vs Perl runtime.

2014-03-15 Thread Gyepi SAM
On Fri, Mar 14, 2014 at 12:42:39PM -0400, ja...@nova-sw.com wrote:
> From what I can see GO is purely compiled down to object code and linked into 
> static binaries.  IMHO Perl, as an interpreted language, is doing *super* to 
> be *only* twice the runtime of Go!   Maybe others have a better handle on 
> this.  

Yes, 2x is not bad. Generally, comparing language speed doesn't get you far
unless you can use any language. If you're not doing green field programming,
there's generally enough of an investment in a particular language (or set of 
languages)
that the mountain is hard to move.

In most cases (web services), a slower language just means more servers.
Hardware will get you surprisingly far before you are forced to really think 
about scalability.
When that happens, you need more from your language than mere speed.

-Gyepi

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] GO vs Perl runtime.

2014-03-15 Thread Gyepi SAM
On Fri, Mar 14, 2014 at 07:42:53PM -0400, Andrew Feren wrote:
> I've never seen GO before this thread,  but after a glance at the GO web 
> site, I suspect the difference may have more to do with concurrency than 
> compiling.  Perl is written in C and natively pretty good at file and string 
> manipulation. My gut says a 2x win for this problem just by using GO compiled 
> to a "static binary" is much too big a difference. 

No, that's not it. The difference really is due to the compilation.
Any interpreter will have overhead that a compiled program will not.
In perl's case, there's even more overhead for providing dynamic memory
management, relaxed typing, etc. 2x is actually not bad, all things
considered. I bet a C version would be even faster; but at the cost of
managing memory and implementing your own hash, string and array data
structures. However, you can tune all of that to the problem set so it
really is a trade-off.
The piper must be paid, you just get to choose when and how.

> Is the code for the GO program being compared to the posted perl script also 
> available?

It is now. As you can see, it's a straightforward translation of the original 
into idiomatic Go.
Even without comments it should be readable to anyone who has programmed any 
Algol derived language.

I've been using Go for about 2 years now and I really like it.
It fits Alan Kay's maxim: simple things are simple and complex things are 
possible.
To which I would add also that impossible things are imaginable.
More prosaic, but equally important, deployment is just a file copy.
Dependency management is pushed to development time where, I think, it rightly 
belongs.

-Gyepi

__DATA__

package main

import (
"bufio"
"fmt"
"log"
"os"
"strings"
)

type Counter map[string]int

func main() {

input := "/dev/stdin"

if len(os.Args) > 1 {
input = os.Args[1]
}

in, err := os.Open(input)
if err != nil {
log.Fatalf("open: %s. %s", input, err)
}

scanner := bufio.NewScanner(in)

var (
lines []Counter
maxCols, numlines int
firstline string
)

splitChar := ","

scanner.Split(bufio.ScanLines)
for scanner.Scan() {

words := strings.Split(scanner.Text(), splitChar)

cols := len(words)

if numlines == 0 {
lines = make([]Counter, cols)
for i := range words {
lines[i] = make(Counter)
}
firstline = scanner.Text()
maxCols = cols //cap column count to first column count
}

numlines++

if cols > maxCols {
cols = maxCols
}

for i := 0; i < cols; i++ {
lines[i][words[i]]++
}
}

fmt.Printf("filename: %s\n", input)

if numlines > 0 {
fmt.Printf("firstline: %s\n", firstline)
}

for i, counter := range lines {
fmt.Printf("field#: %d distinct: %d\n", i, len(counter))
}
}

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] perl program to count distinct values - can it be made faster

2014-03-08 Thread Gyepi SAM
On Sat, Mar 08, 2014 at 02:12:50PM -0500, David Larochelle wrote:
> On Sat, Mar 8, 2014 at 1:40 PM, Gyepi SAM  wrote:
> 
> > For fun, I wrote a version in Go and it's twice as fast as the perl
> > version. I imagine a C version would be faster yet, but I get paid for that
> > kind of fun. I'd be happy to send you the Go version if you're interested.
> 
> 
> 
> I'm curious how you account for disk caches when your bench marking. I
> fully expect that the CPU version of the code will be faster in GO than
> Perl. But I wonder how much this matters if the file isn't already in the
> disk cache.
> 
> An interesting test would be to run the GO version first on a file that's
> you can be sure is not in the disk cache, then to run the Perl version on
> that file. I.e. let Perl benefit from the disk cache and see if GO is still
> faster.

I have an SSD drive on my linux laptop so disk caching plays less of a role in
my tests. I clear the cache with:

echo 3 | sudo tee /proc/sys/vm/drop_caches

I repeated the tests after clearing the disk cache each time and also ran each
test multiple times without clearing cache. The cached versions are a few
seconds faster, but the overall results are the same; the Go version is about 
twice as fast.

-Gyepi

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] perl program to count distinct values - can it be made faster

2014-03-08 Thread Gyepi SAM
On Sat, Mar 08, 2014 at 10:59:22AM -0500, Steve Tolkin wrote:
> # return code: 0 == success; 1 == some warnings; 2 == some errors
> my $rc = 0;

This value never changes. I assume the larger program could change it.

> my $split_char=',';  # CHANGE ME IF NEEDED (later use getopts)
> 
> my @aoh; # array of hashes: key is the field value; value is the count
> my $numlines = 0;
> my $firstline;
> while (<>)
> {
> chomp;
> $firstline = $_ if $numlines == 0; 

More idiomatically written as:

 $firstline ||= $_;

> $numlines++;
> my @data;
> 
> # Seemingly extra code below is for compatibility with older perl
> versions
> # But this might not be needed anymore.
> if ( $split_char ne '' )
> { @data = split(/$split_char/,$_); }
> else
> { @data = split; }
If you're really looking for optimizations, this test can be moved outside
the loop. Since no arg split splits on spaces, your check can be something
like:
$split_char = ' ' unless $split_char;

Then the test and two split options can be replaced with 

@data = split /$split_char/, $_;

There may also be some benefit to hoisting the regular expression outside the 
loop:

my $re = qr/$split_char/o;
...
@data = split $re, $_;

If there's any, it will be tiny, but may be appreciable given your input size.

> # Populate array of hashes.  (This uses perl "autovivification"
> feature.)
> for (my $i = 0; $i < scalar @data; $i++) {
> $aoh[$i]{$data[$i]}++;
> }
> }

Nit: "scalar @data" can be replaced with @data.

> # print output
> print "filename: $ARGV\n"; # This writes a "-" if data is piped in
> if ($numlines >0) {
> print "firstline: $firstline\n";
> }
> print "numlines: $numlines\n";
> for (my $i = 0; $i < scalar @aoh; $i++) {
> # The number of keys in a hash is the "count distinct" number
> print "field#: ", $i, ", distinct: ", scalar keys %{$aoh[$i]}, "\n";
Nit: This reads better as a printf, I think.

printf "field#: %d, distinct: %d\n", $i, scalar keys %{$aoh[$i]};

> }
>
> exit $rc;

This is always 0, as noted above. 

My initial thought at improvement was to avoid the split and walk through each
line looking for a $split_char or a "\n", but that just duplicates split in
perl instead of C. I think you've got just about the fastest program in perl.

For fun, I wrote a version in Go and it's twice as fast as the perl
version. I imagine a C version would be faster yet, but I get paid for that
kind of fun. I'd be happy to send you the Go version if you're interested.

-Gyepi

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Inline::Java

2013-05-29 Thread Gyepi SAM
On Wed, May 29, 2013 at 01:41:56PM -0400, David Larochelle wrote:
> My biggest concern with Inline::Java is why it isn't more widely known and 
> used.

I would not read too much into the fact that a particular solution is not
popular. I have used, and continue to use, such tools when appropriate.

Having said that, most environments and programmers tend to be monolingual
and tend to prefer solutions that don't cross languages. It's an easy and safe
decision to make whereas the other requires careful thought and good reasons.

-Gyepi

-- 
Kites rise highest against the wind---not with it.
--Winston Churchill  

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] printing Perl code (hardcopy)

2013-05-10 Thread Gyepi SAM
On Fri, May 10, 2013 at 09:14:25PM -0400, Adam Russell wrote:
> I am trying to make Perl code look good in print.
> I have tried perltidy and it doesn't really seem to do the simple thing that 
> I want.
> I guess I just want to "pretty print" more than completely reformat the code 
> in ways other than I originally wrote it. That is, I don't care about if 
> there is a space between operators and things like that...I just want long 
> lines to wrap in a way that looks good in print or at least get some warning 
> that line X is too long to fit on a page of any given size (assuming some 
> default of letter or A4). Maybe some other niceties I haven't thought of?
> Anyone have any suggestions or comments? How do authors of Perl books handle 
> this?

I just tried a2ps and it produces decent looking output on an old script of 
mine.
It looks like there are a few knobs to turn.

a2ps -o file.ps -Eperl file.pl

Other programs to look at:

enscript
Source-highlight
trueprint
lgrind


I, for one, would be interested in finding out what you discover/decide on for
future reference.

-Gyepi

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Test code generation

2013-04-16 Thread Gyepi SAM
On Tue, Apr 16, 2013 at 11:35:55AM -0700, Ben Tilly wrote:
> On Tue, Apr 16, 2013 at 6:51 AM, Gyepi SAM  wrote:
> > On Mon, Apr 15, 2013 at 11:35:22AM -0700, Ben Tilly wrote:
> >> On Mon, Apr 15, 2013 at 11:09 AM, Greg London  wrote:
> >> For unit testing I've been emitting TAP
> >> protocol and testing it with prove, but are there better approaches?
> >>
> >> I get a test file with a lot of code that looks like this:
> >>
> >>   printf(
> >> "%s %d: Some useful description and maybe a number %d\n",
> >> (expected_value == test_value) ? "ok" : "not ok", ++tests,
> >> some_useful_debugging_info
> >>   );
> >
> > Instead, I generate the test file from a simpler data file that only
> > contains the relevant test data.

> I think you're visualizing something different than my actual problem.
>  There are indeed a lot of lines in my test file resembling the
> pattern that I showed.  But I do not primarily have values in/out.
> Instead I set up method calls, make them, then go poking around the
> innards of data structures and verify that they have what I expect
> them to have.  This requires intimate knowledge of the class that I'm
> testing, which is not so automatable.

Yeah, I'd have been quite surprised if my response solved your problem directly.

In general, I use code generation as a mechanism to give myself a little
more room between the various stages of program construction (edit, compile, 
run)
so I can insert a translation step which allows me to introduce new
modes of expression that more closely model the particular sub-problem
I'm trying to solve. Also, I'd rather write a program that writes programs.
Particularly when the resulting program is tedious.

I was not suggesting that data files should only contain in/out values.
Sometimes that is the case, but sometimes you need something more complicated.
In most cases, my "data" files actually specify some kind of a little language 
close
to the problem domain and my translator converts it back into the host language.
Actually, that reminds me you could also follow the old embedded SQL path and 
use a
tool like cog to simplify some of your tests.

Obviously, if the validity of the test depends on eyeballing the results
there's not much to say in the way of automation. Until you get tired of
eyeballing ;)

-Gyepi


___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Test code generation (was C++ books)

2013-04-16 Thread Gyepi SAM
On Mon, Apr 15, 2013 at 11:35:22AM -0700, Ben Tilly wrote:
> On Mon, Apr 15, 2013 at 11:09 AM, Greg London  wrote:
> For unit testing I've been emitting TAP
> protocol and testing it with prove, but are there better approaches?
> 
> I get a test file with a lot of code that looks like this:
> 
>   printf(
> "%s %d: Some useful description and maybe a number %d\n",
> (expected_value == test_value) ? "ok" : "not ok", ++tests,
> some_useful_debugging_info
>   );

This method is usually tolerable for a while but gets old as soon as
I realize I'm doing the computer's job much slower and less accurately.
Instead, I generate the test file from a simpler data file that only
contains the relevant test data.

I've successfully used three different approaches for this:

1. Extract the relevant data into a text file
   and use it as input to a program that produces the test file.
   This works well when the input has a lot of variety or could change in
   unexpected ways, but then you also have a code generator to maintain.

2. Extract the relevant data into XML and use gsl 
(https://github.com/imatix/gsl)
   to generate the test file. Works well when the test data varies in ways
   that can be relatively easily expressed by xml. While this approach works
   well, I don't particularly like editing xml so I actually write my data in a
   hierarchical text format and use, shameless plug, txt2xml 
(https://github.com/gyepisam/txt2xml)
   to convert it to xml. 

3. I have some similar things with autogen (apt-get install autogen) and it
   works pretty well too.

The various conversions from txt to xml to c and h, do produce long pipelines,
but I use make so I just define implicit rules and let make resolve the
dependency chain for me. Then I can kick it off with.

make test

It works quite well and the pieces are modular enough that the next guy is 
likely
to understand it. However, understanding is not required for effective use,
which is usually the primary goal.

-Gyepi

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Perl and recursion

2013-04-10 Thread Gyepi SAM
On Tue, Apr 09, 2013 at 10:24:45PM -0400, Bob Rogers wrote:
>map should produce better code and does reads better but it also
>iterates the entire list and you can't break out of it . . .
> 
> Not quite true, as you can "goto" a label outside of the block:
> 
> sub find_odd {
>   # Return the first odd argument.
>   my (@values) = @_;
> 
>   my $result;
>   map { $result = $_ and goto LAST
> if $_ & 1;
>   } @values;
>   LAST:
>   return $result;
> }

Indeed, you are correct. However, when you break out of a map in this way,
the map returns an empty list, regardless of how many results had been 
previously
collected. 

Because your example handles a single result, it is not clear that, in fact,
any return values MUST be collected similarly. Unless, of course, map is used
simply for side effects.
 
> It's hard to think of a case where this would be better than a simple
> loop, which is both smaller and more readable.  However, this technique
> also gives you an early exit when mapping over a tree recursively.

Even then, the need to handle collected values manually would seem to obviate
any advantage in doing so.

This discussion has confirmed, for me, that writing code is, in many ways,
similar to writing prose. Though there may initially, appear to be many ways
to communicate, thoughtfulness, good taste and circumstance quickly show that
there are only a few good ways to do so.

-Gyepi 

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Perl and recursion

2013-04-08 Thread Gyepi SAM
On Mon, Apr 08, 2013 at 10:54:47AM -0400, Ricker, William wrote:
> Have we mentioned the other solution? 
> The Implicit loops of map {block} list; should produce more optimized code 
> and reads better too. 

map should produce better code and does reads better but it also iterates
the entire list and you can't break out of it. I think it's only a viable
solution in the limited case of a for loop that doesn't have a stopping case
or filtering.

Well, the filtering part is not really true: it could be more expensive to say

   @result = map {BLOCK} grep {PREDICATE} @list;

than

  my @result;
  for my $element (@list) {
push @result, $element if PREDICATE;
  }

but the former simply reads better and, in the absence of other necessities, I 
prefer it.

As for recursion, I don't think one can easily replace a recursive solution
with map. Replacing recursion with iteration requires a base 
condition (and, possibly, a stack) and map doesn't handle stopping conditions.
One could work around it, I suppose, but not cheaply and the code would almost
certainly be tasteless.

-Gyepi

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Perl and recursion

2013-04-06 Thread Gyepi SAM
On Fri, Apr 05, 2013 at 09:15:11PM -0400, Conor Walsh wrote:
> Detailed?  What's kept beyond "a called b (arguments...)" ?  That's not a
> lot of bytes, unless it's complete deep copies of structures.

The activation record is itself not large, but many calls do add up.

The larger problem is that any memory allocated inside a function is only freed
when the function call returns. So a deeply nested stack uses more 
memory beyond the activation records. Depending on the function, it could be 
substantially more.

-Gyepi

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Perl and recursion

2013-04-06 Thread Gyepi SAM
On Sat, Apr 06, 2013 at 09:11:55AM -0400, David Larochelle wrote:
> Are languages that have mark and sweep garbage collection better about
> returning memory to the system than languages like Perl that use reference
> count garbage collection.

Not usually.  On Unix systems, at least, memory is acquired from (and released
to) the system using sbrk. malloc(3) and free(3) are actually front ends to
sbrk. free marks memory as available to be reallocated, but only returns 
memory when there is enough of it at the high end of the heap. Depending
on usage patterns this is unlikely to happen naturally unless memory is first
compacted.

This is an additional step to the garbage collection and not many languages do 
it AFAIK.
I know Lisp can do this, but only to avoid fragmentation and does not return 
the memory.

It is generally not necessary to return memory to the system because
most modern operating systems provide a virtual view of memory so every
program appears to have access to the entire memory space. Most of the time
this works fine. Programs that allocate too much get swapped out when
necessary. If you don't want that for your program, you can always use
mlock(3) and friends.

-Gyepi

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Perl and recursion

2013-04-05 Thread Gyepi SAM
On Fri, Apr 05, 2013 at 09:03:13PM -0400, Conor Walsh wrote:
> why is this that much faster than actual recursion?  That speaks
> poorly of lowercase-p perl.

This is not a perl specific issue (for the most part).

Most languages that support function calls need to maintain an activation
record for every call in order to keep track of, at the very least,
parameters, return values, next action, etc [1]. A recursive function creates
a chain of these records.

So, Uri's suggestion is faster because replacing recursion with iteration and
stack operations uses fewer resources than the runtime does in maintaining a 
call stack.
More to the point though, one avoids the built in limits, or rather, exchanges 
that limit
for memory limits.

I don't think this speaks poorly of perl at all.
Every operation has a cost, after all, and function calls are relatively 
expensive.
Certainly more so than iteration or array operations.

[1] There are a couple of ways to avoid this problem while still maintaining the
benefits of recursion. One is to use threaded code, as in Forth, or more 
commonly,
to use tail recursion (or tail call elimination), which re-uses the current 
activation
record for the recursive call, iff the recursive call occurs at the end of the 
function
since that means that the only state we need store are the return values.
Since those are on the stack, they can, with a bit of pointer twiddling or 
copying,
become the parameters to the next call.

A number of languages do this, to great advantage.
Perl does not have tail call elimination. However, it is mentioned in 
"Porting/todo.pod"

-Gyepi

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] Tone: was (Passing large complex data structures between process)

2013-04-05 Thread Gyepi SAM
John, I don't know you, and it's quite possible that I am misinterpreting
your normal modes of communication, but your responses seem quite heated,
intemperate, and rather personal. There are certainly places for that on the 
internet,
but the collegiality of this list is one of the reasons I, for one, remain 
subscribed.
I think we can discuss the merits of the suggested solutions without the 
aspersions.

Regards

-Gyepi


On Fri, Apr 05, 2013 at 06:35:58PM -0400, John Redford wrote:
> Ben Tilly expands:
> > On Fri, Apr 5, 2013 at 12:04 PM, John Redford  wrote:
> > > Your writing is FUD.
> > 
> > Are you reading something into what I wrote that wasn't there?
> > Because I'm pretty sure that what I wrote isn't FUD.
> 
> It was. Ask anyone. I'm not your English tutor.
> 
> > A pull-based system relies on having the job that does the work ask for
> work
> > when it's ready.  A push-based system relies on pushing to a worker.
> 
> So, let's get this straight, pro.


___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Passing large complex data structures between process

2013-04-04 Thread Gyepi SAM
On Thu, Apr 04, 2013 at 04:21:54PM -0400, David Larochelle wrote:
> My hope is to split the engine process into two pieces that ran in
> parallel: one to query the database and another to send downloads to
> fetchers. This way it won't matter how long the db query takes as long as
> we can get URLs from the database faster than we can download them.

If this is, indeed the bottle neck, then I would think that splitting them
into two communicating processes would solve the problem.

Using files, as I mentioned in my previous email, is probably considered
"old school" but is probably the simplest communication method.
Unfortunately, it won't work once your system scales to multiple machines.
As described, it sounds like the current system runs on a single machine,
so this may not be an immediate problem. If you are planning to scale across
machines, then I'd second the recommendation to use a message queue instead.

-Gyepi

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Passing large complex data structures between process

2013-04-03 Thread Gyepi SAM

On Wed, Apr 03, 2013 at 10:34:17AM -0400, David Larochelle wrote:
> I'm trying to optimize a database driven web crawler and I was wondering if
> anyone could offer any recommendations for interprocess communications.
> 
> Currently, the driver process periodically  queries a database to get a
> list of URLs to crawler. It then stores these url's to be downloaded in a
> complex in memory and pipes them to separate processes that do the actual
> downloading. The problem is that the database queries are slow and block
> the driver process.
> 
> I'd like to rearchitect the system so that the database queries occur in
> the background. However, I'm unsure what mechanism to use. In theory,
> threads would be ideally suited for this case but I'm not sure how stable
> they are (I'm running Perl 5.14.1 with 200+ cpan modules).
> 
> Does anyone have any recommendations?

Here's my 5 cents worth [1].

I would imagine that the database query, though slow, produces results
faster than the crawlers consume them.
So the problem sounds like one about maintaining a minimum queue size. 

An actual queue would be the obvious solution, but that brings in Threads,
which you want to avoid.

I can think of a couple of other other solutions:

Since you need parallelism, both depend on moving the database querying to
another process.

The database transfer from the db (producer) process to the driver (consumer)
process could use files or a socketpair between parent and child.

File solution:

The producer program reads the database and writes the data
into files in chunks of size N. The consumer program, when it runs
low, reads one of the files and renames it.

To simplify access, I would use the maildir model and use the three directories

.../tmp
.../ready
.../done

The producer writes each file into tmp and uses rename to move the file
from tmp to ready. Luckily, perl's rename is a wrapper around rename(2)[2]
so you gain the critical benefit of atomicity here.

Similarly, the consumer reads a file in ready and
renames it into done. Periodically, you'll want to clean out done.

SocketPair:

Make the producer a parent process of the
consumer. The producer creates a socketpair and forks the consumer. The
producer prefetches the data and writes it to the socket when the consumer
signals a need for more data. Both would need to use select otherwise one
or the other could block, defeating the goal of the exercise.

I should point out that technically, the processes don't have to be related
and you really only need sockets. The producer only needs to prefetch and
buffer data and provide it as soon as possible.
A simple server can do that in a tight loop all day long (I don't recommend it
though unless you have a feedback mechanism into the database to ensure that
it always gets the correct results even in the face of an earlier error).

[1] Inflation.
[2] I am making the big assumption that you are on a unixish system here.
If that's true, then you can also add notifications as well, if you care.

-Gyepi

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] New Xkcd feaaturing Perl

2013-02-15 Thread Gyepi SAM
Hmm, I also spot allusions to a Jay Z song and a JWZ quote.
Maybe Randall had /J.+Z/ on the mind.

-Gyepi

On Thu, Feb 14, 2013 at 12:57:44PM -0500, Federico Lucifredi wrote:
> http://www.xkcd.org/1171/

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] The second P

2012-01-26 Thread Gyepi SAM

I have found the "hard" way (of going through the documentation) to be quite
effective.

First, I read the tutorial, then skimmed the language reference, then I jumped 
into the library reference with the
occasional return to the language reference when I needed to convince myself
that python's syntax did not allow for whatever construct I had my heart set
on.

It's a bit slow initially but the language is simple enough that the pace picks 
up
pretty quickly.

Regards

-Gyepi

On Thu, Jan 26, 2012 at 08:12:45PM -0500, Federico Lucifredi wrote:
> Okay guys,
>   I haven't gotten a definite answer on this when I asked a couple of years 
> back, so I'l ask again - flog me as you may :)
> 
>   I have a need to properly learn a certain other "P" language, and I do not 
> mean PHP either.  For Perl, my favorite "concise" summary is the first 
> chapter of Damian's OO Perl book.  What about the other, unnamed, language? 
> Guido has written up a short language on the book, but what else has proven 
> popular with people who already knew Perl to expand their range of dynamic 
> languages - without reading hundred of pages?
> 
>  Thanks -Federico
> 
> PS: I promise to flog myself if you guys actually come up with a good 
> suggestion!
> 
> _
> -- "'Problem' is a bleak word for challenge" - Richard Fish
> (Federico L. Lucifredi) - flucifredi at acm.org - GnuPG 0x4A73884C

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] looking for MaxMind contact

2011-10-02 Thread Gyepi SAM
Hi - 

A friend is looking for a contact at MaxMind and I wonder if I could pass on
an intro through anyone on this list. Please respond off-list.

Thanks!


-Gyepi

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] backticks tee'd to stdout ?

2011-07-21 Thread Gyepi SAM
On Thu, Jul 21, 2011 at 01:44:48PM -0500, Greg London wrote:
> If I open a pipe on a command that has a nonzero exit status,
> where do I check that???


 close($HANDLE2);

after the read loop in order to get its correct exit status.
If you really want to be thorough, do

 my $r = close($HANDLE2);

and look at $r to determine whether you even need to look at $?, etc.

man perlfunc#open for details and other useful bits.

-Gyepi

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] emergency social - tues 7pm, sunset grill and tap

2011-05-15 Thread Gyepi SAM
I'll be there! Looking forward to it.

-Gyepi

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] arriving tonight - emergency social meet monday or tuesday?

2011-05-15 Thread Gyepi SAM

On Sun, May 15, 2011 at 12:12:47PM -0400, Uri Guttman wrote:
> > "RLS" == Randal L Schwartz  writes:
>   RLS> Was there any consensus on a date (tuesday or monday) and/or a place
>   RLS> for my emergency social meet?
> 
> that is on me. i say we meet on tuesday night at 7pm. i haven't figured
> out a place yet but i will. any suggestions are welcome from the list so
> send them in.
> 
> the harborside inn is near faneuil hall which is full of tourist traps
> and expensive parking so i say not around there. our usual place cbc is
> possible. so is redbones or even the flatbread pizza place we met at
> recently.

I'll be in the Boston area Tuesday and would be most happy to
join in this social meeting wherever it ends up.
So I vote for Tuesday!

Regards

-Gyepi


___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] $#{$Queue}

2010-09-28 Thread Gyepi SAM
On Tue, Sep 28, 2010 at 07:07:38PM -0400, Greg London wrote:
> Ive used $arr[-2] to get the second to last element of an array.
> But anyone using $[ to change the first index of an array to be
> negative should be beaten severely.

I had initially thought this too; though I imagined something
worse than a beating. However, upon further thought, I think it
can be occasionally useful to change the first index of an array.

Unfortunately, the most useful example I can come up with is from another
language.

In Lua, the equivalent of $ARGV[0] contains the script name while lower
indices reference earlier parts of the invocation. So

  lua -i script.lua 24

creates the equivalent of

  $ARGV[-2] = 'lua'
  $ARGV[-1] = '-i'
  $ARGV[0] = 'script.lua'
  $ARGV[1] = '24'


The point here being that the "useful" data starts at $ARGV[0] while,
perhaps less useful, data exist at earlier indices. Of course this is
a contrived example and Lua arrays are different enough from Perl arrays
to make this simple.

I think '$[' would more useful if it could be scoped to individual arrays.
Though it does seem to be of dubious utility to begin with.

-Gyepi

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] my lang is better than your lang!

2010-07-19 Thread Gyepi SAM

On Mon, Jul 19, 2010 at 05:01:09PM -0400, Uri Guttman wrote:

> gack, this thread is annoying. so here are some high level philosophical
> questions to think about regarding languages.

Great questions all. This is partly why I hang out at the perl bar.

> first off, why are there so many languages? and by many, i mean
> thousands and more. how many of you have invented a language (even a
> mini-lang)?

There are many reasons why there are so many languages; fun, profit,
inventiveness, need, annoyance are all good reasons, I am sure.

The last language I implemented was a domain specific extension language,
with VB like syntax, for a new system I was building.
The parser needed to hook into the application to validate incoming code
and generate code in a different language. One of the reasons for writing a
new language is that none of the existing languages I reviewed had a friendly
enough syntax for non-programmers and and didn't have the level of validation
the users needed. Writing a computer language for non-programmers is very
hard. 

I have also implemented a lisp system in perl. Which was a really fun project.
Can't say it made me a better perl programmer, but definitely improved my lisp!

> no one seems to have mentioned turing compatibility. this means
> something deep in all the langs mentioned. discuss.

No one mentions it because most languages that most people know are,
and people implicitly assume their languages are Turing complete and
equivalent even if they don't know about it. For most people, syntax
is a more important criteria than power.

> what about all those langs that were meant to conquer computing
> civilization? PL/I, COBOL, ALGOL and even the dreaded ADA. c actually
> conquered more than all of them. do you consider c a high level
> language?

Any claim that a language will conquer computing civilization is mere
marketing. For better or worse, marketing is frequently effective.
I'm old enough now to remember, Windows, 4GL languages, relational databases,
C++,  Java and the Internet all touted (rarely by technical people) as
the most exciting thing ever. Obviously we know better.

> should you learn assembler? is there work in it (yes)? what would
> assembler teach you when using a high level lang?

Absolutely! I thoroughly enjoyed learning assembler. Though I no longer
program in it, I still look at the assembler my compilers generate.
Ultimately, your code has to be executed by the machine. It helps to
know how it does it so you can write tasteful code.

It amazes me when I see a piece of code that is inefficient,
wasteful of resources or just slow because the author did not understand
what really happens to their code. This is especially true of so called
scripting languages. For some reason, some scripting language programmers
seem to thing it's ok to write poor quality code, perhaps on the hope that
the interpreter will magically improve it.
I firmly believe that every programmer should understand what their
compiler or interpreter does with their code. Even just reading the code is a 
good first step.


> what does it mean when you like or dislike a lang? in a non-technical
> way why did you make that decision?

Languages exist in a social environment that extends beyond programmers and are
rarely considered solely on technical merit. I suspect that most
programmers 'choose' their languages because of a job, popularity or the
similar factors and a relatively few choose them based on technical merit.
I've been relatively lucky enough to have the freedom to choose the languages I 
know.
I learned Perl because it helped me to generate code for other languages:
about 14 years ago I was writing a program in VB and got tired of the boiler
plate and decided to write a meta-program in Perl to generate the VB code.
Later, while working on a C based virtual machine, I used Perl to generate the 
ops tables
and parts of the grammar file. Trivial stuff now, but a big deal for me back 
then
and the beginning of the realization that some languages are better at some 
things
than others and that it's better to know a lot of languages than just one.

Today, I don't even 'think' in any specific language.
Occasionally, I find myself typing syntactic constructs that don't exist
or don't exist in the particular language I'm working in. It's either a
'senior' moment or time to write that DWIM meta-language.

Of course, I have my non-technical preferences, like everyone else:
I don't like languages that are too verbose, don't have features I consider to 
be
useful/necessary, or force me to jump through hoops even for simple programs.
Yes, it's all a matter of taste and I make exceptions for my favorite
languages.

I like Lisp but still compile snippets of C into assembler
to see what the compiler is doing.

> have any of you ever read an ANSI standard for a language? or tried to
> implement parts of a standard like that? hell, reading ANSI standards is
> a major skill in its own right!

I've re

Re: [Boston.pm] Baby boy

2008-09-29 Thread Gyepi SAM
On Sun, Sep 28, 2008 at 02:47:16PM -0400, Ronald J Kimball wrote:
> Fellow Boston Perl Mongers, of all the announcements I have sent to this
> list over the years, this particular one is, for me, the most exciting:
> 
> Tobias Theodore Kimball-Ware
> son of Ronald Kimball and Martha Ware
> Saturday, September 20, at 11:55am
> Weight: 8 pounds, 11 ounces
> Height: 21 inches
> 
> We're all happy, healthy, and tired.  You can find photos and more info at
> our blog:
> 
> http://littleturniphead.blogspot.com/
> 
> Ronald

Congratulations Ronald! Most exciting news indeed.

-Gyepi



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] merging lists that are ordered but not sorted

2008-01-29 Thread Gyepi SAM
On Tue, Jan 29, 2008 at 12:11:56PM -0500, Tolkin, Steve wrote:
> I am looking for a perl program that will solve the following problem.
> Suppose I have 2 or more lists that are (conceptually) sublists of the
> same underlying list.
> I want to reconstruct the underlying list.  In other words the order of
> the elements agrees in all the lists, but there is no sort condition.
> 
> Example:
> List 1: dog, cat, mouse
> List 2: dog, shark, mouse, elephant
> 
> There are 2 possible outputs, and I do not care which one I get.


Sounds like a problem begging for tsort.
'man tsort' or 'info coreutils tsort'.
Should be on most unixoid systems.

You'd need to pre-process your data into pairs of strings
and feed that to tsort, which will produce one of the possible
totally ordered outputs.

$ tsort 

Re: [Boston.pm] Send Setup commands to Brother HL5250 printer?

2007-11-07 Thread Gyepi SAM
Hi Bob,

CUPS would definitely not expect PCL input. Not sure if it's possible to tell
it otherwise.

A couple of suggestions:

If you're generating PCL from your program, you may want to consider filtering
it through GhostPCL which converts PCL into Postscript.

If you're not averse to python, labelnation 

prints labels quite well. I doubt it will have support for your
particular labels,  but it's quite easy to add new labels. I've had very good
luck with it. It used to be a perl program, BTW.

postscript does not have the concept of margins. by default, printing starts
on the edge of the paper (or nearly so). However, CUPS does have margin 
settings:
see the ppd file for your printer. I suspect you'll need to modify the 
'ImageableArea' values.

Here's how you set a font a postscript:

%Set font to 12 point Helvetica
/Helvetica findfont 12 scalefont setfont

HTH

-Gyepi

On Tue, Nov 06, 2007 at 12:10:45PM -0500, R. Mariotti wrote:
> Fellow luggers;
> 
> I have a short perl program that prints labels n-up on standard letter 
> sized pages (actually Panduit Labels).
> 
> This originally printed to an HP2600 printer which has since been 
> retired and replaced with a Brother HL5250DN printer.
> 
> This printer is connected via CUPS on Linux so I am not sure if cups is 
> converting the output to postscript or sending pcl.  The printer 
> emulation is set to pcl (but I know it can change dynamically).
> 
> I have been trying to send pcl commands from my perl program to modify 
> the offsets, margins, typeface, etc with NO success.
> 
> Therefore, has anyone printed such commands before and especially to 
> this printer?
> 
> My method is really simple such as:
> 
> print OFH "\x1B\&a0L";# Set Left Margin to Zero columns
> 
> When run the esc (x1B) is being eaten but the &a0L prints as text 
> indicating that the printer is NOT recognizing it as a command.
> 
> That would indicate to me that cups is sending the output as postscript 
> which switches the printer to PS mode so it would not intercept the pcl 
> commands.
> 
> If that is true, can anyone PLEASE provide some equiv PS commands to set 
>   some of the parameters?  I've search the PS docs with no clear examples.
> 
> Thanks in advance for any assistance.
> 
> Bob
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Linux Magazine survey: Are you still using Perl?

2007-07-13 Thread Gyepi SAM
On Fri, Jul 13, 2007 at 12:46:15PM -0400, Philipp Hanes wrote:
> Good surveys are quite difficult to construct.

Indeed. And good surveys about specialized topics are even more
difficult without topical expertise.

I just took the survey and agree that many of the single choice questions
should have been multiple choice. Like many people, I just a mixture of
languages, frameworks and even editors. However, nuanced answers don't
translate well into rankings ;)

-Gyepi
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Reading a variable CSV file with embeded newlines

2007-06-08 Thread Gyepi SAM
On Fri, Jun 08, 2007 at 03:26:56PM -0400, Alex Brelsfoard wrote:
> I have a CSV file where each line may NOT have the same number of fields.
> One item per line.

xSV is line oriented: as long as each line is well formed it should be parsed
correctly. Making sense of the data may be more difficult though.

> But occasionally a field in an item will have one or more newlines in it.
> How can I break this up correctly?

Embedded newlines are OK as long as the field is quoted. However, not all
tools will parse the field correctly. Last time I checked, Text::CSV and
Text::CSV_XS do not. I suspect Text::xSV will be better behaved. There are
other, non Perl, tools that should work fine as well.

-Gyepi
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Calling a function that will return to where the grandparent called the parent

2007-05-31 Thread Gyepi SAM
On Thu, May 31, 2007 at 03:22:32PM -0400, Gyepi SAM wrote:
> Here's an example.

Small editing error with my example: the '__END__' should be after the call to
Plort().

-Gyepi

+ Plort();
+ 
+ __END__

instead of

- __END__
- 
- Plort();


 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Calling a function that will return to where the grandparent called the parent

2007-05-31 Thread Gyepi SAM
Hi Alex,

What you're asking is possible, especially since you only asked for quick and 
easy
and said nothing about elegant ;)

The situation you describe is known as a 'condition' in Lisp, which allows
you to define the catch and handle exceptional conditions in your program,
including *restarting* the offending piece of code (presumably after
changing program state to prevent looping). Most other languages use a
catch-throw construct, which is spelled die-eval in Perl.

Basically, you need to place an eval in Plort and die in Error with a
specific error string (or other unique value) that Plort can use to
distinguish your particular situation from some other error. As you can see,
both routines have to cooperate to make this work: one to throw the error and
the other to catch it.

Here's an example.

#!/usr/bin/env perl

use strict;

$\ = "\n";


#note the all important newline, which prevents perl from helpfully appending
#more text to our error string.
our $ERROR_CONDITION = "Error-Condition\n";

sub Plort {
  print "in Plort, calling Foo()";

  eval {
Foo();
  };

  if ($@){
if ($@ eq $ERROR_CONDITION) {
  print "caught error condition. All is well";
}
else {
  #some other error
  die;
}
  }

  print "in Plort, back from Foo()";
}

sub Foo {
  print "in Foo, calling Error()";
  Error();
  print "in Foo, back from Error, but you'll never see this line";
}

sub Error {
  print "in Error";
  die $ERROR_CONDITION;
}

__END__

Plort();
On Thu, May 31, 2007 at 02:11:44PM -0400, Alex Brelsfoard wrote:
> Hi All,
> 
> I'm looking for a quick and easy way to have this situation happen:
> 
> sub Plort {
> ...
> ...
>Foo();
> ...
> }
> 
> sub Foo {
> ...
> ...
> Error();
> ...
> }
> 
> 
> I want it to happen that when Error() is called, when Error() finishes doing
> what it does it returns you to it's parent's parent (Plort() in this case).
> I don't want to have to specify anything.
> I want it to always return you to where Error()'s grandparent called it's
> parent.
> 
> Any ideas of how to do this?
> 
> Thanks.
> --Alex
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] LDAP server recommendations?

2006-11-13 Thread Gyepi SAM
On Mon, Nov 13, 2006 at 04:14:32PM -0500, R. Mariotti wrote:
> I have been searching for a good all-around ldap server to support my project.

I've set up OpenLDAP servers, mostly for samba authentication and it works 
great!

The last installation was 2 or 3 months ago in a 24/7 environment with 
replicated servers,
and it's still humming along. A bit of a pain to setup, mostly because of the
Samba requirements, but works great once you get it. Banged my head against a
wall or two trying to figure out why I could not authenticate until I rebuilt
and reinstalled the rpms (on a FC4 system) server from latest sources at which
point, it worked beautifully.

-Gyepi
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Combinatorics (Permutations)

2005-11-30 Thread Gyepi SAM
On Wed, Nov 30, 2005 at 12:34:58PM -0500, Andrew Medico wrote:
> The anwser is that there is no such thing as a list of lists in Perl -

Don't forget the footnotes:

my @lol = map { [ $_ ] } (0 .. 7);
my $lol = [map { [ $_ ] } (0 .. 7)];

The former is a list of list refs and the latter is a list ref of
list refs and is generally called a list of lists though it's
technically neither.

-Gyepi
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] how to safely access syslog from CGI

2005-10-03 Thread Gyepi SAM
On Mon, Oct 03, 2005 at 05:14:44PM -0700, Ranga Nathan wrote:
> I need to scan the /var/log/messages to provide some tracing info through 
> a CGI. The catch is /var/log/messages is readable only by root and 
> rightfully so. But I do need 'nobody' to be able to scan it.
> I run apache2.
> What is the best way to preserve the security and yet make this happen?
> Thanks

Here are some options, not necessarily recommendations;

1. Change the permissions on the file so it is world readable
2. If #1 is too permissive, change the group owner and put nobody in that group.
3. Modify /etc/syslog.conf so syslog writes to an alternate/additional file 
that is readable by nobody.
4. Write or find an suid program/daemon/server to provide read access to the 
log file.
5. Write a cron driven script that will scan the log file and write the
   results to another file that nobody can read.

And many more in a similar vein.

-Gyepi

 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] possible bug in File::Copy?

2005-07-07 Thread Gyepi SAM
On Thu, Jul 07, 2005 at 12:56:52PM -0400, Alex Aminoff wrote:
> I havent seen any response to my post... I suppose I will take the deafening 
> silence as evidence that there is nothing so flawed about my reasoning as to 
> leap out at the casual observer...

Hi Alex,

perl hasn't changed, File::Copy.pm has changed. Between v2.06 and v2.07,
corresponding to perl v5.8.2 and perl v5.8.3, respectively,

Note the following deletions in the diff:

-no warnings 'io'; # don't warn if -l on filehandle
-if ((-e $from && -l $from) || (-e $to && -l $to)) {

...

 }

--- perl-5.8.2-lib-File-Copy.pm 2003-09-30 13:10:50.0 -0400
+++ perl-5.8.3-lib-File-Copy.pm 2003-12-04 08:11:49.0 -0500
@@ -24,7 +24,7 @@
 # package has not yet been updated to work with Perl 5.004, and so it
 # would be a Bad Thing for the CPAN module to grab it and replace this
 # module.  Therefore, we set this module's version higher than 2.0.
-$VERSION = '2.06';
+$VERSION = '2.07';
 
 require Exporter;
 @ISA = qw(Exporter);
@@ -77,13 +77,12 @@
croak("'$from' and '$to' are identical (not copied)");
 }
 
-if ($Config{d_symlink} && $Config{d_readlink} &&
-   !($^O eq 'Win32' || $^O eq 'os2' || $^O eq 'vms')) {
-   no warnings 'io'; # don't warn if -l on filehandle
-   if ((-e $from && -l $from) || (-e $to && -l $to)) {
+if ((($Config{d_symlink} && $Config{d_readlink}) || $Config{d_link}) &&
+   !($^O eq 'MSWin32' || $^O eq 'os2' || $^O eq 'vms')) {
my @fs = stat($from);
+   if (@fs) {
my @ts = stat($to);
-   if (@fs && @ts && $fs[0] == $ts[0] && $fs[1] == $ts[1]) {
+   if (@ts && $fs[0] == $ts[0] && $fs[1] == $ts[1]) {
croak("'$from' and '$to' are identical (not copied)");
}
}


> 
>  - Alex Aminoff
>BaseSpace.net
> 
> - Original Message - 
> From: "Alex Aminoff" <[EMAIL PROTECTED]>
> To: 
> Cc: <[EMAIL PROTECTED]>
> Sent: Thursday, June 23, 2005 8:28 AM
> Subject: [Boston.pm] possible bug in File::Copy?
> 
> 
> >
> > Hi folks. I use File::Copy in a backup system to copy to and from things
> > that are sometimes filenames and sometimes IO::Gzip filehandles.
> > Everything was OK until sometime in the past year or so when I started
> > seeing a lot of messages like
> >
> > stat() on unopened filehandle GEN0 at /usr/lib/perl5/5.8.5/File/Copy.pm
> > line 84.
> >
> > I did some investigation and found that my files were being copied just
> > fine. Some more investigation and I concluded that File::Copy was
> > calling stat() on something, which might be a file name or a filehandle
> > object, but ignoring the result unless it happened to be a file name, so
> > operating correctly. I surmise that an upgrade to perl 5.8.5 or so added a
> > check for stat() on an unopened filehandle as a helpful warning, and that
> > upgrading perl started these messages.
> >
> > The warnings, while harmless, were landing in folks' email inboxes and
> > they were being annoyed, so I ended up putting a SIG{__WARN__} = sub{...}
> > and SIG{__WARN__} = undef around the copy command, just to suppress the
> > warning messages. This seems inelegant.
> >
> > Could I have found a bug, or rather a formerly acceptable but now less so
> > formulation, that I found in File::Copy? I dove in and modified
> > File::Copy, replacing lines 82-84 with the following:
> >
> > my @fs = $from_a_handle ? () : stat($from); # TEST BY ALEX
> > if (@fs) {
> > my @ts = $to_a_handle ? () : stat($to); # TEST BY ALEX
> >
> > and in fact the warnings were gone.
> >
> > So my question is, am I correct? And if so, can I submit a patch or
> > something to the maintainers of File::Copy? I wanted to ask here first,
> > fairly confident that if my reasoning was flawed you would spot it.
> >
> > Thanks,
> >
> >  - Alex Aminoff
> >BaseSpace.net
> >
> > ___
> > Boston-pm mailing list
> > Boston-pm@mail.pm.org
> > http://mail.pm.org/mailman/listinfo/boston-pm
> > 
> 
>  
> ___
> Boston-pm mailing list
> Boston-pm@mail.pm.org
> http://mail.pm.org/mailman/listinfo/boston-pm

 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Simultaneous redirect to STDOUT & File?

2005-05-09 Thread Gyepi SAM
On Mon, May 09, 2005 at 07:48:09AM -0700, Palit, Nilanjan wrote:
> I want to redirect print output to both stdout & a file at the same
> time: I can think of writing a sub that executes 2 print statements (one
> each to stdout & the filehandle), but I was hoping someone has a more
> elegant solution.

Your solution is basically correct. The devil, however, is always in the
details and IO::Tee should take care of those for you.

-Gyepi
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] HTML Renderer

2005-03-08 Thread Gyepi SAM
On Tue, Mar 08, 2005 at 02:02:47PM -0500, Chris Devers wrote:
> On Tue, 8 Mar 2005, Gyepi SAM wrote:
> 
> > On Tue, Mar 08, 2005 at 12:06:26PM -0600, Alex Brelsfoard wrote:
> > > You might also want to lookin into Image::Magick.> > 
> > Ah yes, a clue!
> > 
> > It turns out that there is an html to postscript converter
> >   
> >   http://user.it.uu.se/~jan/html2ps.html
> 
> Is it aware of CSS and Javascript? The documentation --
> 
>   <http://user.it.uu.se/~jan/html2psug.html>

I don't know. I only glanced briefly at the documentation.

> -- implies that it's aware of CSS (in fact, the config file syntax looks 
> like it's just CSS), but I see no mention of Javascript, which can be at 
> least as important in controlling what ends up on a page.
> It may be attacking a small nut with an enormous hammer, but wouldn't 
> the best approach to this be some kind of scriptable wrapper around the 
> Gecko or KHTML rendering engine? That way you're starting out with the 
> way the represented in a standard client side browser's engine.

You raise good points, and I think that would be the most general approach
if the intent is to convert arbitrary web pages to images. However I don't
know what the original poster had in mind.

> Similarly -- and this way lies madness, I admit up front -- just run the 
> script on a system that can use AppleScript or COM (or WSH or whatever 
> it is, I'm not a Windows programmer) to just automate interacting with a 
> regular browser like Firefox or Safari, and save the result that way. If 
> you run it on OSX, you can go straight from this to a PDF file for free.

That would work too. The simplest solution though, may be to simply feed a url
to the browser and ask it to print the page as a postscript file, which would
then be handed off to ImageMagick. Mozilla and Firefox (at least on Unix) have
the (mozilla|firefox)-remote program but it appears that the
'saveAs("postscript")' command is not implemented, according to this file.

  
http://lxr.mozilla.org/seamonkey/source/xpfe/components/xremote/src/XRemoteService.cpp

-Gyepi
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] HTML Renderer

2005-03-08 Thread Gyepi SAM
On Tue, Mar 08, 2005 at 12:06:26PM -0600, Alex Brelsfoard wrote:
> You might also want to lookin into Image::Magick.  It does some pretty
> impressive things and I could have sworn I read somehwere that it could do
> just that.  I have used Image:Magick before and it's very fun and easy.  I
> would definitely suggest looking into it.  I will too if I get some time
> later.

Ah yes, a clue!

It turns out that there is an html to postscript converter
  
  http://user.it.uu.se/~jan/html2ps.html

and, of course, ImageMagick can convert from postscript to other image
formats...

-Gyepi
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] HTML Renderer

2005-03-06 Thread Gyepi SAM
On Sun, Mar 06, 2005 at 10:34:30AM -0500, Joel Gwynn wrote:
> I'm looking for a server-based object that will do a virtual screen
> capture of a web page and save the result as a jpg.  Sort of like
> http://bettersearch.g-blog.net/
> 
> ideally, it would take a url as an argument, and return a jpg.  Is
> there such a beast?

Something like this, perhaps?
  
  http://www.babysimon.co.uk/khtml2png/index.html

It appears to have recently become unmaintained, so YMMV.

-Gyepi
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: Perl Usability - RE: [Boston.pm] Were to start ?

2005-03-06 Thread &#x27;Gyepi SAM'
On Sun, Mar 06, 2005 at 08:54:50AM -0500, John Redford wrote:
> > From: Gyepi SAM
> > Sent: Saturday, March 05, 2005 11:52 PM
> > Subject: Re: [Boston.pm] Were to start ?
> > 
> > On Sat, Mar 05, 2005 at 07:29:31PM -0800, Arthur Perkins wrote:
> > > and I am interested in
> > > starting a project with a product called ModBus. It is
> > > an embedded application for industrial controllers. I
> > > am not quite clear on how to start.
> Here we have a "very new Perl user" -- the kind that many people claim to
> want to persuade to become an "ardent Perl devotee" or perhaps even a
> "fanatical Perl advocate".  

I am not opposed to those goals. However, they are not mine.

> And what is the response to his request for
> assistance in using Perl to actually solve his problem?  "I have read a
> famously quotable book, and you need to go use a search engine instead of
> expecting people who already know Perl to help you."
> 
> Yes, Alice is fun to read and perhaps fun to discuss with the right people.
> And Perl users have long demonstrated their literary awareness -- however
> specialized and ersatz.  But, if you consider the frame of reference of a
> "very new Perl user", you may realize that he is more interested in solving
> his problem and finding a helpful community than in literature.

Sure. And I am interested in helping him solve his problem. However, there is
no reason to be entirely humorless about it.

> Yes, Google is generally the answer.  That's how I found what I put in the
> first paragraph of this message.  But what kind of "community" grows by
> telling people "You don't need us; we aren't helpful; everything you need
> can be found elsewhere"?  Just something for you to consider.

My response was lighthearted, but certainly no less helpful than yours: I 
provided
a pointer to a source of arguably more useful information.
Given the generality of the question, I don't think I could have done better.
Except perhaps by limiting myself to one quote ;)

-Gyepi
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Were to start ?

2005-03-05 Thread Gyepi SAM
On Sat, Mar 05, 2005 at 07:29:31PM -0800, Arthur Perkins wrote:
> I am very new perl user,

Welcome, very new perl user.

> and I am interested in
> starting a project with a product called ModBus. It is
> an embedded application for industrial controllers. I
> am not quite clear on how to start.

At such times, I have found Alice in Wonderland to be quite instructive.

To wit:

  `Begin at the beginning,' the King said gravely, `and go on
  till you come to the end:  then stop.'

Or this exchange:

  `Would you tell me, please, which way I
  ought to go from here?'

`That depends a good deal on where you want to get to,' said
  the Cat.

`I don't much care where--' said Alice.

`Then it doesn't matter which way you go,' said the Cat.

`--so long as I get SOMEWHERE,' Alice added as an explanation.

`Oh, you're sure to do that,' said the Cat, `if you only walk long enough.'


If, however, you really want to get work done, google seems like a good place
to start.

-Gyepi
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] regex in RHS of s/// spotted

2005-03-03 Thread Gyepi SAM
On Thu, Mar 03, 2005 at 10:45:28AM -0500, Kripa Sundar wrote:
> An unnamed White House source today stated that regexes are
> beginning to infiltrate the RHS of substitutions, and thus
> threaten our national security.
> 
> This was corroborated by the following sighting:
> 
> > s/Perl/(Bike Riding|Gardening|Cooking|Painting|Teaching|Filmmaking)/;

Oddly enough, the the syntactically correct code does not quite have the same
meaning or elegance. Note that I modified the list slightly to avoid manual
quoting:

s/Perl/$z=sub { $_[rand(@_)] }; &$z(qw(Biking Gardening Cooking Painting 
Teaching Filmmaking))/e;

-Gyepi
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] RPM building (was: Bottom Up)

2005-03-01 Thread Gyepi SAM
On Tue, Mar 01, 2005 at 03:16:06PM -0500, Duane Bronson wrote:
> Is there a CPAN "distribution" just as there are Linux "distribution"s?  
> In other words, a collection of CPAN modules that one can install as a 
> bundle rather than having to use the perl -MCPAN install 
> "module_that_wont_compile"?  ActiveState provides PPM which take a lot 
> of pain out of CPAN since so much stuff just doesn't compile on Windows, 
> but modules that don't compile are simply excluded from the PPM 
> database.  Also, some Linux distributions have packages that bundle a 
> bunch of perl modules together, unfortunately, they only work with that 
> Linux distro.  I would prefer a standard distribution of modules for all 
> platforms beyond the limited stuff that comes with the perl install.

I don't know of any CPAN distributions. However, if you are on an RPM based
system, you might try my ovid program

 http://search.cpan.org/~gyepi/Ovid-0.06/ovid

which recursively converts CPAN modules into rpms by following dependencies.
It makes a normally painful and tedious task very easy.
It's rpm specific because that's what I usually use, but that needn't be.

-Gyepi

 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] perl6/pugs

2005-02-28 Thread Gyepi SAM
On Mon, Feb 28, 2005 at 01:40:35PM -0500, Kenneth A Graves wrote:
> I haven't gotten around to playing with Pugs yet, but I did build
> Haskell this weekend.  It's a functional-programming conspiracy.

It must be: I am using LISP, after a long hiatus, and really liking it. I
simply did not appreciate its power upon introduction six years ago.

As I recall, there are quite a few cross language programmers on this
list...

-Gyepi
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Re: CGI Scripts going blank?

2004-12-12 Thread Gyepi SAM
On Sun, Dec 12, 2004 at 05:52:02PM -0500, Ben Boulanger wrote:
> A little more on this.. The error message in the apache error_log is:
>   Bad method or uri at /var/www/html/drivetool/index.cgi line 81
> 
> Line 80-82 in my script is:
> $mdclstr->write_request(
>GET => "/MediaCtrl/cgi-bin/Shell.pl\?Command=seamfg\%20-dk$drive",
>   'User-Agent' => "Mozilla/4.0",
> );
> 
> This works great under firefox/mozilla, even an old netscape.  Anyone have 
> any clue why one would work and not the other?  I wouldn't think it would 
> matter at all which browser was used as this GET is on the server side.
> 
> Any help would be appreciated.

Hi Ben,

You may well get lucky and find that someone had a problem that manifested
itself similarly, but that's no assurance that it is the same problem.

Unfortunately, there's not enough information to answer your question clearly.

Nonetheless, here are debugging some suggestions:

Is "$mdclstr" a string or blessed object?
Does the class or object have a write_request() method?
Are you checking for the return value of the method?
What happens inside the write_request method?
What happens when you invoke curl from the command line with the same URL?
What's the value of the $drive variable?

If none of those suggestions do the trick, I suggest that you provide some
more context for the problem.

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] reading in a directory

2004-12-08 Thread Gyepi SAM
On Wed, Dec 08, 2004 at 12:20:38PM -0500, Uri Guttman wrote:
> browsers were never designed to do much and they are overloaded to the max
> now. classic marketplace beating out quality (in terms of the
> http/browser platform for all things).

Amen! Truer words were never spoken. You would not believe the number of
times, I have determined the best solution to be a client based GUI app using
tk or WxWidgets (formerly WxWindows) then been forced,  instead, to use a
browser because "everybody knows how to use a browser"!

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] more on hosting and email suggestions, any experience with VPS?

2004-12-08 Thread Gyepi SAM
On Wed, Dec 08, 2004 at 11:55:40AM -0500, Andrew Langmead wrote:
> On Dec 5, 2004, at 2:26 PM, Gyepi SAM wrote:
> 
> >The main disadvantage I have found is that you cannot run commands 
> >which
> >require real root privileges. For instance: iptables does not work and 
> >init
> >is really a fake init which cannot be controlled.
> 
> Thank you for pointing that out. I assumed that I would be able to use 
> iptables on the virtual interface (to do things like prevent the 
> machine from initiating network connections.)
> 
> Maybe I need to do more experimenting with user-mode so I'm not making 
> assumptions on what it can or can't do.

As I mentioned in a follow-up message, my provider actually uses Virtuozzo
and not UML as I originally stated. According to John West, in a private
email, neither of those limitations exist on his UML based VPS. Further
investigation has also revealed that the iptables limitation, at
least, is merely a provider policy: they don't include iptables support
in the VPS kernels.

I guess the lesson here is: don't use my provider if you really want full
control of your environment!

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] reading in a directory

2004-12-07 Thread Gyepi SAM
On Tue, Dec 07, 2004 at 02:41:36PM -0800, joe wrote:
> php does multiple file uploads; I've seen it work but haven't looked at
> how it manages it. More here:
> 
> http://www.php.net/manual/en/features.file-upload.multiple.php

The link shows an example of "multiple file uploads" where each
file gets its own text box and must be individually selected. We've already
discussed that option but it isn't quite what Alex mentioned.

Just to be clear, the inability to do multiple file uploads with a single
selection is a result of several factors including: the HTTP standard, web
browser security, and current browser behaviour. It is not dependent on the
server side language, be it Perl, PHP, Python, or whatever.

It can, however, be done if your program runs *on* the browser.

-Gyepi

___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] reading in a directory

2004-12-07 Thread Gyepi SAM
On Tue, Dec 07, 2004 at 02:13:16PM -0600, Alex Brelsfoard wrote:
> Well, basically, I'm just trying to do a batch upload for my photo album. 
> I already have it setup so that I can upload one picture at a time.  But
> say I want to upload all of the pictures from a wedding or something. 
> They all belong to the same album, have the same date, same photographer,
> and some of the same categories.  So i am trying to create a batch upload
> system for these purposes.  I can do this for one file.  I just need to
> make it possible for more than one.  Should I be seeing if there is a
> way I can get the user to be able to select more than one file from their
> computer (as opposed to selecting a directory)?

You could provide a column of file upload boxes, but they would still have to
select each file. If that gets tedious, you may want to consider the option of
uploading a zip file which gets unpacked server side. Given that most of the
pictures would share the same metadata, they could enter all the data at
upload time.

> Or am I simply going to have to get inventive with the use of several
> languages?

You could use Java applets or MS ActiveX (or whatever it's called now) for
multiple uploads. Otherwise, you're stuck with uploading single files.

-Gyepi

___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] more on hosting and email suggestions, any experi ence with VPS?

2004-12-07 Thread Gyepi SAM
On Tue, Dec 07, 2004 at 03:14:13PM -0500, Philipp Hanes wrote:
> 
> > -Original Message-
> > From: Peter Wood [mailto:[EMAIL PROTECTED]
> > I just visited www.tektonic.com, and they appear to be an
> > acquisitions/holding company... do you have a direct link to
> > information on their services?

> looks like it ought to be www.tektonic.net

Indeed! Thanks for the correction Philipp.

Upon further investigation, it turns out that my provider switched sometime
ago to Virtuozzo, which probably explains the reliability improvement.

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] more on hosting and email suggestions, any experience with VPS?

2004-12-07 Thread Gyepi SAM
On Tue, Dec 07, 2004 at 01:27:55PM -0500, David Meyers wrote:
> I looked into using a VPS and the thing which kept me from going
> with it was the lack of backups.  Any backing up of one's server
> had to be done by oneself.

Mine claims to backup every night. I have not had to test it and I also rsync
important files back to home network as well.

> FWIW, I'm using Pair now.
> 
> The only thing that I'd like that they don't provide would be
> a means to use tomcat and to deploy java servlets.

VPS ;)

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] more on hosting and email suggestions, any experience with VPS?

2004-12-07 Thread Gyepi SAM
On Sun, Dec 05, 2004 at 01:11:00AM -0500, Andrew Langmead wrote:
>Does anyone have any  experience with any companies providing "Virtual Private 
>Server" (also 
> called "Virtual Dedicated Hosting")?

After years of using shared hosting services, I switched about a year ago to a
UML based VPS with tektonic.com and am quite happy with it.

For $35/month, I get 4GB of space and two IP addresses with "root" access to a
virtual server on which I run smtp,dns, and http services.

I really like the fact that I can control almost everything and can run any
services I want and am not completely at the mercy of the administrator's
paranoia, ignorance or schedule.

The main disadvantage I have found is that you cannot run commands which
require real root privileges. For instance: iptables does not work and init
is really a fake init which cannot be controlled.

The providers have been very responsive to my needs. They initially had some
growing pains when I first started with them, but have since become quite
reliable.

I am also interested in other people's experiences with similar services.

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] OT: RPMS (was: Recommendation for mail server)

2004-12-02 Thread Gyepi SAM
On Thu, Dec 02, 2004 at 09:17:10PM -0500, Bob Rogers wrote:
>(Though I may do so eventually, if I ever
> finish building RPMs for the qmail suite.)

All the djbware required to run qmail is now available as rpms.
See: http://untroubled.org/rpms/

To keep this on topic, but only marginally: I have released a perl program,
Ovid, which builds rpms for CPAN modules. Unlike other similar tools, follows
most dependencies and builds them too!

-Gyepi

___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] OT: pgp migrate question?

2004-11-16 Thread Gyepi SAM
On Tue, Nov 16, 2004 at 09:22:17AM -0500, Bob Mariotti wrote:
> root directory on the DR machine.  However, while when we display our 
> keyring (i.e.: pgp -kv) we can SEE the keys but the documented 
> passphrase will not work.
> Any ideas, thoughts, suggestions greatly appreciated!

You may want to trace the program execution in both environments to verify your
assumptions. Apparently the strace/truss equivalent on AIX is called sctrace.
You may also find it useful to enable any options that limit tracing to file 
related activities.

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] transposing rows and columns in a CSV file

2004-11-12 Thread Gyepi SAM
On Fri, Nov 12, 2004 at 02:11:37AM -0500, Aaron Sherman wrote:
> Seriously, while mmap is ideal in C, in Perl I would just build an array
> of tell()s for each line in the file and then walk through the lines,
> storing the offset of the last delimiter that I'd seen.

I think mmap would be just as ideal in Perl and a lot less work too.
Rather than indexing and parsing a *large* file, you must mmap
and parse it. In fact, the CSV code, which was left as an exercise in you
pseudo-code, would be the only code required.

I should point out though that mmap has a 2GB limit on systems
without 64bit support. Such systems can't store files larger than
that anyhow.

> Let the kernel file buffer do your heavy lifting for you.

Exactly, if s/kernel file/mmap/

-Gyepi

--
The convenient method is insecure and the secure method is inconvenient.
--me
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Old algorithms

2004-11-11 Thread Gyepi SAM
On Thu, Nov 11, 2004 at 08:48:16PM -0500, William Ricker wrote:
> 
> > When I first read Knuth's TAOCP books, in ...
>  > I have since realized that we also have more data *and* those algorithms do
> > contain some very nice gems that are still useful. If 
> Definitely.
> 
> The bible for actually building space-limited sorting tools is Hal Lorin's 
> book /Sorting and Sort Systems/, (ISBN:0201144530) Lorin, Harold; in the A-W 
> seies, the old white-and-gold ones done by IBM researchers. 

Thanks for the recommendation, Bill. I have located and ordered a copy. I look
forward to reading it.

> If someone buys a beer, I'll explain how I came to study this tome so hard, 
> so long ago. It involved several write-only languages and Perl-67 as MJD 
> refers to PL1.

I'll buy you two beers if the story is interesting and educational, but it may
be a while before I head to Boston: I now live in Westhampton, MA.

-Gyepi

___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] Old algorithms

2004-11-11 Thread Gyepi SAM
On Wed, Nov 10, 2004 at 11:13:33PM -0500, Uri Guttman wrote:
> but here is another thought based on the old disk sort/merges and
> such. you can transpose sections of the input matrix and then join/merge
> those.

When I first read Knuth's TAOCP books, in my irreverent youth, I discounted 
some of the
old limited space algorithms on the grounds that computers are much faster and 
have more storage.
I have since realized that we also have more data *and* those algorithms do
contain some very nice gems that are still useful. If only someone could
collect them and show their usefulness in a modern context ...


-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] transposing rows and columns in a CSV file

2004-11-10 Thread Gyepi SAM
On Wed, Nov 10, 2004 at 04:38:26PM -0500, Tom Metro wrote:
> At last night meeting someone asked about ways to transpose the rows and 
> columns in a CSV file that was too large to fit into memory and 
> potentially had thousands of columns and hundreds of thousands of rows.

All of the suggested solutions are great, but ...

If a file is too large to slurp in to memory, use mmap. It's perfect for the
task and allows for the most natural solution.
There are at least two mmap modules on CPAN.

Of course, since I was not at the meeting, this may well have been discussed
and I could be a day late! ;)

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] OT - A SpamAssassin question

2004-11-04 Thread Gyepi SAM
> If you already have all of this mail rattling around, then use
> 'formail' to cause it to be re-delivered.

Technically, using formail for mail that's already "rattling" around is
just processing, not delivery. Only the MTA can deliver mail, perhaps
by using an external MDA. The distinction becomes very important if you re-inject
previously delivered messages back to the MTA: many will balk and bounce them.

Pedantry makes few friends, but the point must be made nonetheless ;)

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] OT - A SpamAssassin question

2004-11-04 Thread Gyepi SAM
On Wed, Nov 03, 2004 at 09:29:02PM -0800, Ranga Nathan wrote:
> I want to filter my mail from sendmail through SpamAssassin but redirect 
> to my cox.net address.

> I understand that SpamAssassin requires filtering via procmail.

SpamAssassin does *not* require procmail. You are using procmail here as a
Mail Delivery Agent (MDA).

> So I set 
> up /etc/.procmailrc to say:
> DROPPRIVS=yes 
> :0fw
> * < 256000 
> | /usr/bin/spamc 

Now you need to forward

:0
! [EMAIL PROTECTED]

> and then brought up the /usr/bin/spamc daemon.
> 
> What do I have to tell Sendmail to filter this 28MB of mail through 
> procmail, and then forward only non-SPAM mail to my cox.net address?

This depends on where the mail is stored.

If it is still in the sendmail mail queue (doubtful), you invoke sendmail to deliver 
it,
I stopped using sendmail years ago, so I can't help there.

If it has already been delivered, then you have to invoke procmail
manually. Note that in that instance, it may be wise to rename the mail file first.

formail -s procmail < /mail/file

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] OT: setting up site for private file exchange and discussion

2004-10-14 Thread Gyepi SAM
On Thu, Oct 14, 2004 at 05:54:27PM -0400, Greg London wrote:
> a possible option might be to set up a secure
> FTP area on my website, but I have no clue how
> to do that. Is there a simple way to tell FTP
> who can and cannot view a particular directory
> and keep track of usernames/passwords, etc?

You can do this very nicely using a chrooted sftp-server subsystem under ssh.
The result is a very secure FTP area with great user management and access control.
Best of all, it works great with Windows and Mac clients since most decent FTP clients
support SFTP now.

Assuming your server is Linux or BSD, you can even mount common or shared
directories (yep, directories) into the chrooted area so clients gain limited
access to files outside their chroot. I have used this very effectively for
stuff like read-only outgoing and write-only incoming directories.

It does require a little bit of expertise to setup though. I have written a
bunch of tools for setting up sftp jails on Linux, but never got around to packaging
and releasing it. Let me know if you're interested.

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Re: Code generation

2004-10-05 Thread Gyepi SAM
On Tue, Oct 05, 2004 at 08:48:28PM -0400, Kripa Sundar wrote:
> Thanks for the example.  This is certainly an interesting
> technique.  But I still fail to see why going from perl to sh(1)
> makes it easier to undo something.

As it turns out, I have also implemented 'atomic' operations
on groups of files solely in perl. In this case, each undoable action stores an
undo coderef in a global array after the 'do' action has completed. Then
if/when an error occurs, the error handler code iterates through the array and fires 
off
each coderef. Note that since the undo stack is stored in memory, it is lost
when the script ends so I cannot easily undo actions anymore. Furthermore,
the undo can only occur for software detectable errors, which means that the
script could run successfully and still produce bad output.  Of course one
*could* write the script to undo its own, previous, actions but that becomes
more complicated since you have have to figure out what the previous run
actually did.

The generated shell script, OTOH, contains all the state information it needs to
'do' or 'undo' *and* retains that state after execution. That may not sound
like much until you find an error and decide that you need to rollback.

> Moreover, I would guess that such undo-able scripts are
> possible only in specialised domains.

That's part of the point of program and text generation: some problems are
easier solved by the tools that apply in that domain. And yes, there are many
areas where the technique should not be used. 

> If I do a chgrp(1) or chmod(1), there is no straightforward
> to undo it, unless I save the previous file properties some
> place.

Absolutely, but only if you are modifying existing files. And if I were doing
that, remember that the perl script can stat() the file and write out that
information as part of the undo process.

>  Even worse for rm(1) and rmdir(1).

Of course, but I assume we are all adults here and understand the effects of
our actions.

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] Re: Code generation

2004-10-05 Thread Gyepi SAM
On Tue, Oct 05, 2004 at 12:41:59PM -0400, Kripa Sundar wrote:
> Dear Gyepi,
> 
> > Along a similar vein, I frequently generate sh code from perl rather than
> > simply make 'system()/qx/``' calls from perl. Though there are several benefits to
> > this approach, the most compelling, for me, is the ability to embed 'undo'
> > statements in the generated code so the shell code can, given an 'undo'
> > invocation, rollback the previous run. [...]
> 
> What is an 'undo' statement?
> What does "the previous run" mean?
> What does "rollback the previous run" mean?

Here's an example:

My last use of this technique involved a situation where I needed to read a bunch of 
text files
containing user information and add the users to /etc/passwd file, add them to various
groups, create their home directories, and add entries to a samba passwd
database, etc, and I wanted all of those operations to have atomicity:
that is succeed completely or fail completely. My perl script read the text
files and a generated a shell script like this:

  #!/bin/sh
  type=$1

  if [ "$type" eq "do" ]; then
groupadd bar
useradd foo ...
gpasswd -a foo bar
...

  elif [ "$type" eq "undo" ]; then
userdel foo
groupdel bar
...
  fi

except there were more users and more actions.

The script could then be invoked as

  ./script do

or

  ./script undo


so if a script invocation with a 'do' argument failed for whatever reason, I could 
invoke the script
with an 'undo' argument to restore the system to its previous state.

I hope that makes it clearer.

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Code generation [was Re: Cameras Re: [Boston.pm] Tech/Social Meeting w/ Randal Schwartz]

2004-10-05 Thread Gyepi SAM
On Mon, Oct 04, 2004 at 10:32:51PM -0400, Mitchell N Charity wrote:
>> Obligatory perl comment - TIMTOWTDI, and sometimes, a good way,
>> regards both clarity and speed, is having perl read a BNF and write a
>> parser in prolog, which does the parsing, and writes an AST in perl,
>> which is then eval()ed.  Really.
>> ___

> I think that about covers it.
> An example application is parsing _un_preprocessed C code - macros,
> #ifdef's, type/identifier ambiguities and all.

Along a similar vein, I frequently generate sh code from perl rather than
simply make 'system()/qx/``' calls from perl. Though there are several benefits to
this approach, the most compelling, for me, is the ability to embed 'undo'
statements in the generated code so the shell code can, given an 'undo'
invocation, rollback the previous run. In a sense, it allows me to impose
transaction semantics on batch processes. Of course, this only works if you
can be prevent or avoid external agents from modifying the system during or
between batch runs.

In general, I have found code and text generation to be a powerful technique
since one can apply abstraction, indirection. and other useful language
concepts to the task.

-Gyepi

___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Print oddity?

2004-09-22 Thread Gyepi SAM
On Wed, Sep 22, 2004 at 09:41:47PM -0400, Jeffrey Ferland wrote:
> Code:
> #two simple arrays
> @x = (1,2,4,8);
> @y = (2,4,8,16);
> #print both arrays with values joined by "," - end with a newline.
> print (join',',@x), "\n";
> print (join',',@y), "\n";
> 
> Output:
> [EMAIL PROTECTED] ~]$ perl numtest.pl
> 1,2,4,82,4,8,[EMAIL PROTECTED] ~]$

Unexpected but documented behavior.
The bottom of the first screenful of perlfunc has this to say:

   Any function in the list below may be used either with or without
   parentheses around its arguments.  (The syntax descriptions omit the
   parentheses.)  If you use the parentheses, the simple (but occasionally
   surprising) rule is this: It looks like a function, therefore it is a
   function, and precedence doesn't matter.  Otherwise it's a list opera-
   tor or unary operator, and precedence does matter.  And whitespace
   between the function and left parenthesis doesn't count--so you need to
   be careful sometimes:

   print 1+2+4;# Prints 7.
   print(1+2) + 4; # Prints 3.
   print (1+2)+4;  # Also prints 3!
   print +(1+2)+4; # Prints 7.
   print ((1+2)+4);# Prints 7.


I know it's off-topic, uncalled for, and a stylistic issue to boot,
but I have a couple of comments that I hope you'll find useful:

1. use spaces
2. use qw

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] OT: look up a host for a URL

2004-09-22 Thread Gyepi SAM
On Wed, Sep 22, 2004 at 11:57:35AM +0100, David Cantrell wrote:
> On Tue, Sep 21, 2004 at 05:56:47PM -0400, Gyepi SAM wrote:
> 
> > Indeed! The as_check script references to routeviews.org and the Merit Routing 
> > database,
> > are particularly useful for me since I have recently developed an interest in 
> > routing databases.
> 
> Just remember that the AS number returned by that script may not be
> *entirely* accurate.  It'll tell you who is announcing a particular
> netblock to routeviews.org, but not who the *real* owner is.  For that
> you need to look at the AS path.  It's on my ever-growing to-do list.

Thanks for the info.`

> Out of interest, what project do you have in mind that'll be using this
> sort of information?

I am working on a mirror database program that finds the best n mirrors for a
given client IP address. The current selection methods are geographically biased:
they prefer mirrors within the client's country, then the closest mirrors in
other countries based on, very rough, geographic distance calculations.
Most results are surprisingly accurate, but edge cases fail pretty badly since
it's working at country granularity: Vancouver, CA is closer to Seattle, US than to 
Alberta, CA
but the latter is selected first. A similar problem occurs for large countries as well.

I am thinking that some knowledge of possible routes from the client to the mirror may 
help here.
My initial approach was to write a client utility that can traceroute and ping a list 
of mirrors to find the
closest/fastest ones, but I'd like to precompute some of that information on the
server, if possible, using routing tables.

-Gyepi

___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] OT: look up a host for a URL

2004-09-21 Thread Gyepi SAM
On Tue, Sep 21, 2004 at 08:26:32PM +0100, David Cantrell wrote:
> On Tue, Sep 21, 2004 at 03:04:40PM -0400, Greg London wrote:

> > Please reply off-list.
> 
> No.  I would hope that some other people find this useful.

Indeed! The as_check script references to routeviews.org and the Merit Routing 
database,
are particularly useful for me since I have recently developed an interest in routing 
databases.

Thanks!

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Guess what is wrong with this logic

2004-09-09 Thread Gyepi SAM
On Thu, Sep 09, 2004 at 04:03:33PM -0400, Kripa Sundar wrote:

>   20: warn "blah blah\n" if (glob("~$arg") !~ m{^ (/\w+)+ /$arg $}x);

   globIn list context, returns a (possibly empty) list of filename
   expansions on the value of EXPR such as the standard Unix shell
   /bin/csh would do. In scalar context, glob iterates through
   such filename expansions, returning undef when the list is
   exhausted.

Funny, I never noticed that behaviour before.  AFAIK it's the only perl
function that behaves that way. Definitely a gotcha!

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Help using LWP to change password Q's?

2004-08-24 Thread Gyepi SAM
On Tue, Aug 24, 2004 at 12:02:26PM -0400, Dan Boger wrote:
> On Tue, Aug 24, 2004 at 12:25:43PM -0400, Gyepi SAM wrote:
> > Note that since the action tag should either be fully qualified (begin
> > with http or https) or be relative (begin with '/'). Neither is true
> > in this case, so the browser has to figure out what to do.
> 
> Aren't paths that begin with a '/' considered 'absolute'?  And relative
> is anything else?  An ACTION of "../form.cgi" is a valid relative URI,
> isn't it?

A URI that does not begin with a scheme and net location (hostname) is considered
relative. A string that begins with '/' is a relative URI but an absolute path.

I should have been clearer and said fully qualified *URL* or absolute *path*.

The point of the original statement was that sing a relative path as the
target of an ACTION attribute is technically correct, but bad practice.

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Help using LWP to change password Q's?

2004-08-24 Thread Gyepi SAM
On Tue, Aug 24, 2004 at 10:42:32AM -0400, Bob Mariotti wrote:
> Q: How does the "submit" button interrelate with the "next" URL?
> 
> Example:
> 
> Initial https connect to specified page : 
> https://xxx.yyy.com/ssp/jsp/blah.jsp

The submit button causes your browser to submit the contents of the form
using the specified method (post or get). to the specified action URL.
Since the action URL in this case is not qualified, a "smart" browser will
prepend the base URL (in this case https://xxx.yyy.com/ssp/jsp)
to the value of the action attribute and send the response, in this case, to
https://xxx.yyy.com/ssp/jsp/ABC123. Note that since
the action tag should either be fully qualified (begin with http or https) or
be relative (begin with '/'). Neither is true in this case, so the browser has
to figure out what to do. 

> Assuming the response is true... must the programmer alter the URL for 
> the POST operation at all?  Or will LWP and/or HTTP take care of 
> manipulating the URL in combination with the ACTION value?

Since you're writing the "browser", you may need to append the value of the
action attribute to the base URL and post the response there.

-Gyepi

___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Wiki

2004-08-06 Thread Gyepi SAM
On Fri, Aug 06, 2004 at 10:43:20AM -0400, Uri Guttman wrote:
>   JS> why not just run it up the flagpole and see who salutes!
> 
> i won't touch that with a 10 foot flagpole!

A 3 foot flagczech might be easier to manage, I'd say.

-Gyepi




___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] OT - Keyboards

2004-08-04 Thread Gyepi SAM
On Wed, Aug 04, 2004 at 08:49:52PM -0400, Mike Burns wrote:
> If I'm not mistaken, Linux has an option where the SysReq key becomes a 
> special key that works when the kernel freezes. I seem to remember Linux 
> developers using it.

You are not mistaken. This is a compile time kernel option which, when
enabled, allows you to do all sorts of funky stuff with your machine if it
hangs. The sysreq key is used in combination with the ALT key and other,
mappable, keys. I have not used the feature in a long time but I still compile
it into every kernel I build. You never know when you'll need it!

> (I also seem to remember someone getting flamed for 
> suggesting that FreeBSD use it.)

Shrug. Dunno.

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Assignment to Convoluted Data Structure

2004-07-16 Thread Gyepi SAM
On Fri, Jul 16, 2004 at 08:26:40AM -0400, William Goedicke wrote:
> Dear Y'all - 
> 
> I've been struggling with the following problem.  I've got a data
> structure that Dumper displays as:
> 
> $VAR1 = {
> 'TARGETTABLE' => {
> 'SOURCETABLE' => [
> {
>   'ID' => 'S1',
>   'NAME' => 'PS_DIVERSITY',
>   'SOURCEFIELD' => [],
>   'DBID' => 'SDB1'
> }
>  ],
> 'ID' => 'T1',
> 'NAME' => 'SDM_PERSON_DIM',
> 'DBID' => 'TDB1'
>  }
>   };
> 
> I need to push the following onto the SOURCEFIELD array:
> 
>{
> 'NAME'=>$results[0],
> 'ID'=>$id, 
> 'TYPE'=>$results[1],
> 'TARGETFIELD'=>$id+10
>};

   push @{$VAR1->{TARGETTABLE}->{SOURCETABLE}->[0]->{SOURCEFIELD}},
   {
 'NAME'=>$results[0],
 'ID'=>$id, 
 'TYPE'=>$results[1],
 'TARGETFIELD'=>$id+10
};

-Gyepi

--
I am interested in perl/C/unix/DBA/Sys Admin contract work.
Check out my resume http://www.praxis-sw.com/resume.html.
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Is there a module to access memory usage?

2004-07-14 Thread Gyepi SAM
On Wed, Jul 14, 2004 at 02:22:31PM -0400, Tal Cohen wrote:
> Yeah, I thought of that. I was hoping for a platform independent mechanism.
> If not, then I can use this type of methodology, but how do I account for
> Windows based machines?

  http://search.cpan.org/search?query=Win32+memory&mode=all
  returns, among others, a link to 'Win32::SystemInfo'.

  Don't forget to account for swap space, whatever you do!

-Gyepi

-- 
Knowledge is power.
--Francis Bacon  
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] reading in HTML with SSI and processing in perl

2004-07-14 Thread Gyepi SAM
On Wed, Jul 14, 2004 at 10:13:13AM -0500, Alex Brelsfoard wrote:
> I hate to bug you all with a perl question like this seeing as I am new to
> the group.  But I'm getting kinda stuck on this one.  I am simply trying
> to read in an external html file (to be used as the header of a web page)
> and then print it out.  That sounds nice and easy.  However, the header
> file contains SSI, and not just an include, and sets and echos.  I've been
> trying to get CGI::SSI to work, but, near as I can tell, it's not
> understanding the set commands or the if/else commands in SSI.  Do you
> guys have any suggestions on this one?  I KNOW there has to be a way

According to the CGI::SSI docs it does understand the echo and if/else control
structures so something must be wrong. More information and sample data is
probably in order.

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Embedding Perl

2004-07-12 Thread Gyepi SAM
On Sun, Jul 11, 2004 at 10:47:26PM -0400, Federico Lucifredi wrote:
> I have been asked to provide scripting capability into a Qt application
> (essentially, the reverse of what I have shown you in my talk a couple of
> years ago), and was thinking of embedding Perl into their program as a
> solution. I have two questions in the matter, as I have never tried this
> particular magic Perl spell:

On second thought, SWIG is not the answer to this problem. I misunderstood the
problem (or the embedding direction).

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Embedding Perl

2004-07-12 Thread Gyepi SAM
On Sun, Jul 11, 2004 at 10:47:26PM -0400, Federico Lucifredi wrote:
> What kind of access will the scripts have to the proper C++ variables?
> Can these be objects or have to be static ? Or is it simply madness to poke
> at data that way (my take) and the best approach is to pass a data block to
> a Perl function from C++, then retrieve the results from that same memory
> area (or another one, but still allocated by C++).

You'd have to convert any variables from C++ representations to Perl. This
could be messy. Have you tried SWIG?
 
> The person badgering me with this problem seems to think it is possible
> to poke at the memory space of an executable from another one (the
> standalone perl interpreter) and live happily everafter. Now, I know Perl is
> full of wonderous surprises, but unless it bends even standard Unix Kernel
> memory protection, it seems to me the best way to go is embedding.

Poking at the memory space of an executable is "not a good idea" (tm).

> Should I check out other spell books other than perlembed? As far as I know,
> that's the only way to go, but perhaps there are *other* ways to embed Perl

SWIG.

> (No Dan, don't get started on Parrot jst yet ;-)

-Gyepi

-- 
Notice the difference between what happens when a man says to himself, 
I have failed three times, and what happens when he says, I am a failure.
--S. I. Hayakawa  
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] flock() on Solaris

2004-06-22 Thread Gyepi SAM
On Mon, Jun 21, 2004 at 10:10:02PM -0400, Ian Langworth wrote:
> --
> use Test::More 'no_plan';
> use Fcntl ':flock';
> 
> open ONE, ">foo" or die $!;
> flock ONE, LOCK_EX or die "Can't lock";
> print ONE "line 1\n";
> 
> fork and do {

The test on this line is incorrect. The parent continues to run inside this block.
At the very least you should use 'fork or do { ...'


-Gyepi

___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] DBD::mysql 'make test' failure

2004-06-18 Thread Gyepi SAM
On Fri, Jun 18, 2004 at 03:32:36PM -0400, Timothy Kohl wrote:
> 
> Hi,
> 
> I'm trying to install DBD::mysql (version 2.9003) and
> am getting failures across the board when doing 'make test'
> 
> The Perl version is 5.84 with DBI-1.42 already installed.
> 
> The common theme in all the failures has to do with this:
> 
> /export/home1/tkohl/DBD-mysql-2.1028/blib/arch/auto/DBD/mysql/mysql.so: symbol
 ^

It appears that an older version of DBD-mysql is being picked up ...

> P.S. On a separate note, I recently built Tk-804.27 and all of a sudden
> I had to replace all instances of (for example)

Sorry no Tk for me.

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] OT - Any experience with ODBC to MySQL?

2004-06-04 Thread Gyepi SAM
On Fri, Jun 04, 2004 at 05:47:11PM -0700, Ranga Nathan wrote:
> I am trying to set up ODBC access from Access 2000 to MySQL running on 
> Linux. Whenever I test the connection in the set-up dialogue, I get "MySQL 
> ODBC [3.5..] Access Denied for [EMAIL PROTECTED] 
> Password Required (yes)"
> The message is not verbatim but essentially the same.
> 
> If anyone can throw some light on it, I would appreciate it.

Since you didn't mention it, I would guess that you did not 'FLUSH PRIVILEGES'
after changing the grant tables. If you did, then you may find this page
helpful: http://dev.mysql.com/doc/mysql/en/Access_denied.html.

FWIW, I have setup this ODBC combination several times and it works fine.

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Looking for a web-based ftp client

2004-05-12 Thread Gyepi SAM
On Wed, May 12, 2004 at 03:42:09PM -0400, John Saylor wrote:
> most web browsers 'speak' FTP [like they do HTML].

s/HTML/HTTP/

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] Testing MIME boundary integrity

2004-05-06 Thread Gyepi SAM

--===19207982046402039==
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

This message specifies and uses a MIME boundary of 
"===19207982046402039==".
If the boundary in the body has a different value, then some piece of
broken software has mishandled the message. 

-Gyepi

___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Compression without temp file

2004-02-12 Thread Gyepi SAM
On Thu, Feb 12, 2004 at 10:18:52PM -0500, Sean Quinlan wrote:
> I didn't make a script, I just pasted your post into a command line.

Yep! That's the problem. For some reason, running the example from the command
line produces no output while the same program in a script works. I straced
both methods but nothing jumped out at me. At first glance, I'd say there's a
bug somewhere. I'll look closer later.

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Compression without temp file

2004-02-12 Thread Gyepi SAM
On Thu, Feb 12, 2004 at 08:51:43PM -0500, Sean Quinlan wrote:
> On Thu, 2004-02-12 at 20:18, Gyepi SAM wrote:
> Thanks Gyepi! Unfortunately, while this did not throw any errors, it
> also did not produce any output?

I just installed PerlIO::gzip so I could test the example and it works for me,
so it must be you or your system ;) Was your perl built with perlio?

  perl -V|grep io

should  produce at this something like this:
  
  useperlio=define d_sfio=undef

btw, if you save the example to a file and pipe the script
output to 'gunzip -c', you get back the original string,
which serves as a nice test of the whole process.

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Compression without temp file

2004-02-12 Thread Gyepi SAM
> On Thu, 2004-02-12 at 19:37, Chris Devers wrote:
> > I assume you tried CPAN?=20
> > First hit is PerlIO::gzip, which looks promising...
> 
> Yes, I skimmed over that one. However I'm trying to find a way to do it
> without using files, which PerlIO::gzip seems to be doing.

Yes, it does use files, but newish perls support the concept of in-memory
files. So the PerlIO::gzip example becomes:

  use PerlIO::gzip;
  my $string;
  open FOO, ">:gzip", \$string or die $!;
  print FOO 'blah blah blah';
  close FOO;
  print $string; #careful, this may mess up your terminal!


-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Bug/Limitation in DBD::mysql?

2004-01-15 Thread Gyepi SAM
On Thu, Jan 15, 2004 at 09:59:38AM -0500, Chris Braiotta wrote:
> Hi, all. I've discovered some odd behavior in a script I've written 
> that uses DBD::mysql, and I think it's related to the large number of 

> 2) Simply adding a "LIMIT 500" to the end of the SQL query, or using a 
> more restrictive set of dates than the script is meant to use, 
> eliminates the error.

Perhaps the shell or process running the script is running into a resource
limit. What does ulimit tell you?  I am assuming, obviously, that you are
running a very recent DBD::mysql.

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] GUI work ...

2003-12-17 Thread Gyepi SAM
On Wed, Dec 17, 2003 at 05:10:42PM -0500, Sherm Pendley wrote:
> On Dec 16, 2003, at 2:52 PM, runester wrote:
> >I'd really like to leverage my knowledge of PERL
> 
> You're in luck! Try the Inline::PERL module. It will let you embed PERL 
> code inside of Perl.

LOL!  All these years of programming Perl and I never knew this module
existed. I could kick myself for all the time I wasted with Perl instead of
just using Inline::PERL. Drats!

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] RSA public key authentication in Net::SSH::Perl

2003-10-31 Thread Gyepi SAM
On Fri, Oct 31, 2003 at 02:36:01PM -0500, Chris Braiotta wrote:
> Hi all. Long time listener, first-time caller.
> 
> I'm in the process of converting a script from using Net::SSH to 
> Net::SSH::Perl. The module works fine, except for the fact that I can't 
> get it notice that I have RSA public key-based authentication running. 
> When I try to log into my machine via the scrupt, it just returns 
> "Permission denied at ./test.pl line 10".
> 
> I know that the public key stuff is working: I can do it on the command 
> line, and I can do it through Net::SSH. I imagine I need to set the 
> %params or options properly, but the documentation for this aspect is 
> sorely lacking. I've tried looking through
> usenet, but the pickings are slim. I've played around with different 
> values for the 'identity_files' option, as below.
> Here's the code...
> my $ssh = Net::SSH::Perl->new($host, debug => 1, identity_files => > 
> ["~/.ssh2/hostkeys/key_22_domains.pub"]);

ssh clients use private keys, while the remote machine uses the publics
key, it looks like you're specifying a public key for your identity
file.

If nothing else works, run your script under strace and look through the
output. Perhaps in addition, run the command line ssh client under
strace and make sure it is using the same key files as your script.

-Gyepi

-- 
Advertising may be described as the science of arresting the human 
intelligence long enough to get money from it. -- Stephen Leacock  
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] DBI question

2003-06-18 Thread Gyepi SAM
On Wed, Jun 18, 2003 at 09:18:42AM -0400, Joel Gwynn wrote:
>  $dbh =
> DBI->connect("dbi:$$config{dbi}:PROVIDER=$$config{provider};SERVER=$$con
> fig{dbserver};UID=$$config{uid};PWD=$$config{password};DATABASE=$$config
> {database}") || return "Couldn't connect.";
> 
> The problem is not so much that I can't connect, the problem is that if
> I can't, I don't want to return the db credentials to the browser.  How
> can I turn this off?

1. The old fashioned and reliable way is to wrap the connect(...) call
   inside an eval and test for errors outside.

eval {
DBI->connect(...);
};

if ($@){
.
}

2. DBI v1.32 also has the HandleError method which may do what you want.
   I have never used it, had never heard of it until 5 minutes ago, and
   don't know how long it's been there. But it *is* in the docs, so
   there you have it.

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Network pipe !?

2003-03-09 Thread Gyepi SAM
On Sun, Mar 09, 2003 at 12:15:19PM +0700, Komtanoo Pinpimai wrote:
> Hello,
> 
>I've build a system based on unix name pipes; the problem arise when 
> I try to extend the system to multiple servers sharing files with NFS.
> 
>As of my understanding, NFS doesn't support name pipe. Is there any 
> ready-made network object, or service that can perform the name pipe 
> task across network ?

The first solution that came to mind was DJ Bernstein's ucspi interface, of which
there are implementations for tcp, udp, unix domain sockets, and ipc, but apparently,
not for FIFO's.
In any case, writing an implementation for FIFOs should not be too hard.

I can certainly imagine a way to transform a FIFO based service to a remote machine.

Of course, I'd try to get rid of the FIFO's and bury the network access in the 
interface so
it could work locally...

HTH

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Re: "Slightly" off topic from Hartford PM Group

2003-02-27 Thread Gyepi SAM
On Thu, Feb 27, 2003 at 03:45:51PM -0500, [EMAIL PROTECTED] wrote:
> > If you have to lie to your software to make it do the right thing, I'd
> > say you're using the wrong software. But one has work somehow...

> Your observation is correct.  However, when one provides/supports web
> software that MUST serve information to the masses, the masses are most
> likely using a micro$oft product.  Therefore, whether its correct or not,
> whether we like it or not, we've GOT to make it work.  I swear, we spend
> considerably more time breaking things to work with MS than we do
> developing it in the first place.

I agree with most of what you're saying and never implied that the masses
should use anything else, though many do. I serve hundreds of thousands of
those masses who use Microsoft clients, but I don't need or want to use
Microsoft products to do the serving. The masses chose their software,
and I choose mine. We are, after all, talking about the web. ;)

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] open a gz file

2003-02-27 Thread Gyepi SAM
On Thu, Feb 27, 2003 at 01:43:13PM -0500, Carlton Lo wrote:
>   I'm new to perl, I'm trying to write a pl script that would open a gzipped txt 
> file. Is there any functions where I can call for this. I've tried the followings:
> 
> method #1 open(IN, "gunzip -c data.gz") || die "cannot open input data file";

open(IN, "gunzip -c data.gz|") || die "cannot open input data file. $!";



> method #2 pass the filename as ARGV and execute the script as $perl test.pl 
> 'gunzip -c data.gz'

cat > test.pl
open(F, "$ARGV[0]|") or die "Cannot open $ARGV[0]. $!\n";
^D

Note the pipe (|) at the end of the second argument to open.

perldoc -f open

Either method will suffice, though #2 is rather strange.

-Gyepi

-- 
Science is organized knowledge. Wisdom is organized life.
--Immanuel Kant  
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Re: "Slightly" off topic from Hartford PM Group

2003-02-27 Thread Gyepi SAM
On Thu, Feb 27, 2003 at 01:38:23PM -0500, Richard Morse wrote:
> 
> On Thursday, February 27, 2003, at 01:10  PM, Gyepi SAM wrote:
> 
> >That url won't do what you want. This one should:
> >
> > http://.../my_script.cgi/filename.ext?null=null

> I think that I tried this a while ago, but it didn't work.  The reason 
> was that IIS, for some reason unbeknownst to me, refused to realize 
> that my_script.cgi in the URL was a script

Hmm. That seems like a pretty standard thing to be able to do.
In any case, I don't use Microsoft products and have never used IIS so I can't help 
with that.

If you have to lie to your software to make it do the right thing, I'd say you're 
using the wrong software.
But one has work somehow...

-Gyepi

-- 
All the world's a stage, and all the men and women merely players.
They have their exits and their entrances, and one man in his time plays many parts, 
his acts being seven ages.
--Shakespeare, "As You Like It"  
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Re: "Slightly" off topic from Hartford PM Group

2003-02-27 Thread Gyepi SAM
On Thu, Feb 27, 2003 at 11:20:56AM -0500, Richard Morse wrote:
> 
> On Thursday, February 27, 2003, at 10:55  AM, Gyepi SAM wrote:
> 
> >Appending the filename to the url works with all browsers, AFAIK.
> >
> 
> Not any more.  At least, on all of my Win2K boxes, with 
> IE6-what-ever-the-latest-version-is, sending a script to the url 
> "http://.../my_script.cgi?null=null/filename.ext"; will prompt them to 
> save the file "my_script.cgi".  The null=null is required by IIS (not 
> my choice of web server), otherwise it actually tries to read it as a 
> static path.

That url won't do what you want. This one should:

 http://.../my_script.cgi/filename.ext?null=null

1. I only keep the null=null parameter because you claim it is necessary.
2. I assume that your webserver can separate path info from the URI.

-Gyepi

___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Re: "Slightly" off topic from Hartford PM Group

2003-02-27 Thread Gyepi SAM
On Thu, Feb 27, 2003 at 10:16:50AM -0500, Richard Morse wrote:
> 
> On Thursday, February 27, 2003, at 08:03  AM, Bob Mariotti wrote:
> 
> >1) no dialog box appears and the file is automatically downloaded and 
> >stored in some obscure directory somewhere where the user cannot find 
> >it; ow 2) a dialog box will appear but the directory setting is 
> >obscure and the filename is the name of the perl cgi program.

> For issue 2, I've been having problems with this recently as well.  It 
> used to be that it was sufficient to make sure that the URL ended with 
> the filename -- I would often write scripts that included a pointless 
> redirect to the exact same place with '/filename.ext' appended to the 
> end of the query string.  It may still work for some browsers.
> 
> But if you do find a solution for setting the filename, I'd like to 
> know...

I used the 'Content-Disposition' header [1] for a long time, but eventually gave
up and simply appended the filename to the url because some versions of IE ignore the
the headers altogether. I think it was a workaround to fix the IE content-disposition 
insecurity
problem, but I don't really know why.

Appending the filename to the url works with all browsers, AFAIK.

I never tried using both, but that may also work.

[1] ftp://ftp.rfc-editor.org/in-notes/rfc1806.txt

-Gyepi
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm


  1   2   >