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

MacPerl-Digest V1 #29




MacPerl-Digest        Wednesday, March 31 1999        Volume 01 : Number 029



Re: [MacPerl] Flat files and variable miles
Re: [MacPerl] Find SMTP server(s): nslookup?
Re: [MacPerl] Find SMTP server(s): nslookup?
Re: [MacPerl] Find SMTP server(s): nslookup?
Re: [MacPerl] Flat files and variable miles
Re: [MacPerl] Find SMTP server(s): nslookup?
Re: [MacPerl] Find SMTP server(s): nslookup?
Re: [MacPerl] Find SMTP server(s): nslookup?
Re: [MacPerl] Find SMTP server(s): nslookup?
Re: [MacPerl] Find SMTP server(s): nslookup?
Re: [MacPerl] Flat files and variable miles
Re: [MacPerl] Flat files and variable miles
Subj:   Re: [MacPerl] Find SMTP Re: [MacPerl] Find SMTP server(s): nslookup?
Re: [MacPerl] Find SMTP Re: [MacPerl] Find SMTP server(s): nslookup?

----------------------------------------------------------------------

Date: Wed, 31 Mar 1999 07:18:49 -0600
From: "Jefferson R. Lowrey" <lowrey@mailbag.com>
Subject: Re: [MacPerl] Flat files and variable miles

At 7:10 AM -0500 3/31/99, Allan Greenier wrote:
>Greetings,
>I posted a general question last week about doing a CGI script using a
>flat file version of a Filemaker database.
>Noe that I've gotten a look at the database, it's record is about 50
>fields long! So to put each line in a variable would look something
>like:
>
>my $Var1,$Var2,$Var3..$Var50 = @_
>
>Will this work? Or is it impractible?

I expect it should work.  It does seem rather impractical though.

If I were using Fortran, I'd use an array and name 50 constants to access
each element of the array.

In perl, I expect one should think hash.

>I really would like to keep a flat file solution...simplicity you know.

I haven't used any of the db file modules in perl, but I'm not sure that
using them is any less simple than using a flat file - unless you are
trying to use the database from something else other than perl.  It sounds
like you're trying to pull all the records from a filemaker pro database,
munge them, and then put them back, yes?

- -Jeff Lowrey
just another perl lurker



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

------------------------------

Date: Wed, 31 Mar 1999 08:18:59 -0500
From: "Paul J. Schinder" <schinder@pobox.com>
Subject: Re: [MacPerl] Find SMTP server(s): nslookup?

At 1:34 PM +0200 3/31/99, Milivoj Ivkovic wrote:

} Now that I have the hostname, I can go on to the real purpose of this:
}try to find an SMTP server nearby.
}
} Of course, I'll check Net::Config and try to connect to localhost on port
}25. But what else can I do?
}
} Does Net::DNS work on Macs? (It doesn't on Win95).

Yes, it works, but don't count on it being installed.  It requires that
there be a "/etc/resolv.conf", which isn't a real problem, except MacPerl
users don't usually have one.  You have to construct one and point Net::DNS
at it.

}
} Would some Macs have environment variables like $ENV{MAILHOST} set?

Mine does, but that's because I use MailTools.  In general, no.

}
} And of course, I would like to find the MX records for the local domain.
}WinNT and Linux are easy: `nslookup ....`. What about Macs? Would it have
}implemented `nslookup` as with `hostname`?

No.  There are programs that do DNS queries, but you can't count on them
being installed, and you'd have to learn enough about AppleEvents to get
the answer out of them.  The program I use does not have any way of doing
MX queries (only does A); I'd use Net::DNS if I needed to do an MX lookup
here.

}
} Or would some Macs have such a command (I read something about Unix tools
}in a new Mac OS)?

Sure, on Mac OS X server.  But the number of people willing to spend $500
to run it on the limited number of models that will run it are few.  And
they're probably running 5.005_03 or 5.005_5? rather than MacPerl in the
blue box anyway.  Those you treat as BSD boxes, because in essence that's
what they are.

Since I've tested Mail::Sendmail multiple times, and edited test.pl, I've
always thought what you should do is have the test simply prompt the user
and ask for the address to send the test to and the server address.  The
user may not know, but if he doesn't, you probably won't be able to find
out from the settings the same user has put into various other pieces of
software.  Ordinarily I hate prompting software, but here you need only two
things, and the test is run only once for each release.

- -----
Paul J. Schinder
schinder@pobox.com

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

------------------------------

Date: Wed, 31 Mar 1999 08:27:01 -0500
From: Chris Nandor <pudge@pobox.com>
Subject: Re: [MacPerl] Find SMTP server(s): nslookup?

At 06.34 -0500 1999.03.31, Milivoj Ivkovic wrote:
>Now that I have the hostname, I can go on to the real purpose of this: try to
  find an SMTP server nearby.
>
>Of course, I'll check Net::Config and try to connect to localhost on port 25.
  But what else can I do?
>
>Does Net::DNS work on Macs? (It doesn't on Win95).

I would tell you to try checking CPAN Testers, but perl.org is down.  :/

Normally, though, the first thing that you should check when wondering if a
module works on a platform is CPAN Testers.

    http://www.perl.org/cpan-testers/

If a module requires building or porting for MacPerl, the next thing you
should check is MMP (MacPerl Module Porters):

    http://pudge.net/mmp/


ANYWAY ... I just tested it and it passed all tests on my Mac.  I'll submit
a report to CPAN Testers later if one is not already there.


>Would some Macs have environment variables like $ENV{MAILHOST} set?

Doubtful.  Just use Net::Config; it will usually work, and contain the
user's preference.  In MacPerl, it is magical by default.

Net::Config comes with MacPerl and is set to get the user's preference from
Internet Config (MacPerl comes with IC) ... so if the user has IC set up
(which most users do these days), then this will have the proper value by
default.

Some users who don't like IC or want a different value will hardcode
another value in there, but either way, it will work.


>And of course, I would like to find the MX records for the local domain.
>WinNT
  and Linux are easy: `nslookup ....`. What about Macs? Would it have
  implemented `nslookup` as with `hostname`?

Well, since Net::DNS seems to work, I guess you could use Net::DNS for MX
records, right?  I've not looked much at it.

- --
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

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

------------------------------

Date: Wed, 31 Mar 1999 08:29:28 -0500
From: Chris Nandor <pudge@pobox.com>
Subject: Re: [MacPerl] Find SMTP server(s): nslookup?

At 08.18 -0500 1999.03.31, Paul J. Schinder wrote:
>At 1:34 PM +0200 3/31/99, Milivoj Ivkovic wrote:
>
>} Does Net::DNS work on Macs? (It doesn't on Win95).
>
>Yes, it works, but don't count on it being installed.  It requires that
>there be a "/etc/resolv.conf", which isn't a real problem, except MacPerl
>users don't usually have one.  You have to construct one and point Net::DNS
>at it.

Interesting.  I don't have one, and Net::DNS passed all tests.

- --
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

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

------------------------------

Date: Wed, 31 Mar 1999 08:33:53 -0500
From: Chris Nandor <pudge@pobox.com>
Subject: Re: [MacPerl] Flat files and variable miles

At 08.18 -0500 1999.03.31, Jefferson R. Lowrey wrote:
>At 7:10 AM -0500 3/31/99, Allan Greenier wrote:
>>Greetings,
>>I posted a general question last week about doing a CGI script using a
>>flat file version of a Filemaker database.
>>Noe that I've gotten a look at the database, it's record is about 50
>>fields long! So to put each line in a variable would look something
>>like:
>>
>>my $Var1,$Var2,$Var3..$Var50 = @_
>>
>>Will this work? Or is it impractible?
>
>I expect it should work.  It does seem rather impractical though.
>
>If I were using Fortran, I'd use an array and name 50 constants to access
>each element of the array.
>
>In perl, I expect one should think hash.

If all you want are numbered variables, use an array and index them by the
number.

  my(@values) = @_;
  print $value[0], $value[49];

If you want the first one to be 1 not 0, stick an extra value in there:

  my(@values) = ('', @_);

Or something.

If you want names, then you a hash is probably best.


- --
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

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

------------------------------

Date: Wed, 31 Mar 1999 08:44:55 -0500
From: "Paul J. Schinder" <schinder@pobox.com>
Subject: Re: [MacPerl] Find SMTP server(s): nslookup?

At 8:29 AM -0500 3/31/99, Chris Nandor wrote:

} At 08.18 -0500 1999.03.31, Paul J. Schinder wrote:
} >At 1:34 PM +0200 3/31/99, Milivoj Ivkovic wrote:
} >
} >} Does Net::DNS work on Macs? (It doesn't on Win95).
} >
} >Yes, it works, but don't count on it being installed.  It requires that
} >there be a "/etc/resolv.conf", which isn't a real problem, except MacPerl
} >users don't usually have one.  You have to construct one and point Net::DNS
} >at it.
}
} Interesting.  I don't have one, and Net::DNS passed all tests.

In Net::DNS::Resolver.  The test may not exercise this.  Maybe it isn't
really necessary for the most common uses.

}
} --
} Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
} %PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])



- -----
Paul J. Schinder
schinder@pobox.com

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

------------------------------

Date: Wed, 31 Mar 1999 15:49:04 +0200
From: Milivoj Ivkovic <mi@alma.ch>
Subject: Re: [MacPerl] Find SMTP server(s): nslookup?

>} Does Net::DNS work on Macs? (It doesn't on Win95).
>
>Yes, it works, but don't count on it being installed.  It requires that

That's OK, we have eval.

>there be a "/etc/resolv.conf", which isn't a real problem, except MacPerl
>users don't usually have one.  You have to construct one and point Net::DNS
>at it.

Not sure what you mean by construct one. You mean that if the user doesn't have a "/etc/resolv.conf" file, I have to tell Net::DNS which DNS to use? Would make sense. Any way to get the info out of the system? If there is, it probably should be part of Net::DNS, actually.

>} Would some Macs have environment variables like $ENV{MAILHOST} set?
>
>Mine does, but that's because I use MailTools.  In general, no.

So I guess that if there is one, it should also get a high priority. I wonder whether it is usually correctly set on Unix systems.

>} Or would some Macs have such a command (I read something about Unix tools
>}in a new Mac OS)?
>
>Sure, on Mac OS X server.  But the number of people willing to spend $500
>to run it on the limited number of models that will run it are few.  And
>they're probably running 5.005_03 or 5.005_5? rather than MacPerl in the
>blue box anyway.  Those you treat as BSD boxes, because in essence that's
>what they are.

So I can still try `nslookup`. It would just print an error message if it's not there? Or would it be smarter to first check whether this is an X server? Anything different in $^O from a "plain" Mac?

>Since I've tested Mail::Sendmail multiple times, and edited test.pl, I've
>always thought what you should do is have the test simply prompt the user
>and ask for the address to send the test to and the server address.  The

Yes, these goodies have been postponed too long. Still, I feel it would be cool finding the SMTP server(s) first, and prompting the user with good defaults. I hate having to type these names over and over. It would also be nice to figure the user's e-mail address, but that would be far too much trouble for something that would only work occasionally. But the SMTP servers I'll try.

>software.  Ordinarily I hate prompting software, but here you need only two
>things, and the test is run only once for each release.

It has been 3 releases in 2 days this time, but it should stay quiet again now :-)...

Milivoj

>
>-----
>Paul J. Schinder
>schinder@pobox.com


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

------------------------------

Date: Wed, 31 Mar 1999 08:59:11 -0500
From: Chris Nandor <pudge@pobox.com>
Subject: Re: [MacPerl] Find SMTP server(s): nslookup?

At 08.49 -0500 1999.03.31, Milivoj Ivkovic wrote:
>>Sure, on Mac OS X server.  But the number of people willing to spend $500
>>to run it on the limited number of models that will run it are few.  And
>>they're probably running 5.005_03 or 5.005_5? rather than MacPerl in the
>>blue box anyway.  Those you treat as BSD boxes, because in essence that's
>>what they are.
>
>So I can still try `nslookup`. It would just print an error message if
>it's not there? Or would it be smarter to first check whether this is an X
>server? Anything different in $^O from a "plain" Mac?

I think $^O on Mac OS X Server is 'rhapsody', but I am not sure.

- --
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

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

------------------------------

Date: Wed, 31 Mar 1999 16:19:43 +0200
From: Milivoj Ivkovic <mi@alma.ch>
Subject: Re: [MacPerl] Find SMTP server(s): nslookup?

>I think $^O on Mac OS X Server is 'rhapsody', but I am not sure.

Wouldn't it be nice to have a little file on CPAN or somewhere with the $^O values and operating systems?


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

------------------------------

Date: Wed, 31 Mar 1999 16:39:00 +0200
From: Milivoj Ivkovic <mi@alma.ch>
Subject: Re: [MacPerl] Find SMTP server(s): nslookup?

>>Does Net::DNS work on Macs? (It doesn't on Win95).
>
>I would tell you to try checking CPAN Testers, but perl.org is down.  :/

Yes, I found out. Too bad...

>Normally, though, the first thing that you should check when wondering if a
>module works on a platform is CPAN Testers.
>
>    http://www.perl.org/cpan-testers/
>


>If a module requires building or porting for MacPerl, the next thing you
>should check is MMP (MacPerl Module Porters):
>
>    http://pudge.net/mmp/
>
>

Didn't know about this one. Thanks.

>ANYWAY ... I just tested it and it passed all tests on my Mac.  I'll submit
>a report to CPAN Testers later if one is not already there.

It passes all tests on my Win95 notebook, but doesn't work :/
Hey, just got it to work. Re-read the docs and found how to give it the nameservers, which it doesn't find by itself.

>Doubtful.  Just use Net::Config; it will usually work, and contain the
>user's preference.  In MacPerl, it is magical by default.
>Net::Config comes with MacPerl and is set to get the user's preference from
>Internet Config (MacPerl comes with IC) ... so if the user has IC set up
>(which most users do these days), then this will have the proper value by
>default.

Good. I didn't know it was installed by default. It wasn't on my Linux or Windows (and I had trouble installing it on Windows with older Perls), so I didn't expect to be able to count on it.

Thank you all for the help.

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

------------------------------

Date: Wed, 31 Mar 1999 08:29:02 -0600
From: Greenblatt & Seay <g-s@navix.net>
Subject: Re: [MacPerl] Flat files and variable miles

>my $Var1,$Var2,$Var3..$Var50 = @_
>
> Will this work? Or is it impractible?

Yes, it should work but I like the ability to refer to my fields by name.

- -----START CODE------

$fieldNames = "lastName,firstName,phone,address,etc.";
@fields = split(",",$fieldNames);
$fieldDelimiter = "\t"; # or whatever you use

while (<DATA>) {
	@recordFlds = split($fieldDelimiter,$_);
	for($flds=0;$flds<@fields;flds++);
		$field{$fields[$flds]} = $recordFlds[$flds];
	}
	print $field{"lastName"};
	print $field{"firstName"};
	print $field{"phone"};
	print $field{"address"};
	 # etc.
}

- -------END CODE------

Warning. This code is off the top of my head. I use this technique often
but haven't tested this particular code.

The field names list may be hardcoded in your program, in a separate file
that you'll have to read, or in the first record of your file.


David Seay
http://www.mastercall.com/g-s



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

------------------------------

Date: Wed, 31 Mar 1999 09:53:01 -0500
From: Chris Nandor <pudge@pobox.com>
Subject: Re: [MacPerl] Flat files and variable miles

Just some style suggestions ...

At 09.29 -0500 1999.03.31, Greenblatt & Seay wrote:
>$fieldNames = "lastName,firstName,phone,address,etc.";
>@fields = split(",",$fieldNames);

This can be shortened to:

  @fields = qw(last first phone address
    foo bar baz buz etc ad nauseum forever);

qw() is the same thing as split(/\s+/, $foo), where the contents
of qw() is a white-space separated list of tokens.  If your tokens
contain whitespace, it won't work, or course.  Also, if your tokens
contain ',' or '#', you will get a warning.


>	for($flds=0;$flds<@fields;flds++);

Here, i would just prefer:

  for my $n (0 .. @fields) {

- --
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

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

------------------------------

Date: Wed, 31 Mar 99 10:29:20 PST
From: pvhp@forte.com (Peter Prymmer)
Subject: Subj:   Re: [MacPerl] Find SMTP Re: [MacPerl] Find SMTP server(s): nslookup?

Milivoj Ivkovic wrote:

> >I think $^O on Mac OS X Server is 'rhapsody', but I am not sure.
> 
> Wouldn't it be nice to have a little file on CPAN or somewhere with the $^O values and operating systems?

There is such a file.  It goes by the name 'latest.tar.gz' or something like 
'perl5.005_02.tar.gz'  inside that archive you'll find a document called 
perlport.pod that has plenty of $^O listings - though admittedly I do not think 
that it contains the one for 'rhapsody' - which is very new after all
(note that even Chris who is the author of perlport is not sure if 'rhapsody' 
is correct).

Hmm, apparently it is available loose on CPAN as:

  $CPAN/doc/manual/html/pod/perlport.html

as well as at Chris's home:

  http://pudge.net/macperl/perlport.html

Peter Prymmer


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

------------------------------

Date: Wed, 31 Mar 1999 14:26:21 -0500
From: Chris Nandor <pudge@pobox.com>
Subject: Re: [MacPerl] Find SMTP Re: [MacPerl] Find SMTP server(s): nslookup?

At 13.29 -0500 1999.03.31, Peter Prymmer wrote:
>Milivoj Ivkovic wrote:
>
>> >I think $^O on Mac OS X Server is 'rhapsody', but I am not sure.
>>
>> Wouldn't it be nice to have a little file on CPAN or somewhere with the
>>$^O values and operating systems?
>
>There is such a file.  It goes by the name 'latest.tar.gz' or something like
>'perl5.005_02.tar.gz'  inside that archive you'll find a document called
>perlport.pod that has plenty of $^O listings - though admittedly I do not
>think
>that it contains the one for 'rhapsody' - which is very new after all
>(note that even Chris who is the author of perlport is not sure if 'rhapsody'
>is correct).

While perlport is a good reference, it is not very complete in respect to
$^O values.  Perhaps it could be, though.

- --
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

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

------------------------------

End of MacPerl-Digest V1 #29
****************************


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