[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] droplet




On Fri, 1 Oct 1999, Simon Martel wrote:

> I am new to programming and english isn't my native langage. I learn
> programming with MacPerl and some JavaScript. I want to make a droplet
> to clean some html files. My question is : What is the way to tell the
> droplet it should read the file i drop on it. I already have the book
> "MacPerl, Power and Ease".

Just use normal perl:  you can use the <> structure to read line by line,
or use ARGV.  It just works.

while (<>) 
{
    # handle input file line by line here
}


If you want to use files dropped if there are any, but use a Mac open
dialog if there weren't any, here's a snippet I clipped from this list a
while back (Chris?  Kevin?  Alan? Ronald?   somebody?):

   
  if ($#ARGV < 0) 
  {
	  use Mac::StandardFile;
	  $file = StandardGetFile('', 'TEXT');
	  if ($file->sfGood()) 
	  {
		  push(@ARGV, $file->sfFile());
	  } 
	  else 
	  {
		  exit(1);
	  }
  }


And lastly, I highly recommend using HTML::Parser and HTML::Filter to
break apart HTML files.  Have you looked at using these?


--
MattLangford 



# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org