[12371] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5971 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 12 08:07:25 1999

Date: Sat, 12 Jun 99 05:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 12 Jun 1999     Volume: 8 Number: 5971

Today's topics:
        accessing a single char in a string <bsat@iprolink.ch>
    Re: accessing a single char in a string <gellyfish@gellyfish.com>
    Re: accessing a single char in a string <gellyfish@gellyfish.com>
    Re: Accessing characters in a string? (Hasanuddin Tamir)
    Re: Calculating weekday given year, month and day (Hasanuddin Tamir)
    Re: Calculating weekday given year, month and day (Marcel Grunauer)
    Re: comparing substrings of array values (Marcel Grunauer)
    Re: defined() and my variables (Hasanuddin Tamir)
    Re: Definition of words in Perl and POSIX (Bart Lateur)
        disalowing words (Twarren10)
    Re: File Locking (Hasanuddin Tamir)
    Re: File Uploading via html form (Marcel Grunauer)
    Re: Form Redirection (Marcel Grunauer)
    Re: HELP: Perl on Windows Platform??? (Marcel Grunauer)
    Re: I'm really peaved off! <Tobin@breathemail.net>
    Re: if (my $a=1) { } print $a; Why do i get undef an no (Ilya Zakharevich)
    Re: importing comma-delimited data into perl? (Marcel Grunauer)
    Re: interesting problem involving query (Michel Dalle)
    Re: Intersection of SEVERAL ( eg. 5 -> ) lists (Bart Lateur)
    Re: Linus Torvalds and Carmen Electra? (Marcel Grunauer)
    Re: multiple match & replace regexp (Hasanuddin Tamir)
        New Website Resource (Perl, JAVA, CGI, VB, JavaScript,  sponsorfind@my-deja.com
    Re: Odd/Even Numbers? <gisle@aas.no>
    Re: Please Help!! (Bart Lateur)
    Re: problem with no text outputting from Perl CGI scrip (Marcel Grunauer)
    Re: Telnet monitor <chris@oogabooga.worldhq.org>
    Re: Verifying date data (Abigail)
    Re: Where is sendmail on NT using Perl <gellyfish@gellyfish.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Sat, 12 Jun 1999 11:53:24 +0200
From: Maan Bsat <bsat@iprolink.ch>
Subject: accessing a single char in a string
Message-Id: <37622E14.E572EAD2@iprolink.ch>

Hi,

In C, to access a single character in a string you just use the index in
the array. How can you do this in perl ? Thanks a lot.

Maan
bsat@iprolink.ch

PS: an e-mailed answer would be greatly appreciated. Thanks.


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

Date: 12 Jun 1999 10:37:46 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: accessing a single char in a string
Message-Id: <7jtd9q$hl$1@gellyfish.btinternet.com>

On Sat, 12 Jun 1999 11:53:24 +0200 Maan Bsat wrote:
> Hi,
> 
> In C, to access a single character in a string you just use the index in
> the array. How can you do this in perl ? Thanks a lot.
> 

In C a string *is* an array of characters, terminated by a null - whereas
the string is essentially an indivisible value - a single character is
indeed a string, much like BASIC for instance.

You will need to use the substr() function:

   perldoc -f substr

Of course if you really must use a subscript then I suppose you could
do:

  @string2 = split //, $string1;

  $fifthchar = $string2[4];

of course if you ever wanted to use @string2 as a string again then you
would have to put it back together into a scalar using join().

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 12 Jun 1999 11:21:15 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: accessing a single char in a string
Message-Id: <7jtfrb$l7$1@gellyfish.btinternet.com>

On 12 Jun 1999 10:37:46 -0000 Jonathan Stowe wrote:
> 

Oops - distracted by the 'Trooping of the Colour' on the telly.

> In C a string *is* an array of characters, terminated by a null - whereas

in Perl

> the string is essentially an indivisible value - a single character is
> indeed a string, much like BASIC for instance.
> 

Apologies for any confusion that may have caused ...

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 13 Jun 1999 00:15:34 GMT
From: hasant@trabas.co.id (Hasanuddin Tamir)
Subject: Re: Accessing characters in a string?
Message-Id: <slrn7m471o.791.hasant@borg.intern.trabas.co.id>

On 11 Jun 1999 20:00:48 GMT, SMS/Christian Fowler <sms@links.magenta.com> wrote:
> I am trying to parse through a scalar with a string in it. How does I
> access the n'th character? I am looking for the perl equivalent of
> 
> char c = myString[n];
> 
> Sorry if this is obivious, my nutsheell book didn't seem to have an
> answer.

But your perl doc does :-)

   my $string  = 'comp.lang.perl';
   my $C = substr $string, 0, 1;      # $C got the first one
   my $Perl = substr $string, 10;     # $Perl takes care the rest :-)

perldoc -f substr
perldoc perlfaq4:

HTH,

-- 
-hasan-
uhm, no more sig(h)


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

Date: 13 Jun 1999 00:06:38 GMT
From: hasant@trabas.co.id (Hasanuddin Tamir)
Subject: Re: Calculating weekday given year, month and day
Message-Id: <slrn7m45mr.791.hasant@borg.intern.trabas.co.id>

On Fri, 11 Jun 1999 15:37:20 -0400, Ed Bogart <e.h.bogart@larc.nasa.gov> wrote:
> Gregory Snow wrote:
> > 
> > In article <7jq986$7g1$1@nnrp1.deja.com>,  <perl_beginner@my-deja.com> wrote:
> > >    what is the most efficient way to calculate the weekday (sunday=0,
> > >monday=1 ...) given the year, month, and day without using the module
> > >provided by perl (i.e using arithmatics and algorithm)? Any suggestion?
> > >
> > 
> > Another approach (that doesn't require any modules and the overhead
> > that comes with them) is:
> > 
> >   $day_of_week = ( dmy_to_julian( $day, $month, $year ) + 1 ) %7;
> > 
> > where dmy_to_julian is a good julian day converter (I use the one
> > available at the Perl Function Repository:
> > http://moiraine.dimensional.com/~dgris/perl/pfr/ ).
> > 
> 
> Well I tried it and got;
> 
> Undefined subroutine &main::dmy_to_julian called at TestIF line 10.
> 
> Line 10 is "$day_of_week = ( dmy_to_julian( $day, $month, $year ) + 1 )
> %7"

The respond says that subroutine dmy_to_julian
is defined at the url above.

HTH,

-- 
-hasan-
uhm, no more sig(h)


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

Date: Sat, 12 Jun 1999 10:24:02 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: Calculating weekday given year, month and day
Message-Id: <376b30c0.4699898@enews.newsguy.com>

On Fri, 11 Jun 1999 15:37:20 -0400, Ed Bogart
<e.h.bogart@larc.nasa.gov> wrote:

>Gregory Snow wrote:
>> 
>> In article <7jq986$7g1$1@nnrp1.deja.com>,  <perl_beginner@my-deja.com> wrote:
>> >    what is the most efficient way to calculate the weekday (sunday=0,
>> >monday=1 ...) given the year, month, and day without using the module
>> >provided by perl (i.e using arithmatics and algorithm)? Any suggestion?
>> >
>> 
>> Another approach (that doesn't require any modules and the overhead
>> that comes with them) is:
>> 
>>   $day_of_week = ( dmy_to_julian( $day, $month, $year ) + 1 ) %7;
>> 
>> where dmy_to_julian is a good julian day converter (I use the one
>> available at the Perl Function Repository:
>> http://moiraine.dimensional.com/~dgris/perl/pfr/ ).
>> 
>
>Well I tried it and got;
>
>Undefined subroutine &main::dmy_to_julian called at TestIF line 10.
>
>Line 10 is "$day_of_week = ( dmy_to_julian( $day, $month, $year ) + 1 )
>%7"

Did you include the dmy_to_julian function from the Perl Function
Repository (see above for URL)?

Marcel



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

Date: Sat, 12 Jun 1999 10:23:59 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: comparing substrings of array values
Message-Id: <37682c3b.3542453@enews.newsguy.com>

On Fri, 11 Jun 1999 16:53:50 +0200, Markus Banach
<h0444vcs@rz.hu-berlin.de> wrote:

>Dear participants,
>
>I have an array of string values and
>I want to compare a substring of these strings.

Could you please rephrase that and also say what it is you want to do
in German? Also, what is it that this program is actually supposed to
do? There may be a more straightforward approach...

>
># an @bernd array with string values exists

Can you give an example of this array; it's easier to know what you
want to do when sample data is available.

>
>$y = 1;
>
>for ($i = 0; $i <= $x ; $i++) {

If $x contains the number of elements in @bernd, you'll have a problem
with the last element, since bernd[i+1] will then refer to nonexistent
data.

BTW, did you use the following:

#!/usr/bin/perl -w
use strict;

Makes finding errors easier.

>
>    if ( $bernd[$i] eq $bernd[$i+1] ) {
>    # at this stage the substrings instead of the whole string
>    # should be compared
>    # the substring starts with any single digit or letter and ends
>    # with the first space char, in other words :
>    # $_ =~ /^[a-zA-Z0-9]*\s/
>
>    # if true, $bernd[$i] and $bernd[$i+1] should get the same $y number

What is the meaning of $y?
>
>    # (starting from 1) at the beginning
>    }
>
>    else {
>    #increase the $y
>    $y++;
>    # $bernd[$i+1] gets the new $y
>    # compare substrings of $bernd[$i+1] and $bernd[$i+2] ...
>         }
>
>            }
>
>Does someone of you know how that works ?

Marcel



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

Date: 13 Jun 1999 00:06:12 GMT
From: hasant@trabas.co.id (Hasanuddin Tamir)
Subject: Re: defined() and my variables
Message-Id: <slrn7m3vuh.6t5.hasant@borg.intern.trabas.co.id>

On Fri, 11 Jun 1999 12:17:27 GMT,
cmertz@my-deja.com <cmertz@my-deja.com> wrote:
[snip]

> I expected %h to go completely out of scope when
> func() returns. It appears that some symbol
> reference is still remaining, because defined
> acts differently between the first and third call.

[snip]

perldoc -f defined:

   Currently, using defined() on an entire array or hash
   reports whether memory for that aggregate has ever
   been allocated.  So an array you set to the empty list
   appears undefined initially, and one that once was full
   and that you then set to the empty list still appears
   defined.

HTH,

-- 
-hasan-
uhm, no more sig(h)


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

Date: Sat, 12 Jun 1999 10:59:03 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Definition of words in Perl and POSIX
Message-Id: <376737fd.3932575@news.skynet.be>

Abigail wrote:

>--    [\w-]  ==>  [A-Za-z0-9_-]
>
>But that doesn't help \b.

Indeed. On many definitions (e.g. parts of email addresses, see the
RFC's), hyphens MAY NOT begin or end a "word". So the problem doesn't
really occur in that case.

OTOH, allowing people to create their own run-time versions of what
constitutes "\w" seems like it would be an interesting addition, to me.
It would allow you to properly process ISO-Latin 1 text with accented
characters (Unix text) on a Mac. That is now impossible using "locale"
alone. Or text in other languages with different character sets, such as
Polish or Turkish.

	Bart.


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

Date: 12 Jun 1999 11:43:23 GMT
From: twarren10@aol.com (Twarren10)
Subject: disalowing words
Message-Id: <19990612074323.22857.00000762@ng-fu1.aol.com>

I have what seems to be a relativly simple problem, but I cannot find the
answer in the books. I want to cut off to a "not allowed" message anyone who
enters the 8 or 9 words which are unacceptable to some people. I have it set
with a long list of elsif statements, but I remember reading this can be done
on one line with a comma or something to that nature? can anyone enlighten me
how to avoid the long list of "elsif" statements for each word I want to
exclude. Thanks in advance.



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

Date: 13 Jun 1999 00:06:26 GMT
From: hasant@trabas.co.id (Hasanuddin Tamir)
Subject: Re: File Locking
Message-Id: <slrn7m411g.6t5.hasant@borg.intern.trabas.co.id>

On Fri, 11 Jun 1999 14:39:16 -0500,
Mike Sanders <msanders@thetangledweb.net> wrote:
> I'm stumped on this flocking
> 
> I'm trying to use this test
> 
> while(!flock(FILEHANDLE,2)){
>     sleep 1
> }
> Do Stuff

And you wait forever, at least, as long as
the other process holds the file is running.

> or used this test
> 
> if(flock(FILEHANDLE,2)){
>     Do Stuff
> }

same above, and what about add this:

You need non blocking mode to get immediate status,
and check the $!. Again, check the return value.

   use Fcntl ':flock';
   flock FILEHANDLE, LOCK_EX|LOCK_NB or die "can't lock: $!";


HTH,

-- 
-hasan-
uhm, no more sig(h)


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

Date: Sat, 12 Jun 1999 10:24:01 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: File Uploading via html form
Message-Id: <376a2fd8.4467774@enews.newsguy.com>

On Fri, 11 Jun 1999 15:22:11 GMT, Ryan Corder <uucon@my-deja.com>
wrote:

>I am currently designing a site that will allow users to upload image files
>that can be viewed on their page as soon as they upload them.  I have
>been working with cgi-lib.pl with no success.

If you are using Perl 5, there is CGI.pm, which is cgi-lib.pl's
successor. It is well documented in itself, but there's also a book by
the module's author: Official Guide to Programming with CGI.pm by
Lincoln Stein.

>I understand the process
>of uploading the files, but is there a way to limit only files with certain
>extensions to be uploaded (ie. .gif & .jpg) ?  I understand that this will
>probably have to be coded into the cgi file because cgi-lib.pl cannont
>filter file types on its own.

Specifically on p.152 of that book, the author gives an example of how
to determine the file name and length of what the user tried to
upload. So before saving the file somewhere on your server you could
check the file's extension.

I could type in the program, but I'd have to test it first to make
sure there aren't any typos, and I'm not sure if it's ok to take a
program 1:1 from a book.

HTH

Marcel



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

Date: Sat, 12 Jun 1999 10:24:03 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: Form Redirection
Message-Id: <376c33fe.5529330@enews.newsguy.com>

On Fri, 11 Jun 1999 11:46:05 -0700, David <davidf@gaylordusa.com>
wrote:

>
>    @pairs = split(/&/, $ENV{'QUERY_STRING'} ); # GET Method
>
>    foreach $pair (@pairs) {
>        ($name, $value) = split(/=/, $pair);
>
>        $value =~ tr/+/ /;
>        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>        $name =~ tr/+/ /;
>        $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>
>        $FORM{$name} = $value;
>    }
>
>
>    $location = $FORM{'URL'};       # Use the field named "URL".
>    print "Location: $location\n\n";    # Voila!
>

Wow, you're thorough in your crossposting.

There's no </FORM> tag on your page.

Also, you could write the above as:

use CGI qw(:standard);
print redirect(param('URL'));

Although it does mean pulling in a large module.


Or (sorry for posting this in a Perl group), you could dispense with
the script altogether and use JavaScript:

<SELECT onchange="if (this.selectedIndex > 0) {
window.location.href=this.options[this.selectedIndex].value; }">

HTH

Marcel



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

Date: Sat, 12 Jun 1999 10:23:58 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: HELP: Perl on Windows Platform???
Message-Id: <37672764.2303151@enews.newsguy.com>

On Sat, 12 Jun 1999 00:07:00 -0500, seong joon bae
<seongbae@students.uiuc.edu> wrote:

>Hi everyone,
>I know that in Unix, you have to put something like....
>#!/usr/local/bin/perl in order to run CGI script.
>But how about Windows 9x?
>What do you put on the first line in order to run CGI script?
>

First of all, I think you should phrase this "to run a Perl script",
or rather "Perl program". CGI is a protocol, it can't do anything by
itself.

You should use the same line as in Unix. To use Perl programs for CGI
under, say, IIS or Personal Web Server, you'll probably give them the
extension .pl and create an association on your server to run the Perl
interpreter when something with that extension is requested. But
although the server then already knows to use Perl, you should still
use the shebang line, because (someone correct me if I'm wrong here)
Perl still looks for switches on the shebang (like -w or -T).

To make your scripts a little bit more portable between Win9x/NT and
Unix, you could place make C:\usr your Perl directory, so that the
interpreter itself resides in C:\usr\bin, then you can keep the
#!/usr/bin/perl you see in many scripts.

HTH

Marcel



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

Date: Fri, 11 Jun 1999 11:00:49 +0100
From: "Tobin" <Tobin@breathemail.net>
Subject: Re: I'm really peaved off!
Message-Id: <37622f29@news1.vip.uk.com>

Thanks for all your help! This one worked Johnothan - you genius 8-)

>
>Check you havent messed up your shebang (#! ) line.
>
>/J\
>--





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

Date: 12 Jun 1999 08:42:27 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: if (my $a=1) { } print $a; Why do i get undef an not "1" ??
Message-Id: <7jt6hj$ke2$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Abigail
<abigail@delanet.com>],
who wrote in article <slrn7m3ur0.3uj.abigail@alexandra.delanet.com>:
> The confusing part is that the expression following the 'if' is part
> of the block; even when it's outside the {}.

Now try it with while(){}...

These horrible misdesigns of Perl's bite us again and again...

Ilya


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

Date: Sat, 12 Jun 1999 10:39:24 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: importing comma-delimited data into perl?
Message-Id: <376e3883.6687005@enews.newsguy.com>

On Sat, 12 Jun 1999 15:42:15 +1000, Kate Roberts
<kate.roberts@lib.monash.edu.au> wrote:

>Dear all: I'm very new at this, so please excuse asking what might be
>obvious to others.
>
>I have a file containing comma-delimited data (exported from EXCEL),
>egmyfile...	"field1-wanted later","field2","field3-wanted"
>	        "field1-wanted later","field2","field3-wanted"
>	        "field1-wanted later","field2","field3-wanted"
> which I want to bring into perl, filter out most of the fields, and
>then output the fields of interest.
>
>I had thought that since you can assign separate fields to a list-array
>as follows:
>@listarray = ("field1-wanted later","field2","field3-wanted");
>
>that it might also be possible to first put each line from the file into
>a scalar, and then replicate the pattern above using that scalar
>eg
>open (FILEHANDLE, "myfile");
>while ($scalar1 = <FILEHANDLE>) {
>chomp $scalar1;
>@listarray1 = ($scalar1);     #This line should be equivalent to above 

Just because it looks the same as the @listarray you declare above
when $scalar1 is interpolated, doesn't mean Perl is actually
evaluating the expression. You probably want to use split.

HTH

Marcel



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

Date: Sat, 12 Jun 1999 11:32:40 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: interesting problem involving query
Message-Id: <7jtgf4$f6c$1@xenon.inbe.net>

In article <7jrf0b$3pv$1@nntp4.atl.mindspring.net>, "marktoth" <marktoth@mindspring.com> wrote:
[snip]
>In other words I want to check to see if the last character is an invalid
>character (the / character)
>if it is there I want to cut it off of the end
[snap]

$querytype =~ s#/$##;

And read up on the 's' function for any further "parsing" question,

Michel.


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

Date: Sat, 12 Jun 1999 10:59:00 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Intersection of SEVERAL ( eg. 5 -> ) lists
Message-Id: <37643359.2744712@news.skynet.be>

Thomas Weholt wrote:

>Perhaps I didn`t make it clear that I need to compute the intersection
>of more than 4-5 lists, often 10-12. And this varies. 
>
>It is part of a "complex" search-engine. 

How do you generate your lists? I assume you do a search for a keyword,
add your results as keys for a hash (as in the FAQ), and then repeat
with the next keyword, etc.

Simply incrementing the value of a hash will do. 

	foreach (@keyword) {
		my @result = &search($_);
		foreach (@result) {
			$score{$_}++;
		}
	}
	@intersection = grep { $score{$_} == @keyword } keys %score;

You may or may not want to ignore results where not all keyworsds have
been found. If you don't, and you want smarter results, a weight could
be assigned to each keyword, e.g. the inverse of the number of files the
word was found in. Simply sort the results in inverse order of score.

	foreach (@keyword) {
		my @result = &search($_);
		next unless @result;
		my $weight = 1 / @result;
		foreach (@result) {
			$score{$_} += $weight;
		}
	}
	@output = sort { $score{$b} <=> $score{$a} } keys %score;

	Bart.


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

Date: Sat, 12 Jun 1999 10:23:57 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: Linus Torvalds and Carmen Electra?
Message-Id: <3765263c.2007216@enews.newsguy.com>

On Fri, 11 Jun 1999 14:20:59 -0400, Greg Bartels <gbartels@xli.com>
wrote:

>I wouldn't worry too much, Marcel's recent posts
>shows more interest in being hall monitor than
>pointing anyone in a helpful direction.
>so its not likely you'd ever get some useful information out of him.

You never know, one day...

I'm (like most people) learning, but if there's something I can
answer, I will. However, I'm also trying to catch up with the
newsgroup, with hundreds of messages a day, and there are just too
many off-topic posts or posts from people who should just have RTFM.

"Hall monitor"... I like that.

Will try to balance posts in favor of informative ones in the future.

Marcel



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

Date: 13 Jun 1999 00:06:17 GMT
From: hasant@trabas.co.id (Hasanuddin Tamir)
Subject: Re: multiple match & replace regexp
Message-Id: <slrn7m3vvq.6t5.hasant@borg.intern.trabas.co.id>

On Fri, 11 Jun 1999 19:18:32 +0200, Ondrej Palkovsky <xpalo03@vse.cz> wrote:
> regurg wrote:
> 
> > What I don't know, however is this: what if I want to
> > replace $1 ... $3 with something else? Analagous to this
> > (which doesn't work):
> >      if (/...( )...( )...( )/) {
> >         $1 = "foo";
> >         $2 = "bar";
> >         $3 = "smar";
> >      }
> > 
> > I feel sure this has been answered before, but I
> > haven't been able to come up with a good search for
> > this in the archives :-(.
> 
> What about 
> s/(...) (...) (...) /$1foo$2bar$3smar/;
> 

search for `subroutine substitution'.
shortly, you need a subroutine to process
each match found.

   s/...(MATCH1|MATCH2).../a_function($1)/e

or just,

   s/...(MATCH).../a_function($1)/e

if they have same pattern.

HTH,

-- 
-hasan-
uhm, no more sig(h)


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

Date: Sat, 12 Jun 1999 06:56:51 GMT
From: sponsorfind@my-deja.com
Subject: New Website Resource (Perl, JAVA, CGI, VB, JavaScript, HTMLScript, Sponsors)
Message-Id: <7jt0bh$415$1@nnrp1.deja.com>

New Website Resource (Perl, JAVA, CGI, VB, JavaScript, HTMLScript,
Sponsors)

There is a new site that has finally put together
a COMPLETE resource for every webmaster!

www.sponsorfind.com

SponsorFind.com has the info you need on:
Sponsors
Advertisers (banners, how to make money on your
website)
Perl
CGI
Java
JavaScript
HTML
HTMLScript
VB
SponsorFinds OWN scripts (TOTALLY FREE)

Want to increase your hits? Find that domain or
sub-domain host? Help getting those scripts
installed? or just want to start making the cash
from your hard work?

VISIT WWW.SPONSORFIND.COM


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 12 Jun 1999 11:08:53 +0200
From: Gisle Aas <gisle@aas.no>
Subject: Re: Odd/Even Numbers?
Message-Id: <m3909pwztm.fsf@eik.g.aas.no>

abigail@delanet.com (Abigail) writes:

> Tom Christiansen (tchrist@mox.perl.com) wrote on MMCX September MCMXCIII
> in <URL:news:37613ad3@cs.colorado.edu>:
> <>      [courtesy cc of this posting mailed to cited author]
> <> 
> <> In comp.lang.perl.misc, 
> <>     Brent Singers <brent.s@ihug.co.nz> writes:
> <> :Is there any way of Perl telling if a number is odd or even?  I have a
> <> :script where I need do do one thing if a numerical result is even, and
> <> :something if it is odd...
> <> 
> <> Either the successful completion of basic arithmetic courses in grammar
> <> school is no longer a requirement for awarding our children access to
> <> computers, or else you are a curious and innovative soul inquiring after
> <> creative approaches of a more idiomatically perlian bent to this most
> <> trivial of all possible problems.  As it would be severely depressing
> <> if the former explanation were the root cause of your query, the latter
> <> must then be taken as the actual case.  I shall consequently assume then
> <> that you are not a hopeless idiot and instead present you with some more
> <> interesting solutions to digest.
> <> 
> <>      ( (1 x $integer) =~ /^(11)+$/ ? $even : $odd ) = 1;
> <> 
> <> or
> <> 
> <>      ( (1 x $integer) =~ /^(1+)\1$/ ? $even : $odd ) = 1;
> <> 
> <> or
> <> 
> <>      ( ($integer / (1 << 1)) =~ /\.5$/ ? $odd : $even) = 1;
> <> 
> <> or:
> <> 
> <>     ($integer =~ /[13579]$/ ? $odd : $even) = 1;
> <> 
> <> or 
> <> 
> <>     (($integer & (1 << 0)) ? $odd : $even ) = 1;
> <> 
> <> or perhaps most obvious of all:
> <> 
> <>     sub odd { 
> <> 	my($n) = $_; 
> <> 	$n<=0 ? 0 : !even($n-1); 
> <>     } 
> 
> That should be:
>         $n <= 0 ? 0 : even ($n - 1);
> 
> <>     sub even { 
> <> 	my($n) = $_;
> <> 	$n<=0 ? 1 : !odd($n-1); 
> <>     }
> 
> That should be:
>         $n <= 0 ? 1 : odd  ($n - 1);
> 
> 
> You forgot one:
> 
>        sub is_even ($) {
>            my ($number) = abs shift;
>            my @answers  = (1, 0);
>            while (@answers < $number) {push @answers, @answers}
>            return $answers [$number];
>        }

What is wrong with

    sub odd { (.5*shift) =~ /\./ }

or if you feel very clever

    sub odd { vec(chr shift, 0, 1) }

-- 
Gisle Aas


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

Date: Sat, 12 Jun 1999 11:01:52 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Please Help!!
Message-Id: <376a3db3.5395117@news.skynet.be>

coneliberation@my-deja.com wrote:

>The cone liberation society needs your help. We are an international
>organisation dedicated to liberating traffic cones, an we're updating
>our webpages. 

Completely off-topic, but... why would you want to free traffic cones?
It seems to me like they are perfectly happy where they are.


Is this some Monty-Python-esque fun organization?

	Bart.


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

Date: Sat, 12 Jun 1999 10:36:01 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: problem with no text outputting from Perl CGI script (long, enclosure)
Message-Id: <376d36bc.6231370@enews.newsguy.com>

On Fri, 11 Jun 1999 22:07:28 -0500, "Ben Mullen"
<brutal@greenbaynet.com> wrote:

>I'm having troubles with a CGI script that feeds in a html document template
>and adds in information that it gets from the cgi querry.  Basically my
>problem is that I get no output from the script.  I'm not sure where I'm
>going wrong since I'm taking a crash corse on Perl and my job needs this
>done in a week.  Below is the script as I have it so far:
>
># !/usr/bin/perl -w
>
># --init
>use CGI qw(:standard escapeHTML);
>use Text::ParseWords;
>#define variables
>$cgistring = "default" ; #cgi string
>$index = "0000"; #indexed car number
>$cartype = "C"; #car type
>$workdir = "~/"; #working directory
>$htmlfile = "car.html"; #file template to be loaded
>$html = ""; #the html file itself
>$info=""; #file info handle
>$description = ""; #car description
>$mileage = ""; #mileage
>$price =""; #price
>$damage=""; #damage
>
>#parse cgi string
>$cgistring = $ENV{'QUERY_STRING'};
>$index = substr($cgistring,0,4);
>$cartype = substr($cgistring,3,1);
>
>#parse short description file
>$defile = $index . $cartype . "SH.TXT";
>open (filehandle, $defile);
>@descstuff = <filehandle>;
>$description = $descstuff[0];
>$mileage = $descstuff[1];
>$price = $descstuff[2];
>$damage = $descstuff[3];
>
>#parse html file
>open (TEMPLATE, cars.html);
>while (<TEMPLATE>)
>{
> $buffer .= $_;
>}
>$buffer =~ s/<!--cgi:description-->/$description/g;
>$buffer =~ s/<!--cgi:mileage-->/$mileage/g;
>$buffer =~ s/<!--cgi:price-->/$price/g;
>$buffer =~ s/<!--cgi:damage-->/$damage/g;
>$buffer =~ s/<!--cgi:index-->/$index/g;
>print $buffer;

That's a rather convoluted way of doing things. For example, when
looking at the QUERY_STRING, you rely on the car information being in
a specific position. What if you change the HTML form to include some
other field? Then the car type most likely won't be in those
positions, and you have to rewrite the program. Also, you don't check
for URL-escaped characters (%20 for space, for example).

You already use the CGI.pm to do the hard work for you; if the form
field with the car type is called "cartype", just use
param('cartype').

Also (sorry if I didn't spot it) where are you actually using
Text::Parsewords? You pull it in, but don't use any of it's
functionality.

As for filling in the template, there are easier ways of doing that as
well. Have a look at Text::Template (on CPAN).

HTH

Marcel



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

Date: 10 Jun 1999 07:57:46 -0700
From: Christopher Mahmood <chris@oogabooga.worldhq.org>
Subject: Re: Telnet monitor
Message-Id: <x73e006r2t.fsf@oogabooga.worldhq.org>

bletch!  the auth keyword will do this for syslogd--see 'man 5 syslog.cong'.
-ckm


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

Date: 12 Jun 1999 01:21:40 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Verifying date data
Message-Id: <slrn7m3vk0.3uj.abigail@alexandra.delanet.com>

Larry Rosler (lr@hpl.hp.com) wrote on MMCXI September MCMXCIII in
<URL:news:MPG.11cb4490afd9288989bc7@nntp.hpl.hp.com>:
"" 
"" #!/usr/local/bin/perl -w
"" use strict;
"" 
"" sub isdate ($$$$$$) {
""     6 == grep { defined } @_[0 .. 5] or return;
""     my ($sec, $min, $hour, $day, $mon, $year) = @_;
""     my @m_day = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
""     $m_day[1] = 29 unless $year % 4; # OK from 1901 through 2099.
""        0 <  $year && $year < 200
""     && 0 <= $mon  && $mon  < 12
""     && 0 <  $day  && $day  <= $m_day[$mon]
""     && 0 <= $hour && $hour < 24
""     && 0 <= $min  && $min  < 60
""     && 0 <= $sec  && $sec  < 60
"" }


It doesn't deal with leap seconds!


Abigail
-- 
perl -wle 'print "Prime" if (0 x shift) !~ m 0^\0?$|^(\0\0+?)\1+$0'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 12 Jun 1999 09:03:34 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Where is sendmail on NT using Perl
Message-Id: <7jt7p6$cn$1@gellyfish.btinternet.com>

On Fri, 11 Jun 1999 21:06:11 GMT diVirgil wrote:
>
> if u find an SMTP server...
> use the LWP or libwww mod.
> 

Boing ! I think you mean that you mean Net::SMTP which is part of the
libnet bundle available from CPAN.  However you probably want to read
what it is says in the FAQ about mailing :

perldoc perlfaq9

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 5971
**************************************

home help back first fref pref prev next nref lref last post