Re: Need to write a pop3 attachment fetch program

2004-07-14 Thread Morbus Iff
What I need is to write an application that:
- Access a pop3 remote account
- Iterate through the list of messages on the server
- Download the attachments and save them localy on the machine
- delete all downloaded messages

See http://disobey.com/detergent/code/leecharoo/leechpop.pl
The code was further explained in my book 'Spidering Hacks'.

-- 
Morbus Iff ( and think about the bad things that I didn't do )
Technical: http://www.oreillynet.com/pub/au/779
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




[OT] Re: AW: book suggestion for atypical beginner

2004-04-08 Thread Morbus Iff
In fact, let me take this one step further.  I've been told recently
(although I might be misremembering) that O'Reilly will publish NO
MORE CDs because of rampant piracy.

Last I heard, Safari was going to make it *easier* for you to read
books offline, which sounds like they're just removing the CD, not
the digital rendering, from the equation. I personally see more Safari
rips than CD rips nowadays.

From O'Reilly's E-Book Strategy:

  http://www.oreilly.com/pub/a/oreilly/ask_tim/2003/ebooks_1103.html

  This is perfect timing for phase two of our e-book strategy.
  Having built the Safari database, we can now offer additional
  services beyond the web browser interface. These include a custom
  textbook project (in which professors can mix and match sections
  from Safari books with their own classroom materials to build
  their own class-specific textbooks), A DOWNLOADABLE OPTION
  for Safari subscribers, and a series of shorter documents sold by
  the piece, à la GnomeTomes.

Emphasis mine. What format these downloadables take, I'm not
sure, because earlier, Tim remarks about PDFs in general:

  It's my belief that simply putting a book into some kind of PDF
  or other representation of the printed book is like pointing a camera
  at a stage play and calling it a movie.

--
Morbus Iff ( softcore vulcan pr0n rulez )
Technical: http://www.oreillynet.com/pub/au/779
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Questions about game design in perl

2004-04-07 Thread Morbus Iff
 I'd love to see what you come up with.
 Games and Perl is close to my heart.

WTF does this have to do with the confusion
between NULL and Perl's udef [New To
Perl], the thread on which you replied?
I suspect a good amount of people have no clue
the purpose of a Message-ID/References, much less how
replying to the wrong one (ie. I don't feel like typing
the To: address myself) and then rewriting the subject
line can cause havoc with archivers and threaders.
--
Morbus Iff ( i put the demon back in codemonkey )
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/disobeycom
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



[OT] Re: Questions about game design in perl

2004-04-07 Thread Morbus Iff
Give us another chance...

For what it's worth, giving up on the list this early in the
game doesn't impress me very much. If someone wants to be that
close-minded [1] without further investigation [2], then good
riddance - they're not gonna make good programmers, so why waste
our time [3] trying to dissect their lack of language and grammar?
I, personally, have never killfiled or filtered anyone - I
have yet to meet someone that doesn't entertain me with
mirth or intelligence at least once in their life. I'm
always ready for a second helping.
[1] abrupt, assumptionary, out to get me, etc.
[2] mailing list archives, assuming only you and I speak, etc.
[3] Use MySQL! five minutes later I installed it. Now what?
--
Morbus Iff ( i put the demon back in codemonkey )
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/disobeycom
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Questions about game design in perl

2004-04-06 Thread Morbus Iff
I am trying to build a game in perl. I have questions.
This is a story book game... here is the story, make a choice
next page..here is the story, make a choice
I'd love to see what you come up with.
Games and Perl is close to my heart.
1-Do I set up the login file (password name and your game details)
in one big file, or in many files, one file per player?
Depends - if you expect the game to get any substantial amount
of hits, you'd really want it in a MySQL database. Likewise, if
you plan on getting zillions of users, managing them in a single
file is going to get rather slow and cumbersome rather quickly.
Likewise, one little bug is gonna wipe out your entire userbase.
--
Morbus Iff ( i put the demon back in codemonkey )
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/disobeycom
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



HOWTO: File Renaming and Directory Recursion

2004-04-01 Thread Morbus Iff

 foreach DIRECTORY (DIRECTORIES) {
 get list of ENTRIES in DIRECTORY

 foreach ENTRY (ENTRIES) {
 if ENTRY is a DIRECTORY, add to DIRECTORIES
 }

 finished DIRECTORY; remove it from DIRECTORIES
 }

And you know what? This approach *can* work, but you're reinventing
the wheel: this is such a common problem (how do I recurse through
directories) that it has been mentioned in a zillion FAQs. But no
one reads FAQs, and no one reads HOWTO, so we're gonna be blowing
gas for the rest of our lives.

The proper solution to recursing directories is File::Find. It's
included with every distribution of Perl, is quick and easy to use,
and allows code that looks nearly exactly like our first example.
it's also far more platform-agnostic that you'd ever expect your
code need to be. The revised script:

 #!/usr/bin/perl
 use warnings;
 use strict;

 use File::Find;

 # we no longer have to read directories
 # ourselves: File::Find takes care of that
 # for us - we just define a subroutine for
 # what we want to do with what's been found.
 #
 find(\underscores, .);

 # and here is that subroutine. it's nearly exactly
 # the same as our previous code, only this time, we
 # move into the directory that contains a file to
 # be renamed. this is actually a quick hack because
 # I knew this wouldn't be production-code: a more proper
 # solution would be to stay where we are in the directory
 # structure, and give full paths to our rename(). this
 # would require the help of another module, File::Spec.
 # find out more with perldoc File::Spec. it's handy.
 #
 sub underscores {
next if -d $_;
next if /^\./;
next unless /_/;

my $new_name = $_;
$new_name=~ s/_/ /g;
chdir($File::Find::dir);
rename($_, $new_name) or die $!;
 }

One of the best traits you can learn as a Perl programmer is
mastering the use of the core modules, as well as how to find what
you need on CPAN: a good metric ton of your code will look far cleaner,
far easier to understand, and far more maintainable (and FAR more
documented too!). Likewise, you'll get far more done, and with
less doh! bugs. Try to understand that a good number of the problems
you'll face in programming have been solved for you: it's just a
matter of taking the time to find the answer instead of coding your
own solution that really isn't.

Yep.

-- 
Morbus Iff ( shower your women, i'm coming )
Technical: http://www.oreillynet.com/pub/au/779
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: HOWTO: File Renaming and Directory Recursion

2004-04-01 Thread Morbus Iff
  while (@files) {

Are you sure that's not:

   for (@files) {

Yup, for is right. An error in my memory recall.

-- 
Morbus Iff ( evil is my sour flavor )
Technical: http://www.oreillynet.com/pub/au/779
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Pause/Hold in Perl

2004-03-30 Thread Morbus Iff
Is there a way in Perl to have a script wait 30 seconds before it
continues processing?  Like or a pause or hold?

sleep().

-- 
Morbus Iff ( black as the devil and sweet as a stolen kiss )
Technical: http://www.oreillynet.com/pub/au/779
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: File content question

2004-03-29 Thread Morbus Iff
Where are you getting lost? I don't recall your previous
messages, so I'm not sure what like before means...
Anyway, here's an untested rewrite. Untested. Mmhm.
The biggest problem is making sure to reset %datastore
when you come across another bunch of text lines that
don't match your variable names. You didn't provide enough
data for that instance, so I've considered it irrelevant.
 #!/usr/bin/perl
 use warnings;
 use strict;
 my $infile = /tmp/test1.log;
 my $outfile = /tmp/mysqltats.out;
 my %datastore; # where we keep variables.
 open (INFILE, $infile)   || die cannot open $infile: $!\n;
 open (OUTFILE, $outfile) || die cannot open $outfile: $!\n;
 while (INFILE) {
   chomp;
   next if /^\*+/; # changed from your example. you were
   # checking if there was *+ anywhere in
   # a string, which could potentially match
   # the value of a variable. ^\+ is stronger.
   # etc., etc. this sorta syntax is more
   # readable than if/else statements. the same
   # can be done with next unless [condition].
   next if /^anotherexample/;
   # key: beginning of line up to first whitespace.
   # value: everything else after the first whitespace.
   my ($key, $value) = /^(.*)\s(.*)$/;
   # you may want to throw in more tests here to make
   # sure that $key is what you expect: ie., letters and
   # underscores only, less than 15 characters, lowercase,
   # etc., etc. pro-actively checking for sanity helps.
   #
   # next if $key !~ /[\w_-]*/;
   # next if length($key)  15;
   # $key = lc($key);
   # store the key/value into a hash, unless this
   # key has already been seen (ie., the first instance
   # takes precedent. remove the unless ... if you'd
   # like the final value of a duplicated key instead.
   $datastore{$key} = $value unless $datastore($key);
 }
 # print out a specific key value.
 print The value of 'Bob' is $key{Bob}\n;
 # or loop through 'em all.
 foreach (keys %datastore) {
print Variable: $_ // Value: $datastore{$_}\n;
 }
 close (OUTFILE); close (INFILE);

--
Morbus Iff ( i put the demon back in codemonkey )
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/disobeycom
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: HOW-TO of the Month Club (end Of MARCH Edition)

2004-03-27 Thread Morbus Iff
This edition I will show you how to declare
variables WITHOUT using *my* $var everywhere...

I'm not sure this is the sorta stuff I'd be teaching beginners.
There are far better ways to shape impressionable minds, and
this syntax just lends credence to the Perl is ugly theory
(more adequately stated as bad programmers make Perl ugly).

-- 
Morbus Iff ( rotinom ruoy edisni deppart mi pleH )
Technical: http://www.oreillynet.com/pub/au/779
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: OO Programming

2004-03-03 Thread Morbus Iff
WilliamGunther IMHO, Object Oriented Perl is
the best book you can get on the subject.

RandalLSchwartz And for a tutorial approach ala Learning
Perl, check out Learning Perl Objects References and Modules.
I'll second both of those suggestions. OOP does have an early
chapter on references, but the ORA book is more in-depth.
--
Morbus Iff ( i put the demon back in codemonkey )
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/disobeycom
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: ENV variables and custom 404 error page

2004-03-01 Thread Morbus Iff
I have a custom 404 error page that uses that shows the URL of the page that
couldn't be found using var=REDIRECT_URL. Is there a way to take this
variable, such as /folder/wrong.html, strip out everything except
folder, match folder and redirect (launch the web page) to
folder/index.html.
Depends. Three different ways to do it:

 * if you just want to redirect the user to the right place (without
   showing an interim page), then don't use Perl at all - look into
   your server (presumably Apache) capability. The following, in
   your httpd.conf or .htaccess file, will do the same thing, only
   without the additional Perl/CGI overhead:
  Redirect /folder/wrong.html /folder/index.html

 * if you want to show an error page first, use a meta-refresh
   tag to automatically send the user to the right place. The
   following example would tell the user's browser to go the
   the rightplace.com after ten seconds. For accessibility,
   be sure to make this a clickable link somewhere on the page.
META HTTP-EQUIV=Refresh CONTENT=10; URL=http://rightplace.com/;

 * if you just want to redirect the user to the right page,
   only with your Perl/CGI script, do the following INSTEAD
   of a Content-type header:
 # instead of this:
 print Content-type: text/html\n\n;
 print Oopsies! Wrong page!;
 # do this. make sure that this line is the
 # ONLY thing you print out to the browser.
 print Location: http://rightplace.com/\n\n;;
As for splitting up a URL into its
component parts, look into the URI
(pseudo code, not tested):
  my $url = YOUR URL HERE;
  my $urih = URI-new;
  my $path = $urih-path($url);
  my @parts = $urih-path_segments($path);
  my $first_path = $parts[0];


--
Morbus Iff ( i put the demon back in codemonkey )
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/disobeycom
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Perl or Bash error?

2004-02-25 Thread Morbus Iff
print Before;
sleep (5);
print After\n;
You're buffering, I suspect. Add $|=1 to the top of your
script, and read: http://perl.plover.com/FAQs/Buffering.html
--
Morbus Iff ( i put the demon back in codemonkey )
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/disobeycom
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: cool project ideas

2004-02-24 Thread Morbus Iff
I'm getting tired of working on a text adventure in perl, and I was
wondering if anyone had some interesting projects they could suggest I
Why did you get tired of the text adventure?

--
Morbus Iff ( i put the demon back in codemonkey )
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/disobeycom
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: cool project ideas

2004-02-24 Thread Morbus Iff
perl I wanted to know how to write spiders (but I'm too cheap to buy the
O'Reilly book Spidering hacks, and the library doesn't have it) allthough
Hey, that's my book g.

--
Morbus Iff ( i put the demon back in codemonkey )
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/disobeycom
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



File::Spec::no_upwards(), Absolutes, Alternatives?

2004-02-21 Thread Morbus Iff

Evening. File::Spec::no_upwards is supposed to:

  Given a list of file names, strip out those that refer to a parent
  directory. (Does not strip symlinks, only '.', '..', and equivalents.)

but, I can't seem to get it to work:

print 1: $file_path\n;
next unless File::Spec-no_upwards($file_path);
print 2: $file_path\n;

gives me:

1: /Users/morbus/templates/default/en/../variants.html
2: /Users/morbus/templates/default/en/../variants.html

Looking at no_upwards, it seems to want relative file names only,
not absolute (because of ^), but this is unclear in the documentation:

  sub no_upwards {
  my $self = shift;
  return grep(!/^\.{1,2}\Z(?!\n)/s, @_);
  }

What's the proper answer? Should I rip out the regexp and use
it myself without the ^? I couldn't get that to work either:

print 1: $file_path\n;
next if $file_path =~ /\.{1,2}\Z(?!\n)/s;

The only way I could was to remove, or unknowingly
break, the NULL injection, which I don't want to do:

# these both work. don't know what breaks in the
# first one, and the second one isn't strong enough.
next if $file_path =~ /\.{1,2}\Z?(?!\n)/s;
next if $file_path =~ /\.{1,2}/s;

Neither of the above work in a cross-platform sort of way, which is
why I was hoping to use something in File::Spec. But, I'm always
receiving absolute paths, not relative, so I don't believe no_upwards
will work for me. What are other people doing to prevent directory
traversals in an absolute-path, cross-platform sorta way?

-- 
Morbus Iff ( i desire penance for your sins )
Technical: http://www.oreillynet.com/pub/au/779
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: File::Spec::no_upwards(), Absolutes, Alternatives?

2004-02-21 Thread Morbus Iff
At 1:18 PM -0500 2/21/04, Morbus Iff wrote:
Neither of the above work in a cross-platform sort of way, which is
why I was hoping to use something in File::Spec. But, I'm always
receiving absolute paths, not relative, so I don't believe no_upwards
will work for me. What are other people doing to prevent directory
traversals in an absolute-path, cross-platform sorta way?

As is typical, minutes later, you find the answer:

Here's the proper code, rather. Forgot about files:

  # check for naughty users doing not-so-proper things.
  my ($v, $directories, $f) = File::Spec-splitpath($file_path);
  my @path_parts = File::Spec-splitdir($directories);
  push(@path_parts, $f); # check the file for naughties too.
  return $self-error(Hi! You've attempted directory traversal. Naughty!)
  if scalar File::Spec-no_upwards(@path_parts) != scalar @path_parts;

-- 
Morbus Iff ( if i could change the future, i'd change the past instead )
Technical: http://www.oreillynet.com/pub/au/779
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: File::Spec::no_upwards(), Absolutes, Alternatives?

2004-02-21 Thread Morbus Iff
Neither of the above work in a cross-platform sort of way, which is
why I was hoping to use something in File::Spec. But, I'm always
receiving absolute paths, not relative, so I don't believe no_upwards
will work for me. What are other people doing to prevent directory
traversals in an absolute-path, cross-platform sorta way?

As is typical, minutes later, you find the answer:

  # check for naughty users doing not-so-proper things.
  my ($v, $directories, $f) = File::Spec-splitpath($file_path);
  my @directories = File::Spec-splitdir($directories);
  return $self-error(Hi! You've attempted directory traversal. Naughty!)
 if scalar File::Spec-no_upwards(@directories) != scalar @directories;

-- 
Morbus Iff ( if i could change the future, i'd change the past instead )
Technical: http://www.oreillynet.com/pub/au/779
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: stop

2004-01-07 Thread Morbus Iff
For the sake of:

 * giving the guy a break.
 * expecting some intellect.
 * realizing he's probably
   not reading your responses.
Notice he didn't say whether he requested to the list, or to the
proper email unsubscribe address: just that he had requested multiple
times to be removed. The flip side of the coin is that there may
very well be a problem with the unsubscription scripts.
Yes, this is a far-flung possibility, but besides courtesy in
the face of idiocy, one of the things ANY beginner to ANY thing
should know is to think things through from ALL angles: just
because the answer seems obvious, doesn't mean it is.


--
Morbus Iff ( i put the demon back in codemonkey )
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/disobeycom
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



RE: Pure Perl df

2003-12-30 Thread Morbus Iff
 I browsed the CPAN a bit, but wasn't too happy with the
 aside from the fact that any module installs would pretty much defeat
 the purpose here.

Why is that? That is the point of modules.
Note that if the module is pure perl without a lot of dependencies, you can
ship it with your final tarbull - that's the approach I use with AmphetaDesk
(http://www.disobey.com/amphetadesk/), where I ship XML::Simple and
Text::Template, even for Linux distributions. Stuff that requires
compilation (like XML::Parser, Compress::Zlib, etc., etc.), I leave
up to the ever easy-to-use CPAN.
--
Morbus Iff ( i put the demon back in codemonkey )
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/disobeycom
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: How to print ... during download

2003-12-10 Thread Morbus Iff
What if I want to print a ... and calculate the percentage and amount of
currently downloaded size during the download process? (wget style), should
I create another process to do that? or is there any other alternative? (I
will choose the later).
I chatted about this in my book, SPIDERING HACKS:
http://amazon.com/exec/obidos/ASIN/0596005776/disobeycom
Thankfully, the discussion and code, are available free online:

 http://hacks.oreilly.com/pub/h/943
 http://disobey.com/d/code/
Depending on your shell, however, one of the examples
may not work correctly (the spinner thing, which
isn't the display you're looking for. The quick
fix is to move the \b to the front of the spinner,
not the end). There was more discussion of this on a
mailing list, but I can't remember, or find, the URL.
--
Morbus Iff ( i put the demon back in codemonkey )
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
My book, Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



RE: Get file size without downloading

2003-12-10 Thread Morbus Iff
 Is there any way to get the size of a file without downloading it?
 I want to write a program using LWP to download a file only
 if it is bigger than 3K but smaller than 500K.
 So I need to know the file size in the first place.

Try making a HEAD request - that should return
file size and last modification date. This
obviously will not work for CGI URLs.
Something like:

   my $ua = LWP::UserAgent-new();
   my $result = $ua-head($url);
   my $remote_headers = $result-headers;
   $total_size = $remote_headers-content_length;


--
Morbus Iff ( i put the demon back in codemonkey )
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
My book, Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: What is this called: ($myvar-{otherid}) ? 'stringA' : 'stringB';

2003-11-20 Thread Morbus Iff
I'm not yet able to read certain parts of perl code. What is this
comparison/alternation after the hash lookup on 'otherid' called, and what
does the code do?

  $myvar-{id} = ($myvar-{otherid}) ? 'stringA' : 'stringB';
It's a ternary or flip-flop statement. In
this case, the above is the equivalent of:
 if myvar-otherid is set, then set myvar-id to
  stringA, otherwise, set it to stringB.
Code-wise, the above is equivalent to:

 if ($myvar-{otherid}) { $myvar-{id} == 'stringA' };
 else   { $myvar-{id} == 'stringB'; }
--
Morbus Iff ( i put the demon back in codemonkey )
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
My book, Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: -w vs. use warnings

2003-08-28 Thread Morbus Iff
Having been a Perl programmer for several years now I have become
accustom to using the following as my normal start of any Perl script:

#!/usr/bin/perl
use warnings;
use strict;

Randal Schwartz uses this:

#!/usr/bin/perl -w
use strict;
$|++;

Is there any difference between the -w and use warnings declaration?
I know that both turn on warnings and the -w is commonly used at the
command line, but was just curious as to if one was better than the other.
use warnings only exists in Perl 5.004_05 or later. If you want your
scripts to work in Perl interpreters earlier than that (the still prevalent
5.004_04), then you'll need to use -w. Note: I may be slightly what crack
is he smoking? on my version numbers - it's been a while.
I prefer use warnings myself - people
really should try their damndest to update.
As for $|++, there was a recent debate (on Perlmonks.com, I believe) on how
$|=1 may be a better visual choice than $|++. I haven't made up my mind
either way - I still use ++ in my own scripts. Unfortunately, I couldn't
find the Perlmonks.com link, so I may have just dreamt this.
--
Morbus Iff ( i put the demon back in codemonkey )
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
Buy My Book! http://amazon.com/exec/obidos/ASIN/0596004605/disobeycom
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Scan data for XML invalid characters and parse articles

2002-02-13 Thread Morbus Iff

 I have a scalar variable containing HTML that needs to be converted
 to XML.  It's not the best HTML so it has invalid characters (like
 smart quotes, 1/2 character, etc.).  I need to determine if these
 characters exist in the data and throw an error if they do.  What
 is the best way to do this?  I can't use an XML parser because it's
 not really XML.

Welp, ultimately, if you were using an XML parser, it would
choke on the bad data. For instance, this code:

  use XML::Simple;
  my $data = eval { XMLin( $xml_data ); };
  if ($@) { print $@; }

Would produce error messages like:

   There was an error loading morelikethisweblog.xml: not
   well-formed at line 72, column 28, byte 4001 at
   C:/Perl/site/lib/XML/Parser.pm line 168.

   There was an error loading hackintheboxorg.xml: mismatched tag
   at line 168, column 2, byte 4751 at
   C:/Perl/site/lib/XML/Parser.pm line 168.

A cheat would be to:

   my $invalid_data_check = data$real_data/data;

And then XMLin on $invalid_data_check, as above. Another option is to HTML 
encode all the data before passing it off to the XML creator/parsing code:

   use HTML::Entities qw( %char2entity );
   $real_data =~ s/([^\s!\#\$%\'-;=?-~])/$char2entity{$1}/g;

(note, in this example, I'm importing the char2entity hash myself, which 
allows me to define exactly what characters I DO NOT want turned into 
entities (the first part of the regexp). Check the man page for the defaults.

With the above in hand, my XML parsing usually runs like this:

  use XML::Simple;
  my $data = eval { XMLin( $xml_data ); };
  if ($@) {
   print $@, attempting to repair.;
   $xml_data =~ s/([^\s!\#\$%\'-;=?-~])/$char2entity{$1}/g;
   eval { XMLin( $xml_data ); }
   if ($@) { print Nope. Still an error.; }
  }

You can probably modify that to your use.


-- 
Morbus Iff ( softcore vulcan pr0n rulez )
http://www.disobey.com/  http://www.gamegrene.com/
please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Open a brand new browser window with Perl

2002-02-07 Thread Morbus Iff

 Is it possible to open a brand new browser window and set it's size,
 location and characteristics (no menu bar, no status bar, etc.) using Perl
 or is it necessary to always use the same window that has called the script?

With Perl, no. But you can certainly tell Perl to send some javascript that 
does what you want to the browser. Have Perl spit out something like this 
to the browser window:

  html
  head
 SCRIPT LANGUAGE = Javascript TYPE=text/javascript!--
 function open() { window.open('/path/to/file.shtml', 'Your New Window',
 'height=125,width=360,toolbar=no,scrollbars=no,menubar=no,location=no,
 directories=0,status=no,resizable=0'); }
 //--/SCRIPT
 titleSee Other Window/title
  /head
  body onLoad=open()

   h1Please See The Other Window/h1

  /body
  /html



--
Morbus Iff ( softcore vulcan pr0n rulez )
http://www.disobey.com/  http://www.gamegrene.com/
please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Win32::GUI - Getting rid of console Window?

2002-02-01 Thread Morbus Iff

 Is there anyway to get a Win3::GUI app to not display the DOS console when
 running, so it runs just like any other GUI app?

Yuppers.

use Win32::GUI;

# hwnd is a handle to a window - basically, window's
# way of keeping track of it's program windows...
$hwnd = GUI::GetPerlWindow();

# comment this to see error messages in a dos window
# otherwise, this will hide the blasted thing...
GUI::Hide($hwnd);


--
Morbus Iff ( softcore vulcan pr0n rulez )
http://www.disobey.com/  http://www.gamegrene.com/
please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Win32::GUI - Getting rid of console Window?

2002-02-01 Thread Morbus Iff

 The only downside to this method is that an errant Perl Window can linger
 around long after you think it's been closed (i.e. it won't show anywhere
 expect under Task Manager).

Russ,

I had noticed that a while too. Somehow or another, with the Windows.pl 
file in the AmphetaDesk [1] source, I've stopped that. Not sure how, but 
check it out...

[1] http://www.disobey.com/amphetadesk/


--
Morbus Iff ( softcore vulcan pr0n rulez )
http://www.disobey.com/  http://www.gamegrene.com/
please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Streaming Source Code Updates

2002-01-30 Thread Morbus Iff


I'd like to:

 - create or use a module that allows me to stream source code updates
   to a specific program. Something like: the user clicks update me
   now, the program downloads all differing modules and libraries,
   sticks them in the current install directory, and reloads itself
   midrun.

The closest correlation I can find is the whole
install CPAN, reload CPAN sort of ideal.

 - How is this done? ie., how do you load a module at
   runtime, and then unload/reload it in mid run?

 - Does anyone have any pointers on streaming
   source code updates? Has it been done before?
   Should I go a tar.gz route, or specific modular
   downloads?

-- 
Morbus Iff ( i'm wearing footsie jammies here )
http://www.disobey.com/  http://www.gamegrene.com/
i write for good folk. read me: http://oreillynet.com/pub/au/779
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Links to DBM Tutorials?

2002-01-09 Thread Morbus Iff

Does anyone have any good tips or links to DBM tutorials? I'd like to start 
using DBFile and the like to store a database. From the limited knowledge I 
know of them, you can only use single level hashes?

Ultimately, I'm looking to store something like this:

  $pictures{001}{name}
{width}
...
{description}
  $pictures{002}{name}
{width}
...
{description}

Likewise, I'd be keeping a second database of:

  $comments{001}{1}{name}
   {email}
  $comments{001}{2}{name}
   {email}
  $comments{003}{1}{name}
   {email}

And so on and so forth. An RDMBS is NOT an option for me. I could do this 
stuff easily with a delimited text file DB, but was under the impression 
that DBM allow faster access.

Any pointers or tips are appreciated.


--
Morbus Iff ( softcore vulcan pr0n rulez )
http://www.disobey.com/  http://www.gamegrene.com/
please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Perl2Exe (or Compiled Perl) and Shipping Runnable Source

2002-01-07 Thread Morbus Iff

Hey all,

To summarize, my impresssion of people's hatred of Perl2Exe
or generically, compiled (hidden source) perl is:

  - it hides the source from the user. this goes against Perl,
and you really should be using another language if you want
to be such a Nazi.

I totally agree with this. Now, the caveat: *I* ship compiled Perl 
applications, primarily AmphetaDesk [1], which is available for Mac and PC. 
My primary reason of shipping compiled is:

  - it saves the user from having to download a large Perl
installation, and learning how to interact with Perl
and CPAN. I cater to the lowest common denominator in
*everything* I do. If it's not easy, then I won't ship
it - this extends OUTSIDE of Perl - if the download
is to long, or the install process isn't easy, then
those are problems too.

So, I started thinking of how to merge both of those two ideals. My initial 
thought, and why I'm writing this email, is use / require / do. The idea is 
to write a wrapper exe that simply loads in, at runtime, the pure perl 
code. Roughly:

- all real source code under /src/
- a wrapper.pl script under / that contains all
  module declarations, path determinations, etc,
  that contains, simple do /src/mainscript.pl or
  use src/mainscript.lib, etc.

This wrapper.pl would then be turned into the wrapper.exe that is created 
from runtime builders like perl2exe or MacPerl. The wrapper.exe would 
contain all the CPAN modules, all other modules used, and any XS libraries 
needed. The actual application source code would be shipped as plain text. 
In this case, we satisfy the first requirement:

  - the perl interpreter, all modules, and XS libraries are contained
in one binaried app, which prevents the need for additional
downloading and installation.

It also satisfies the second requirement:

  - all source code for the app is shipped plain text, in /src/.

Now, the inevitable questions:

  - how do the naysayers and the users feel about this?
  - what do you see can break about this implementation?

Once I get more time, I'll be trying this approach on my own AmphetaDesk.

[1] http://www.disobey.com/amphetadesk/


--
Morbus Iff ( softcore vulcan pr0n rulez )
http://www.disobey.com/  http://www.gamegrene.com/
please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Computer connected to the internet?

2002-01-04 Thread Morbus Iff

How about pinging several hosts that have a pretty good chance of being up.
www.microsoft.com, www.netscape.com, www.ibm.com, etc, etc. You could also
ping your local gateway address. If all fail (except for the router as the
link may be down beyond that, but if the ping to the router fails, then you
are definetly without connection) then you could assume you've lost
connection.

If a user has connect automatically or dial automatically, will this
pinging cause the computer to dial? I'm thinking of this in a dialup
Win/Mac environment.

-- 
Morbus Iff ( i assault your sensibilities! )
http://www.disobey.com/  http://www.gamegrene.com/
read me: http://www.oreillynet.com/pub/a/mac/2001/12/07/apache.html
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: dollar sign in subject

2001-12-18 Thread Morbus Iff

Every time any of you place a dollar sign ($) in the subject line, it gets
tossed into the deleted file here.

Those are pretty draconian filters you have. I can see filtering $$$
subject lines (as I do locally), but subject lines that contain $ should be
further analyzed for common spam language (money, free, order, etc.).
I set up the procmail filters at my local ISP, so we run through various
scoring rules to see how much a $ subject line should really be considered
spam.

Perl-wise, you may want to look at the following:

 http://razor.sourceforge.net/
 http://sourceforge.net/projects/sendmail-milter/
 http://spamassassin.taint.org/

-- 
Morbus Iff ( softcore vulcan porn rulez )
http://www.disobey.com/  http://www.gamegrene.com/
read me: http://www.oreillynet.com/pub/a/mac/2001/12/07/apache.html
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: New Coder

2001-11-19 Thread Morbus Iff

 I am a new programmer fresh out of logic and program development school.

Ever read Code Complete by Steve McConnell?
I'd place that first on your reading list.

 Immediately I have been thrown into an environment where I have to learn 6
 new computer languages...one of which is PERL. Where do I start? Thanks.

Learning Perl from O'Reilly. De facto.


--
Morbus Iff ( softcore vulcan porn rulez )
http://www.disobey.com/  http://www.gamegrene.com/
please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: New Coder

2001-11-19 Thread Morbus Iff

 Ever read Code Complete by Steve McConnell?
 I'd place that first on your reading list.
 
 I'm still excited that the OP said he came from a school whose title
 implies that they taught the kinds of things that CC covers... I would like
 to know whether this was the case.

I'd be interested to know too. We have classes that teach that around 
here, but they're rather moronic, ie. when to use an unless and when to 
use a negating if. Not what I'd considered covered by CC ;) ...

 ITYM de rigeur :-)

Acronym and foreign language. Brain ... shutting ... dow..~! g


--
Morbus Iff ( softcore vulcan porn rulez )
http://www.disobey.com/  http://www.gamegrene.com/
please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Perl based Notification System

2001-10-29 Thread Morbus Iff

 a) Having a minimized Web browser window, that would periodically poll the
 Server side Perl Script, which would call the database to see if such an
 event occured and then return the feedback.

This could be done with a simplistic Meta Refresh - if you're script is 
located at server.com/script.pl, then you could set up a blank meta refresh 
page to simply call that script every X minutes.

 I need to know if there are any Perl-compatible technologies that would do
 this kind of messaging functionality..say Jabber(???) etc?

There are Jabber modules available, check out these:

   http://www.pipetree.com/jabber/
   http://www.pipetree.com/jabber/fwj.html

Also, the Applied Perl book has a chapter on integrating with Jabber.


--
Morbus Iff ( softcore vulcan porn rulez )
http://www.disobey.com/  http://www.gamegrene.com/
please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Storing a Decryptable Password?

2001-10-02 Thread Morbus Iff

I have a need to store a user's password in a configuration file:

  - the password should NOT be in plain text.
  - the password should be decryptable so that we
don't have to ask the user each time (as per
the common Unix crypt ideal).

Any ideas? There's always the cheap sort of rot13, binary, decimal sort of 
madness, but I was looking for something a bit more hard to deciper at a 
glance. I know the inherent risks with having a decryptable, but I'll take 
those over the obvious risks of plaintest stored passwords.

Thoughts?


--
Morbus Iff ( i am your scary godmother )
http://www.disobey.com/  http://www.gamegrene.com/
please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: how to change the prompt in perl

2001-09-26 Thread Morbus Iff

 Is their any function is available

Are you talking about your shell prompt? If that's the case, then that's a 
capability of the shell itself, and you'd want to look into the appropriate 
docs (for example, there's a Bash Prompt HOWTO).

Technically, yes, you could use Perl to edit the relevant shell file to 
insert the configuration of your desire. That, however, is kinda innane.


--
Morbus Iff ( i am your scary godmother )
http://www.disobey.com/  http://www.gamegrene.com/
please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: STDIN Help

2001-09-24 Thread Morbus Iff

=
EOF
;
print $output;

Instead of including your put text here arrow in
your initial block, put it as part of output:

my $output = EOF
Select the number of clients to run for this SLT:
1)  2000
2)  1500
3)  1300
4)   500
EOF
;
print $output =;
$num_clients = STDIN;

-- 
Morbus Iff ( i am your scary godmother )
http://www.disobey.com/  http://www.gamegrene.com/
please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: how to write a password generator

2001-09-13 Thread Morbus Iff

 What resources can I look at to start writing a password generator from a
 complete newbie level of knowledge??

If you want to mimic Unix passwd, do something like:

$seed = (some randomly generated bit of something);
$plaintext_password = password;
$encrypted_password = crypt($plaintext_password, $seed);


--
Morbus Iff ( i am your scary godmother )
http://www.disobey.com/  http://www.gamegrene.com/
please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: weird activity...

2001-09-10 Thread Morbus Iff

 i have a cgi script to enter user data, etc.  i am also loading a couple
 images.  when the cgi comes up on my web browser, ( i am running rh7.1,
 apache 1.3.19 PHP/4.04p11 mod_perl/1.24_01 and using opera ) the form is
 there fine and works.  my images don't show up.  there is no error in the
 error.log, no entry for the image in the access log, and when i open the
 source, i do see the IMG SRC tags there?  how can that be?  since i am not
 using mod_perl do i need to disable that?

If you manually try to load the images, what happens?
Say, for example, your script is here:

http://www.domain.com/cgi-bin/script.pl

And your images are referred this way:

src=../images/bob.jpg

In which case, try to load this file:

http://www.domain.com/cgi-bin/../images/bob.jpg

What happens? Most of the time, non-executable files located in a cgi-bin 
directory can NOT be accessed. If you're using relative links (like above - 
with .. or just plain /), then try switching to absolute links 
(http://www.domain.com/images/bob.jpg;) and see what happens.


--
Morbus Iff ( i am your scary godmother )
http://www.disobey.com/  http://www.gamegrene.com/
please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Does Perl2Exe remove the Compilation Phase?

2001-08-31 Thread Morbus Iff

Recently, I've been reading a lot into CGI performance and how to reduce 
the amount of memory and time it takes to run a CGI based application. The 
number one thing to attack is the start time - the half second or so that 
Perl looks at the script and compiles all the modules and that sort of junk.

Now, knowing that skipping the compilation phase will not solve all my 
problems (since most are related to the CGI environment), if I Perl2EXE'd 
for Linux my CGI programs, would that save me a half second or so (or 
whatever the startup costs are)?

Or does that merely embed the interpreter
so that the startup / compilation phase still happens?


--
Morbus Iff ( i am your scary godmother )
http://www.disobey.com/  http://www.gamegrene.com/
please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Run a CGI Script on OS X w/o...

2001-08-16 Thread Morbus Iff

 I have a mac w/ OS 9, and would like to know if I upgrade to OS X (UNIX
 BASE) would I be able to run CGI scripts natively w/o having to connect to
 the internet, but use the WEB SERVER on the hard disk instead? I heard that
 the only way to connect to the internet w/ OSX is through Ethernet, no
 dial-up support yet.

Yes. You can. OS X has a build of Apache built in, as well as a full Unix 
Perl. You'd be able to test either connected to the Internet, or locally 
with no 'net connection (using 127.0.0.1).


--
Morbus Iff ( i am your scary godmother )
http://www.disobey.com/  http://www.gamegrene.com/
please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: executing a cgi-script continously

2001-08-16 Thread Morbus Iff

Is it possible to have a CGI script that, at the end of doing all the

James Keltys idea using a perl script in cron using LWP::Simple against the
CGI in question sounds the most obvious answer

How do you figure? He wants to run it after the script is done, not every X
minutes, like a cron. I mean, sure, you could throw a cron of every minute
or so, but that doesn't take into effect if the script has been completed,
if the DB is down, or anything of the sort. He may not have cron access,
either.

Ultimately, he wants a continuous loop, not a timed loop.
Enlighten me if I'm wrong, of course.

can you give me an example of Content-type header and then a Location:
header that referred back to the script ?  Should this be at or near the
end of the

You would throw it near the end of the script, after the script has done
everything you want it to do. This assumes that your script doesn't spit
out any HTML (or really anything else) to the web browser or user.

   print Location: http://path/to/cgi/script.pl\n\n;;

-- 
Morbus Iff ( i am your scary godmother )
http://www.disobey.com/  http://www.gamegrene.com/
please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: cgi syslog

2001-08-15 Thread Morbus Iff

Does anybody know how to access root owned file via cgi script?

Not unless your webserver (which runs the cgi script with its own
permissions) is set as root, and that's normally a big no-no. There is a
Syslog module though  - you may want to look into that (I know nothing
about it, though)...

-- 
Morbus Iff ( i am your scary godmother )
http://www.disobey.com/  http://www.gamegrene.com/
please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: format for code review

2001-08-13 Thread Morbus Iff

 And remember, the key to having someone actually read your code is to make
 it readable; make good use of whitespace and indentation, this isn't an
 obfuscated Perl contest.

I'd also include, with a healthy shout, to comment your own code first. It 
helps people a lot if we can see what you were trying/intending to do, as 
opposed to what you actually did.


--
Morbus Iff ( i am your scary godmother )
http://www.disobey.com/  http://www.gamegrene.com/
please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: unix perl to win NT perl

2001-07-18 Thread Morbus Iff

Originally posted on beginners@:

 Much like cultures, programming evolves over time. It's old and bad because:
 
  1. it's not written with security in mind. when the internet
 comes in play, security should be the number one feature, and
 nothing else.
 
  2. it's not written in good programming style. any production
 perl script should include -w and use strict as programming
 ideals. these force the programmer to write better code
 and to clean up after himself. not using these ideals severely
 impacts #1 (above).
 
  3. Generally speaking, every script from Matt Wright's should
 be ignored. None of his scripts are particularly well written
 and security holes abound. I wouldn't even try fixing his
 scripts - I'd just start over.

To find other scripts:

 You could try the following (in that order):
 
   http://perlarchive.com/
   http://www.cgi-resources.com/
   http://www.hotscripts.com/


--
Morbus Iff ( .sig on other machine. )
http://www.disobey.com/  http://www.gamegrene.com/
where's there's a will, there's a morbus ready to collect!
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber: [EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: unix perl to win NT perl

2001-07-18 Thread Morbus Iff

 Apart from the dates on the top of the script, how can you tell it's old,
 and why is it bad stuff?

Much like cultures, programming evolves over time. It's old and bad because:

  1. it's not written with security in mind. when the internet
 comes in play, security should be the number one feature, and
 nothing else.

  2. it's not written in good programming style. any production
 perl script should include -w and use strict as programming
 ideals. these force the programmer to write better code
 and to clean up after himself. not using these ideals severely
 impacts #1 (above).

  3. Generally speaking, every script from Matt Wright's should
 be ignored. None of his scripts are particularly well written
 and security holes abound. I wouldn't even try fixing his
 scripts - I'd just start over.


--
Morbus Iff ( .sig on other machine. )
http://www.disobey.com/  http://www.gamegrene.com/
where's there's a will, there's a morbus ready to collect!
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber: [EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: unix perl to win NT perl

2001-07-18 Thread Morbus Iff

 I'm not competant enough to write a complete guestbook script, only to edit
 scripts I find. Any ideas where I can get a new guestbook script?

You could try the following (in that order):

   http://perlarchive.com/
   http://www.cgi-resources.com/
   http://www.hotscripts.com/


--
Morbus Iff ( .sig on other machine. )
http://www.disobey.com/  http://www.gamegrene.com/
where's there's a will, there's a morbus ready to collect!
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber: [EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Nasty

2001-07-13 Thread Morbus Iff

 I don't work with a lot of programmers. I hope to get into a situation where
 I do. Is it fair to say the majority are *holes?

Bwahahah. Not at all. We're smarter than you, but not as presumptuous.


--
Morbus Iff ( .sig on other machine. )
http://www.disobey.com/  http://www.gamegrene.com/
where's there's a will, there's a morbus ready to collect!


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Nasty

2001-07-13 Thread Morbus Iff

At 04:55 PM 7/13/01, you wrote:
  I don't work with a lot of programmers. I hope to get into a 
situation  I do. Is it fair to say the majority are *holes?
 
 Bwahahah. Not at all. We're smarter than you, but not as presumptuous.

Of course, the nicer comment is:
   The ones who act like such are too sure of their perceived intelligence.

:)


--
Morbus Iff ( .sig on other machine. )
http://www.disobey.com/  http://www.gamegrene.com/
where's there's a will, there's a morbus ready to collect!


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Re-inventing wheels (WAS re: Required Fields Module)

2001-07-10 Thread Morbus Iff


 Please note that CGI.pm is a special case.

My problem with CGI.pm is that, get this, it's too complicated. I've tried 
to use it, but, quite simply, all I would ever want out of a CGI routine is 
to give me back the data in either a hash or object reference. The 
difference between:

$value = $form-{foo};

and

@values = $query-param('foo');

isn't much, but it's enough to annoy me, especially when I don't need all 
the  rest of the 208k module.

My other major beef is that it strikes against something I hold dear in 
programming - separating of design from the code. Sure, it may write valid 
HTML, but to do so, you need to be able to write valid perl. I'd much 
rather see someone hack a HTML template on the server and screw up my 
perfect XHTML than muck around with a perl script and stop the script from 
running due to syntax errors, line encodings, or what have you.

But hey, that's just me.





Re: How to make a script run in the background on a Win32 machine

2001-07-10 Thread Morbus Iff

I was hoping someone could point me in the right direction. I have a script
that will run for long periods of time (checking a url every once in a while
to make sure it is up) on a Windows98 machine. The script works fine, but it
runs in a dos window. Is there a way in which I could invoke the script and
have the dos window with the script running in the background?

You could try the following:

   use Win32::GUI;

   # hwnd is a handle to a window - basically, window's
   # way of keeping track of it's program windows...
   $hwnd = GUI::GetPerlWindow();

   # comment this to see error messages in a dos window
   # otherwise, this will hide the blasted thing...
   GUI::Hide($hwnd);

-- 
  ICQ: 2927491  /  AOL: akaMorbus
   Yahoo: morbus_iff/  Jabber: [EMAIL PROTECTED]
   [EMAIL PROTECTED]   /   http://www.disobey.com/



Re: Re-inventing wheels (WAS re: Required Fields Module)

2001-07-10 Thread Morbus Iff

 CGI.pm isn't the only solution to creating dynamic web pages with Perl.
 Text::Template is another alternative, as are embedded Perl
 implementations like Apache::ASP, Mason, or even PerlScript (for IIS).

 None of which is crossplatform (Windows / Mac / Linux)
 or installable by a user with normal access on a webhost.

Text::Template is installable as a regular module and is cross-platform.

Hmm... My reasoning for saying it wasn't was because CPAN says it failed
the Win32 build. Have you used it before? Anything to say concerning memory
usage? It's small enough to distribute with a tarbull too (for those people
who don't have module install rights)...

-- 
  ICQ: 2927491  /  AOL: akaMorbus
   Yahoo: morbus_iff/  Jabber: [EMAIL PROTECTED]
   [EMAIL PROTECTED]   /   http://www.disobey.com/



Re: Re-inventing wheels (WAS re: Required Fields Module)

2001-07-10 Thread Morbus Iff

use CGI :all;
@values = param('foo');

If you're using the object interface, you've read the wrong book.
Even Lincoln himself doesn't use that for any examples I've seen him
teach in seminars.  perldoc CGI is written that way mostly from
legacy, not optimization.

Hmmm. Ok. That would shoot down that complaint. I think the only other one
I had regarding the param() sort of interface was the fact that I had to
assign the value of a param to an interim value (is that right?). So
instead of:

   print The color is $form-{foo};# the way i want
   print The color is param('foo');# the way i'd want

I'd have to do:

   my $color = param('foo');
   print The color is $color;

Is that accurate?

Stop quoting the size.  That's a red herring.  That's like saying I'm
not invoking the 60,000 line Perl binary when my 15 line C program will
do the same thing.  Dumb argument.

So there's no additional overhead to using a routine from CGI.pm? I work
for an ISP where a spike on MRTG spells instant remove that script!
remooovee thattt script!!. I'm not trying to be sarcastic - what
happens to the other 180k of code that I don't use? Is it ever loaded into
Perl? It must take up some something, right? I had read previously that
CGI.pm is super smart in that aspect, and doesn't load junk that it doesn't
need, but doesn't the dormant code cause some effect? What if this script
is being hit a hundreds of thousands of times a week (mod_perl is not an
option)?

-- 
  ICQ: 2927491  /  AOL: akaMorbus
   Yahoo: morbus_iff/  Jabber: [EMAIL PROTECTED]
   [EMAIL PROTECTED]   /   http://www.disobey.com/



Re: Feasible?

2001-06-20 Thread Morbus Iff

 You see, we'd like to add a count of users online to our homepage.
 We are an ISP, and as such, this information is stored not on the
 websever that will host the page, but rather inside of the various
 dial-in platforms both in the office and at our co-location points.

It's certainly feasible, yes. I've written a script which fingers various 
terminal servers, telnet's into a Cisco server, and then uses a C program 
to SNMP into a PM3 to get that information - I display username, line 
speed, idle time, all that fun stuff. Shouldn't be that hard to just spit 
out a number instead.


Morbus Iff
.sig on other machine.
http://www.disobey.com/
http://www.gamegrene.com/




Re: Where to begin??!!??

2001-06-14 Thread Morbus Iff

 The point:
 I need to take this text file and format each entry (separated by hard
 returns) so that the user info (name address, etc) are all in their own
 columns still and then for each number they chose (up to 271 out of 271) it
 creates a new entry with their contact info and one number in the last
 column.

Here's some untested pseudo code to help you:

  # for each line of the DAT file:
  while (FILE) {

 # split each line on the pipe, and throw into matching
 # variable entries - note that bingo numbers are all
 # thrown into a single array.
 my ($date, $time, $name, $street, $city, $state,
 $town, $zip, $country, $email, $phone, @subscriptions) =
 split (/|/, $_);

 # now, loop through the subscriptions array and
 # create a new line for each bingo number.
 foreach my $subscription (@subscriptions) {

$new_data .= $name|$street|$city|$state|$country|
  $zip|$phone|$email|$subscription|\n;

 }

  }

Once the entire DAT file has been looped through, you'll have your 
completed data in $new_data to do whatever you want. NOTE that this is 
untested code. Don't sue me if I birth your child.


Morbus Iff
.sig on other machine.
http://www.disobey.com/
http://www.gamegrene.com/




Re: closed filehandle

2001-05-31 Thread Morbus Iff

 what does a closed filehandle error mean? i'm trying to write to a log
 and yes, the permissions for the directory and the log are 777.

A closed filehandle means that the pipe (ie., the tunnel that connects your 
perl script to the innards of the file) is no longer there. See the 
examples below:

open(PIPE_TO, your-filename);
print PIPE_TO burp!;
close PIPE_TO;
print PIPE_TO sadness;

The burp line will print to the file correctly (assuming we were able to 
create the pipe to your-filename). The sadness line, however, won't 
because we've closed the pipe.

You *definitely* want to test that the pipe is created successfully. The 
code above is much nicer like this:

open(PIPE_TO, your-filename) or die Problem!: $!;

This has a double benefit. If the pipe isn't open correctly, then you'll 
get Problem!: printed to STDOUT. Along with problem is a magical thingy 
called $!, which contains a remotely specific error on why the pipe 
couldn't be open in the first place...


Morbus Iff
.sig on other machine.
http://www.disobey.com/
http://www.gamegrene.com/




Re: you all are going to laugh at me

2001-05-31 Thread Morbus Iff

 i can't believe this. the whole problem is this: instead of working on my
 work's afs account, i'm copying over the scripts to my account just in
 case something goes wrong. well, i just moved to a different office and i
 realized (just now) that i was using binary instead of ascii.
 
 thanks to all that tried to *help* me. little did you know the idiotic
 mistakes i am known for. :)

Heh. I make the binary/ascii mistake all the time - often times fighting 
between the FTP/editor knows what it's doing and no, listen to Morbus, I 
know what I'm doing.


Morbus Iff
.sig on other machine.
http://www.disobey.com/
http://www.gamegrene.com/




Re: On Beginners' Mindsets, Part II

2001-05-30 Thread Morbus Iff

 Secondly, want to understand *everything*.  Even if you leave some parts
 until later because they're less interesting or less relevant, strive to
 understand an entire process from top to bottom.  It's amazing how often

I agree wholeheartedly with this statement. I've done the gambit of 
advanced perl programming, but I still read perl tutorials and beginner 
columns. Why? Because I don't doubt that the author can shed a pe[a]rl of 
light in a slightly different way, or highlight a metaphor that I can 
reiterate to another...

When I buy magazines, I read *every single bit* of text. Same with books. 
It was written for a reason - it's my reading of that text that gives it 
reason, not hastily skipping over it because it's uninteresting at the time.

There are some people who say they only read the stuff they need to know at 
the time they need to know it - and that anything else means shoving 
useless facts into the brain that could push worthwhile facts out. I don't 
agree, not in the least.

 Thirdly, devour good examples of code that are just within or just beyond
 your current understanding.  They'll both broaden and deepen your expertise

Definitely agreeable. I learn much faster from examples.


Morbus Iff
.sig on other machine.
http://www.disobey.com/
http://www.gamegrene.com/




RE: use strict / explicit packages

2001-05-29 Thread Morbus Iff

 I am using MacPerl here.

Good! I love seeing Mac people learning Perl.

 Line 9:  Global symbol FORM_DATA requires explicit package name.

In this case, you correctly localized the $key that you were using, but not 
the actual %FORM_DATA itself. Much like you did my $key, simply add 
another line at the top of the script that says my %FORM_DATA;.


Morbus Iff
.sig on other machine.
http://www.disobey.com/
http://www.gamegrene.com/