[16075] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3487 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 26 21:10:59 2000

Date: Mon, 26 Jun 2000 18:10:48 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <962068248-v9-i3487@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 26 Jun 2000     Volume: 9 Number: 3487

Today's topics:
    Re: Number of Unique Values (Charles DeRykus)
    Re: Number of Unique Values <cghansen@micron.com>
    Re: Number of Unique Values <cghansen@micron.com>
    Re: Number of Unique Values (Tad McClellan)
    Re: perl 5.6: bug with -0777 slurping? <sumus@aut.dk>
        Perl and Sockets valarkin@my-deja.com
    Re: Perl and Sockets <rootbeer@redcat.com>
    Re: Perl and Sockets valarkin@my-deja.com
        Perl Chat Program Help malverian@hotmail.com
    Re: Perl for Palm ? <lauren_smith13@hotmail.com>
        perl/Tk again...what widget called a function? <alager@csuchico.edu>
        Persistence problem (Mark P.)
    Re: question about stat <tony_curtis32@yahoo.com>
    Re: regex - slurp file and extract email addresses <rootbeer@redcat.com>
    Re: regex - slurp file and extract email addresses (Abigail)
    Re: regex - slurp file and extract email addresses <csorensen@uptimeresources.net>
    Re: San Diego Perl Mongers and MP3.com (Mark P.)
    Re: Scheduled script <csorensen@uptimeresources.net>
    Re: Sys::Syslog & _PATH_LOG <d-weber@itg.uiuc.edu>
    Re: Sys::Syslog & _PATH_LOG <rootbeer@redcat.com>
    Re: Teen Volenteers WANTED (Craig Berry)
    Re: Telnet.pm module <rootbeer@redcat.com>
    Re: User's details <billy@arnis-bsl.com>
    Re: Web Hosting malverian@my-deja.com
        Who's the man? You can be(ginner) 8inches_manmeat@my-deja.com
    Re: Who's the man? You can be(ginner) newsposter@cthulhu.demon.nl
    Re: Who's the man? You can be(ginner) <alager@csuchico.edu>
    Re: Who's the man? You can be(ginner) (brian d foy)
    Re: Who's the man? You can be(ginner) <tony_curtis32@yahoo.com>
        Write to file problem <aranick@home.com>
    Re: Write to file problem <stephenk@cc.gatech.edu>
    Re: Write to file problem <rootbeer@redcat.com>
    Re: Write to file problem (Tad McClellan)
    Re: Write to file problem <stephenk@cc.gatech.edu>
    Re: Write to file problem (Clinton A. Pierce)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 26 Jun 2000 22:24:56 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Number of Unique Values
Message-Id: <Fws8xK.F2C@news.boeing.com>

In article <slrn8lfepv.ka1.abigail@alexandra.delanet.com>,
Abigail <abigail@delanet.com> wrote:
>Colby Hansen (cghansen@micron.com) wrote on MMCDXCI September MCMXCIII in
><URL:news:8j82bg$fck$1@admin-srv3.micron.com>:
>{} I'm wondering what the easiest way is to find the number of unique values in
>{} a list.
>
>    my $nr_of_unique = keys %{{ map{$_=>1 } @list}};
>


Just for the heck of it, an obfuscated solution: 

     my $nr_of_unique = keys %{@$_{@list}=() => $_};


Major side effects may include $_ damage.  


--
Charles DeRykus


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

Date: Mon, 26 Jun 2000 16:23:46 -0600
From: "Colby Hansen" <cghansen@micron.com>
Subject: Re: Number of Unique Values
Message-Id: <8j8l5p$3su$1@admin-srv3.micron.com>

PDL is Perl Data Language.  It's awesome for calculating things super fast.
For more information, go to http://www.aao.gov.au/local/www/kgb/perldl/


Lauren Smith wrote in message <8j8dgv$hvh$1@brokaw.wa.com>...
>
>Colby Hansen <cghansen@micron.com> wrote in message
>news:8j82bg$fck$1@admin-srv3.micron.com...
>> I'm wondering what the easiest way is to find the number of unique values
>in
>> a list.
>
>'perldoc -q unique' yields:
>
>perlfaq4: How can I extract just the unique elements of an array?
>
>Also try
>
>perldoc perldata
>
>>  Also, is there a way to do it using PDL?  Thanks!
>
>I have no idea what PDL is.
>
>Lauren
>
>
>




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

Date: Mon, 26 Jun 2000 16:21:08 -0600
From: "Colby Hansen" <cghansen@micron.com>
Subject: Re: Number of Unique Values
Message-Id: <8j8l0l$3si$1@admin-srv3.micron.com>

Here's a cool solution someone sent me...

my %unique = ();
@unique{@list} = (undef) x scalar @list;
my $uniquecount = scalar keys %unique;

This works where @list is your list of values.  For pdl,
@list = list $pdl is what you want..


Colby Hansen wrote in message
>I'm wondering what the easiest way is to find the number of unique values
in
>a list.  Also, is there a way to do it using PDL?  Thanks!
>
>




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

Date: Mon, 26 Jun 2000 19:32:57 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Number of Unique Values
Message-Id: <slrn8lfq19.8an.tadmc@magna.metronet.com>

On Mon, 26 Jun 2000 13:13:27 -0700, Lauren Smith <lauren_smith13@hotmail.com> wrote:
>
>Colby Hansen <cghansen@micron.com> wrote in message
>news:8j82bg$fck$1@admin-srv3.micron.com...
>> I'm wondering what the easiest way is to find the number of unique values
>in
>> a list.
>
>'perldoc -q unique' yields:
>
>perlfaq4: How can I extract just the unique elements of an array?


But not with 5.6 it doesn't.


Now it says:

   "How can I remove duplicate elements from a list or array?"


I wish POD had a place for synonyms...



>>  Also, is there a way to do it using PDL?  Thanks!
>
>I have no idea what PDL is.


Perl Data Language (mentioned in perlfaq[34].pod).


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 27 Jun 2000 00:15:29 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: perl 5.6: bug with -0777 slurping?
Message-Id: <aeg8ozr2.fsf@macforce.sumus.dk>

mike@excite.com () writes:

> Why is the empty string treated as true by the
> while loop?

This is no bug though. It's documented in eg. perlop. We were just discussing
it in "defined()"

-- 
Jakob


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

Date: Mon, 26 Jun 2000 22:03:04 GMT
From: valarkin@my-deja.com
Subject: Perl and Sockets
Message-Id: <8j8jud$1oe$1@nnrp1.deja.com>

Hello Everyone,
Here is a quick question. I have created a script in Perl *Dah I am
asking questions in a Perl Forum *grins* * I use Sockets in it. I can
connect to the server just fine. Here is what I must do, and the prob.

Get the first four bytes of data from the server. Unpack the data into
an int value and use that to receave the rest of the data. *hint it
tells the length of the text to come*

The code I have tried is bellow:

sysread(SOCKET, $len, 4);

$realNumber = int (unpack("S", $len));

read(SOCKET, $motd, $realNumber);

@lines = split(/\r/, $motd);

foreach $line (@lines)
{
    print "$line<p>";
}

close(SOCKET);

Note At the start of the code the Socket has been created and opened
with the file handel SOCKET. The data receaved by the program is then
split by each new line *and or return* and printed.

Is the code correct? I am unable to get the 4 bytes and unpack them
into the correct int value.

Thanks
-Thomas


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 26 Jun 2000 16:44:20 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Perl and Sockets
Message-Id: <Pine.GSO.4.10.10006261640360.23149-100000@user2.teleport.com>

On Mon, 26 Jun 2000 valarkin@my-deja.com wrote:

> sysread(SOCKET, $len, 4);

You should probably check that you got the four bytes you're expecting, to
be sure.

> $realNumber = int (unpack("S", $len));

You shouldn't need int(). And you probably want a different format than
"S", don't you think? Be sure to choose a format of the appropriate
endianness for your needs.

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 27 Jun 2000 00:14:21 GMT
From: valarkin@my-deja.com
Subject: Re: Perl and Sockets
Message-Id: <8j8rkf$7h4$1@nnrp1.deja.com>

In article <Pine.GSO.4.10.10006261640360.23149-
100000@user2.teleport.com>,
  Tom Phoenix <rootbeer@redcat.com> wrote:
> On Mon, 26 Jun 2000 valarkin@my-deja.com wrote:
>
> > sysread(SOCKET, $len, 4);
>
> You should probably check that you got the four bytes you're
expecting, to
> be sure.
>
> > $realNumber = int (unpack("S", $len));
>
> You shouldn't need int(). And you probably want a different format
than
> "S", don't you think? Be sure to choose a format of the appropriate
> endianness for your needs.
>
> Hope this helps!
>
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
>
>
I have tried most of the values for "S", V, v, I, i, M, m and the
others. How would I check to see if I got the 4 bytes? And if I didn't
get the data what should I do?


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 26 Jun 2000 21:55:42 GMT
From: malverian@hotmail.com
Subject: Perl Chat Program Help
Message-Id: <8j8jgl$1ja$1@nnrp1.deja.com>

I have created the following program in Perl... It is a chat program.
Currently when it connects it sends
"User " . $new->fileno . " Enters."
to the whole chat.

And sets a variable called $lastname to $new->fileno
When someone sends something, it will do $lastname: <whattheysent>
to everyone on the screen.

This is no good since everyone will have the same Name in the chat...
This is one thing I would like help with.. put in another way.. Is
there some kind of back use for fileno?
So I can tell what person is sending the data?

If this is hard to understand please ask..
Here is the script

_____________________________________________
use IO::Socket;
use IO::Select;
my $listen = IO::Socket::INET->new(Proto => 'tcp', LocalPort => 9000,
Listen => 1, Reuse => 1) or die $!;
my $select = IO::Select->new($listen);

my @ready;
while(@ready = $select->can_read)
{
	my $socket;
	for $socket (@ready)
	{
		if($socket == $listen)
		{
	    		my $new = $listen->accept;
			$select->add($new);
			my $socket;
			for $socket ($select->handles)
			{
				next if($socket==$listen);
				$socket->send("User " . $new-
>fileno . " Enters.\n");
				$lastuser = $new->fileno;
			}

		}
		else
		{
	    		my $line="";
			$socket->recv($line,80);
	    		if($line eq "")
			{
		};
		my $socket;
		for $socket ($select->handles)
		{
			next if($socket==$listen);
			if ($line =~ /^\#nick .+/i)
			{
				$lastuser = substr($line,5,-1);
			}
			elsif ($line =~ /^:.+/i)
			{
				$line = substr($line,1);
				$socket->send("$lastuser $line");
			}
			else
			{
				$socket->send("$lastuser: $line");
			}
		}
	}
}
}

1;
____________________________________________________


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 26 Jun 2000 15:01:25 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Perl for Palm ?
Message-Id: <8j8jrg$jlk$1@brokaw.wa.com>


D De Villiers <ddevilliers@lando.co.za> wrote in message
news:8j8fvv$3lq$1@ctb-nnrp2.saix.net...
> Hello, Everyone
>
> I just started programming my Palm device and is looking for a version of
> Perl for the Palm. Does anyone know please know if such a product exist
and
> where I can find it ?

perlfaq2: What machines support Perl?  Where do I get it?

And what's with that sig monstrosity?  Could you find some way to possible
trim it down to a moderately acceptable length?

Lauren





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

Date: Mon, 26 Jun 2000 16:04:21 -0700
From: Aaron <alager@csuchico.edu>
Subject: perl/Tk again...what widget called a function?
Message-Id: <3957E175.12E9C4CB@csuchico.edu>

I read it once before, but I can't locate it again now when I need to
know how to do it.  Within a generic function, how do I know what widget
called the function?
Thanks for the help.


Aaron




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

Date: Tue, 27 Jun 2000 01:08:39 GMT
From: perl@imchat.com (Mark P.)
Subject: Persistence problem
Message-Id: <3957fbed.937099447@news.ionet.net>

Hi, I have a multi-page form that I'm having some trouble with when I
try to use a persistant method, ie; CGI::Speedy, or FastCGI. Code
snippets follow, but the problem seems to be with CGI.pm not wanting
to parse out every instance of the form. Is there something I'm
missing? I've tried a lot of stuff, even to the point of creating a
package to do the processing on each instance. I'm fairly sure it has
to do with scoping somewhere, but where?

#!/usr/local/bin/speedy -- -wt300

use strict;
use CGI qw(:all);

my $query = new CGI;

my %sections = ();
my($sections,$params);

%sections = ( 'def' => { 'name' => 'Role',
                          'sub'  => \&define },
              'ques' => { 'name' => 'Company Profile',
                          'sub'  => \&quest },
              'fin'  => { 'name' => 'Product Type',
                          'sub'  => \&fin },
);

my @order = ('def','ques','fin');

if ($query->param('submit_end')) {
    end();
    }

my $action = (grep s/submit_//,$query->param)[0] || 'def';
foreach ($action) {
    pheader($_);
    &{$sections{$_}{sub}};
    pfooter();
}

sub pheader {
    my $cur = shift;
    my $tabs;
    die "Invalid section specified: $cur" unless
defined($sections{$cur});

    foreach (grep !/^$cur$/,@order) {
        $tabs .= submit('submit_' . $_,'Go to ' .
$sections{$_}{name});
    }

    print header,start_html,start_form('POST',$query->url);
    print p($tabs),hr;
}

sub pfooter {
    foreach (grep !/submit_/,$query->param) {
        print hidden($_);
    }

          end_form,end_html;
}

	pfooter is where the problem lies. When running standard I
have no problems, however, if I run it using CGI::Speedy or FastCGI,
sorry, don't have access to mod_perl, the problem pops up that no
hidden fields are inserted with each form instance. If you need the
rest of the code I'll post it. Ah hell, here it is just in case.

sub define {
    print p('What is your role in your company?');
    
    print p('Are you: ',br,checkbox(-name=>'pers_role',
                                    -value=>'ceo',
                                    -label=>'The CEO?'),
                        br,checkbox(-name=>'pers_role',
                                    -value=>'cto',
                                    -label=>'The CTO?'),
                        br,checkbox(-name=>'pers_role',
                                    -value=>'developer',
                                    -label=>'Just a developer?')
           );
    $query->delete('pers_role');
    print p(submit('submit_ques','Next >>'));
}

sub quest {
    print p('Enter your Company
Name:',textfield(-name=>'comp_name',-size=>20));
    $query->delete('comp_name');
    print p('Are you: ',br,checkbox(-name=>'comp_stock',
                                    -value=>'preipo',
                                    -label=>'Pre-IPO?'),
                        br,checkbox(-name=>'comp_stock',
                                    -value=>'nasdaq',
                                    -label=>'NASDAQ?'),
                        br,checkbox(-name=>'comp_stock',
                                    -value=>'notforprofit',
                                    -label=>'Not for Profit?')
           );
    $query->delete('comp_stock');
    print p(submit('submit_fin','Next >>'));
}

sub fin {
    print p('What kind of business? ',br,checkbox(-name=>'bus_type',
                                                  -value=>'product',
                                                  -label=>'Product'),
                                      br,checkbox(-name=>'bus_type',
                                                  -value=>'service',
                                                  -label=>'Service'),
                                      br,checkbox(-name=>'bus_type',
                                                  -value=>'web',
                                                  -label=>'Web'),
                                      br,checkbox(-name=>'bus_type',

-value=>'electronic',

-label=>'Electronic')
           );
    $query->delete('bus_type');
    print p(submit('submit_end','Finish >>'));
}

sub end {
    print header,start_html;
    foreach ($query->param) {
        $params .= li("$_ => ",$query->param($_));
    }
    print ul($params),end_html;
}



MP


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

Date: 26 Jun 2000 18:44:29 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: question about stat
Message-Id: <87pup4nh2a.fsf@limey.hpcc.uh.edu>

>> On Mon, 26 Jun 2000 16:45:39 -0400,
>> "Chen, Terrence" <terrchen@americasm01.nt.com> said:

> Hi, I have a question about the stat function in Perl 5
> when it comes to symbolic links.

> example: make ->
> /opt/mce/tools/hppa/mctools/ae01/public/gnumake

> It returns the stat information for
> /opt/mce/tools/hppa/mctools/ae01/public/gnumake but I
> want the stat information for make.

perldoc -f lstat

hth
t
-- 
"With $10,000, we'd be millionaires!"
                                           Homer Simpson


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

Date: Mon, 26 Jun 2000 16:36:17 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: regex - slurp file and extract email addresses
Message-Id: <Pine.GSO.4.10.10006261631520.23149-100000@user2.teleport.com>

On 26 Jun 2000, Chris Sorensen wrote:

> I need to figure out how to say .. count forward and backward from @ to
> the closest whitespace on either side .. 

That's neither necessary nor sufficient. This first one would get too much
text, while the second would get too little. Both of these are valid
e-mail addresses as they stand, though.

    I have spaces<fred&barney@redcat.com>

    <"fred and barney" (yes, this works!)@(believe me!) redcat.com>

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 26 Jun 2000 20:17:46 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: regex - slurp file and extract email addresses
Message-Id: <slrn8lftn7.ka1.abigail@alexandra.delanet.com>

Chris Sorensen (csorensen@uptimeresources.net) wrote on MMCDXCI September
MCMXCIII in <URL:news:3957C5C7.BC8F228C@uptimeresources.net>:
@@ Abigail wrote:
@@ > If there file is in free format, there isn't much you can do, as you
@@ > will have no idea where an email address might start, and where it
@@ > will end. Even newlines can be part of an email address.
@@ > 
@@ 
@@  the email addresses are all in the middle of a line - none are at the
@@ beginning or end (fortunately) 

Fortunally? I'd say unfortunally. Without futher knowledge of the format
of the file, it will be impossible to extract the right addresses.

@@ > ][ $address =~ /^\s+/\Q@\E/\s+$/
@@ > ][ This seems wrong since it could start at the first whitespace in the
@@ > 
@@ > You didn't even *try* this, did you? The above doesn't even compile.
@@ > 
@@ 
@@ 
@@ i did try it .. and no .. it doesn't compile .. that's why I am asking
@@ for help .. I'm totally unsure of the syntax .. I'm trying to build an
@@ expression using the pocket reference as my guide ..  I see that \s =
@@ whitespace and \S = non-whitespace .. 

Perhaps you should first learn Perl and learn what the syntax of regexes
are, before getting to the semantic details of regexes.

@@ I need to figure out how to say .. count forward and backward from @ to
@@ the closest whitespace on either side .. 
@@ 
@@ > You'd use \S, but what does "closest whitespace in front and at the back
@@ > of @" have to do with email addresses? Addresses can contain whitespace,
@@ > and can be delimited by other things than whitespace.
@@ > 
@@ 
@@ I haven't run across email addresses that contain whitespace .. that
@@ doesn't mean they can't .. it just means it's not usual.
@@ whitespace/something/@/something/whitespace is the best I could come up
@@ with ..

You haven't seen your own email address? Your From line says:
"Chris Sorensen <csorensen@uptimeresources.net>", and that's an
email address - including the spaces.

Now, probably "csorensen@uptimeresources.net" is valid too, but 
"<csorensen@uptimeresources.net>" is not, which shows that using white
space as delimiters ain't good enough.

Isn't ironic that your own email address shows that both your assumptions
are false?



Abigail
-- 
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
                                      print } sub __PACKAGE__ { &
                                      print (     __PACKAGE__)} &
                                                  __PACKAGE__
                                            (                )


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

Date: 26 Jun 2000 20:46:35 EDT
From: Chris Sorensen <csorensen@uptimeresources.net>
Subject: Re: regex - slurp file and extract email addresses
Message-Id: <3957F95B.43703DA7@uptimeresources.net>


> Perhaps you should first learn Perl and learn what the syntax of regexes
> are, before getting to the semantic details of regexes.
> 

listen .. you don't have to help ... I'm just hoping someone will help
me figure out the syntax ... why are you being nasty ? 

If I don't ask .. how will I lean the syntax of regular expressions .. I
keep checking all the books I have (camel, llama, pocketbook) and I'm
having a hard time understanding how to correctly describe an email
address .. so I asked a question


> You haven't seen your own email address? Your From line says:
> "Chris Sorensen <csorensen@uptimeresources.net>", and that's an
> email address - including the spaces.
> 
> Now, probably "csorensen@uptimeresources.net" is valid too, but
> "<csorensen@uptimeresources.net>" is not, which shows that using white
> space as delimiters ain't good enough.
> 
> Isn't ironic that your own email address shows that both your assumptions
> are false?

actually .. my email address works fine .. the expression pulls
<csorensen@uptimeresources.net> just fine .. I don't need the Chris
Sorensen label .. just the address .. and I'm happy to have it with < >
on it .. I pull all the addresses together, seperate them with commas,
and print them to the To: line .. <something@something.com>,
<somethingelse@something.com> works .. 

I haven't seen an email address that looks like this   joe
blow@something.net ... there's usually an _ between the joe and blow ..
the label notwithstanding ..


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

Date: Tue, 27 Jun 2000 00:55:08 GMT
From: perl@imchat.com (Mark P.)
Subject: Re: San Diego Perl Mongers and MP3.com
Message-Id: <3957fa9d.936763424@news.ionet.net>

On Mon, 26 Jun 2000 20:21:04 GMT, remove_this_prefix_adms1@cts.com
(Garrett Casey) wrote:

>Open Invitation:
>
>MP3.com http://www.mp3.com will be hosting the San Diego Perl Mongers
>meeting being held on JUNE 28, 2000 at 7:00pm.  Any Perl programmer in
>the San Diego area is welcome to attend.
>
	Anyway they would think about doing a web presentation also?
You could use Slideshow and maybe a Real Audio broadcast. It would be
very interesting and probably not that hard to setup.


MP


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

Date: 26 Jun 2000 18:13:25 EDT
From: Chris Sorensen <csorensen@uptimeresources.net>
Subject: Re: Scheduled script
Message-Id: <3957D575.ECE44937@uptimeresources.net>

the cron

these guys explain it pretty well.     
http://www.linuxdot.org/nlm/part1/cron.html

sinewave wrote:
> 
> Hi
> 
> I want to somehow run a script on a daily basis that will automatically
> generate and send e-mails where someone has posted their email details.
> What is the best way of doing this. It is Apache/UNIX. I don't suppose I
> want to have a program running all the time, so what is the best way of
> doing this. Is there a UNIX/Apache process that I can put my script
> into????
> 
> Thanks in advance
> 
> S


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

Date: Mon, 26 Jun 2000 18:22:34 -0500
From: Daniel Weber <d-weber@itg.uiuc.edu>
Subject: Re: Sys::Syslog & _PATH_LOG
Message-Id: <3957E5BA.C5B9A5DF@itg.uiuc.edu>

OK, I believe I have a solution, but I am totally unfamiliar with the process
for submitting problems & solutions like this to the perl developers. I'd be
glad to get some advice from those "in the know" (Tom? Jonathan?) how to
approach it.

The problem (for review):
Attempting to use the Net::Daemon package, I discovered that Syslog.pm was
reporting errors when the _PATH_LOG function was being called. This happend on
both IRIX 6.5.8 and AIX 4.3.3, and was caused by the lack of a _PATH_LOG
variable under both OS's. This is for perl-5.6.0.

The overall solution:
Both Syslog.pm and Syslog.xs have problems, at least as far as I can tell:
Syslog.pm in how it is using calls to the _PATH_LOG subroutine, and what it is
doing with those responses; Syslog.xs in how it is handling the lack of
_PATH_LOG information.

At first it appeared that all that was missing from Syslog.xs was the correct
#include file for the definition of _PATH_LOG. This is not the case, especially
for AIX where there is no _PATH_LOG macro in any .h file! The fix should be made
wholly without the inclusion of the _PATH_LOG macro.

The cause of the problem is that the _PATH_LOG() function croaks if there is no
defined macro _PATH_LOG. This should not happen, as Syslog.pm is expecting a
returned value from _PATH_LOG( ). Removing the croak allows the _PATH_LOG
function to return a NULL value which can then be captured by the Syslog.pm
module.

At one point, Syslog.pm uses the _PATH_LOG function in a "defined" context, and
using the "&" form of the function call:
	if ( defined &_PATH_LOG ) {
		$sock_type = 1;
	} else {
		return undef;
	}
Given that the Syslog.xs file has defined this function, the result of the
preceeding conditional is always true! This is not what is wanted. Instead these
statements should read:
	if ( defined _PATH_LOG( ) ) {
		$sock_type = 1;
	} else {
		return undef;
	}
as pointed out in a couple of posts here. Fixing this causes $sock_type to be
unassigned, and then later, the correct portion of code in Syslog::connect to be
executed.

The other use of &_PATH_LOG should also probably change to _PATH_LOG( ), though
there is no harm in leaving it as far as I can see.

What's a bigger question to me now is: Should all of those functions in
Syslog.xs croak? Or should they return NULL values if the macros aren't defined?


Below are the diffs between my Syslog.{xs,pm} original files and the working new
versions. I hope these help others struggling with the same problems.

-daniel




*** Syslog.xs.orig      Mon Jun 26 15:43:24 2000
--- Syslog.xs   Mon Jun 26 15:43:32 2000
***************
*** 550,556 ****
  #ifdef _PATH_LOG
        RETVAL = _PATH_LOG;
  #else
-       croak("Your vendor has not defined the Sys::Syslog macro _PATH_LOG");
        RETVAL = NULL;
  #endif
      OUTPUT:
--- 550,555 ----



*** Syslog.pm.orig      Mon Jun 26 15:53:03 2000
--- Syslog.pm   Mon Jun 26 15:53:29 2000
***************
*** 159,165 ****
      local($setsock) = shift;
      &disconnect if $connected;
      if (lc($setsock) eq 'unix') {
!         if (defined &_PATH_LOG) {
              $sock_type = 1;
          } else {
              return undef;
--- 159,165 ----
      local($setsock) = shift;
      &disconnect if $connected;
      if (lc($setsock) eq 'unix') {
!         if (defined _PATH_LOG() ) {
              $sock_type = 1;
          } else {
              return undef;
***************
*** 274,280 ****
          socket(SYSLOG,AF_INET,SOCK_DGRAM,$udp)           || croak "socket: $!"
;
          connect(SYSLOG,$that)                            || croak "connect: $!
";
      } else {
!         my $syslog = &_PATH_LOG                          || croak "_PATH_LOG n
ot found in syslog.ph";
          my $that = sockaddr_un($syslog)                  || croak "Can't locat
e $syslog";
          socket(SYSLOG,AF_UNIX,SOCK_STREAM,0)             || croak "socket: $!"
;
          if (!connect(SYSLOG,$that)) {
--- 274,280 ----
          socket(SYSLOG,AF_INET,SOCK_DGRAM,$udp)           || croak "socket: $!"
;
          connect(SYSLOG,$that)                            || croak "connect: $!
";
      } else {
!         my $syslog = _PATH_LOG()                          || croak "_PATH_LOG
not found in syslog.ph";
          my $that = sockaddr_un($syslog)                  || croak "Can't locat
e $syslog";
          socket(SYSLOG,AF_UNIX,SOCK_STREAM,0)             || croak "socket: $!"
;
          if (!connect(SYSLOG,$that)) {



-- 

]:o_ | Daniel E. Weber (d-weber@uiuc.edu) - ITG Information Technologies | _o:{
 |O =| 4311 Beckman Institute, 405 N Mathews, Urbana, IL, 61801 MC-251   |= O|
 |_o=| 217-244-3191 (off) * 217-244-6219 (fax) * 217-244-3074 (lab)      |=o_|
  \  |                              *moo*                                |  /


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

Date: Mon, 26 Jun 2000 16:46:23 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Sys::Syslog & _PATH_LOG
Message-Id: <Pine.GSO.4.10.10006261645450.23149-100000@user2.teleport.com>

On Mon, 26 Jun 2000, Daniel Weber wrote:

> OK, I believe I have a solution, but I am totally unfamiliar with the process
> for submitting problems & solutions like this to the perl developers. 

Use the perlbug program; it'll guide you through the process. Including a
patch will make you a hero. :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 26 Jun 2000 23:31:20 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Teen Volenteers WANTED
Message-Id: <slfpu8e4jev62@corp.supernews.com>

Abigail (abigail@delanet.com) wrote:
: Daniel Jones (danjones@crosswinds.net) wrote on MMCDXCI September
: MCMXCIII in <URL:news:39573795.45CAA5A8@crosswinds.net>:
: '' Do you know c-c++, HTML, JAVA, JAVASCRIPT, xml or any other computer
: '' languages?
: '' Are you a teenager?
: '' Are you a web guru?
: '' Wanna get recognition?
: 
: Translated:  want to work hard for no pay?

Hey, beats working hard for little pay at McDonald's.  Dan ought to invest
in a spell-checker, though.

-- 
   |   Craig Berry - http://www.cinenet.net/users/cberry/home.html
 --*--  "Beauty and strength, leaping laughter and delicious
   |   languor, force and fire, are of us." - Liber AL II:20


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

Date: Mon, 26 Jun 2000 16:26:25 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Telnet.pm module
Message-Id: <Pine.GSO.4.10.10006261623560.23149-100000@user2.teleport.com>

On Mon, 26 Jun 2000, thoma wrote:

> I use Telnet.pm module to communicate with terminal servers. Whenever,
> I do a Telnet session from my Perl CGI program, I get the following
> warning:
> 
> Argument "" isn't numeric in gt at bin/Telnet.pm line 2569.

What's Telnet.pm? It's not something derived from Net::Telnet, is it?
What's it doing in bin/Telnet?

I think you've got a broken installation of Net::Telnet, but I can't be
certain.

> Even though, it is harmless, it's kind of disturbing to see on the web
> browser. Is there any way this could be fixed or supressed? 

Probably fixed is better than suppressed. Have you looked at line 2569 of
your bin/Telnet.pm file to see what it's doing?

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/




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

Date: Tue, 27 Jun 2000 00:06:35 GMT
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: User's details
Message-Id: <8j8r5v$7c8$1@nnrp1.deja.com>

In article <8j8249$25e$17$3@news.t-online.com>,
  "Raphael Pirker" <raphaelp@nr1webresource.com> wrote:
> Ilja Tabachnik <billy@arnis-bsl.com> wrote in message
> news:8j5qag$1d8$1@nnrp1.deja.com...
> > In article <8j5n7s$oap$12$1@news.t-online.com>,
> >   "Raphael Pirker" <raphaelp@nr1webresource.com> wrote:
> > > Hi,
> > >
> > > I've heard that you can find out user's details using perl. In
which
> > array
> > > or variable are they stored? I'm aiming at:
> > >
> > > Browser
> > > PC
> > > OS
> > >
> > > Can I find those anywhere?
> > >
> >
> > What 'user' (or user of what) do you mean ?
> > There are plenty of entities which may be
> > described with that word.
> >
> > Ok, as long as you included a keyword 'browser'
> > and making some assumptions I guess you mean the following:
> >
> > "How can I get some details about HTTP client
> > in CGI environment using perl ?"
> >
> > If so, you need a CGI.pm module (AFAIK part of
> > stardard perl distribution).
> > Consult your local 'perldoc CGI' or visit
> > http://www.cpan.org/doc/manual/html/lib/CGI.html
> > to learn more.
> >
> I'll be using this for educational purposes, so I don't want to use
CGI.pm -
> I know I could, but the teacher doesn't like me doing stuff he doesn't
> understand... :-)
>

Ok, then a guess you primary intention is to learn CGI protocol.
If so, you should search for FAQs/newsgroups/manuals about CGI.

Perl isn't CGI related, you may write programs for CGI
environment in (almost) any programming language.

Good luck.
Ilja.





Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 26 Jun 2000 22:41:05 GMT
From: malverian@my-deja.com
Subject: Re: Web Hosting
Message-Id: <8j8m5v$3i9$1@nnrp1.deja.com>

Hahahahahahahahah
Can't say I do!
But.. if you want a free ISP -- www.freewwweb.com (No banner)
And a free shell account -- www.hobbiton.org

Good luck though =P


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 26 Jun 2000 22:11:44 GMT
From: 8inches_manmeat@my-deja.com
Subject: Who's the man? You can be(ginner)
Message-Id: <8j8keh$269$1@nnrp1.deja.com>

Hi, I need a little help with perl.  If you have any insight for me that
would be cool.  Thanks.

I have a text file that has a bunch of email addresses

foo.bar@domain.com
foo.bar@domain.com
foo.bar@domain.com
foo.bar@domain.com ...

etc.

For each 'foo.bar@domain.net' I want 'Foo Bar'.  In other words, for
'mike.smith@hotmail.com' I want 'Mike Smith'

It's part of a larger script that will be run on a Windows machine, so I
can't make system calls to unix commands. (right?)

Anyways, thanks in advance, G


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 26 Jun 2000 22:29:20 GMT
From: newsposter@cthulhu.demon.nl
Subject: Re: Who's the man? You can be(ginner)
Message-Id: <8j8lg0$hf3$1@internal-news.uu.net>

8inches_manmeat@my-deja.com wrote:

> I have a text file that has a bunch of email addresses

> foo.bar@domain.com

> etc.

> For each 'foo.bar@domain.net' I want 'Foo Bar'.  In other words, for
> 'mike.smith@hotmail.com' I want 'Mike Smith'

  Write a regular expression that matches the format used in your
list and use it to extract the foo and bar parts, then capitalize
the first character of both strings.  Then glue them together with
a space in between.

Erik



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

Date: Mon, 26 Jun 2000 16:01:35 -0700
From: Aaron <alager@csuchico.edu>
Subject: Re: Who's the man? You can be(ginner)
Message-Id: <3957E0CF.60F9364@csuchico.edu>



8inches_manmeat@my-deja.com wrote:

> Hi, I need a little help with perl.  If you have any insight for me that
> would be cool.  Thanks.
>
> I have a text file that has a bunch of email addresses
>
> foo.bar@domain.com
> foo.bar@domain.com
> foo.bar@domain.com
> foo.bar@domain.com ...
>
> etc.
>
> For each 'foo.bar@domain.net' I want 'Foo Bar'.  In other words, for
> 'mike.smith@hotmail.com' I want 'Mike Smith'
>
> It's part of a larger script that will be run on a Windows machine, so I
> can't make system calls to unix commands. (right?)
>
> Anyways, thanks in advance, G
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.

from STDIN:

while <STDIN> {
    $full_name=split /\@/;
    ($f_name, $l_name) = split /\./, $full_name;
    $proper_name = \U$f_name . ' ' . \U$l_name;
    print "$proper_name\n";
}
it uses a lot of variables but it's clear as to what it is doing.

Aaron



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

Date: Mon, 26 Jun 2000 16:13:54 -0800
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Who's the man? You can be(ginner)
Message-Id: <brian-2606001613540001@dhcp-baytraining-141.cisco.com>

In article <8j8lg0$hf3$1@internal-news.uu.net>, newsposter@cthulhu.demon.nl wrote:

>8inches_manmeat@my-deja.com wrote:

>> For each 'foo.bar@domain.net' I want 'Foo Bar'.  In other words, for
>> 'mike.smith@hotmail.com' I want 'Mike Smith'
>
>  Write a regular expression that matches the format used in your
>list and use it to extract the foo and bar parts, then capitalize
>the first character of both strings.

that would work if we knew something extra about the format.  otherwise,
a quick edit of the grammar in RFC::RFC822::Address will give the
desired results.

-- 
brian d foy
Perl Mongers <URI:http://www.perl.org>
CGI MetaFAQ 
  <URI:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>



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

Date: 26 Jun 2000 19:42:15 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Who's the man? You can be(ginner)
Message-Id: <87n1k8nee0.fsf@limey.hpcc.uh.edu>

>> On Mon, 26 Jun 2000 22:11:44 GMT,
>> 8inches_manmeat@my-deja.com said:

Bad Subject line.  Gives no indication of what this post
is about.

> foo.bar@domain.com foo.bar@domain.com foo.bar@domain.com
> foo.bar@domain.com ...

> For each 'foo.bar@domain.net' I want 'Foo Bar'.  In
> other words, for 'mike.smith@hotmail.com' I want 'Mike
> Smith'

    my $addr = 'tony.curtis@erewhon.com';
    my ($localpart) = split /@/, $addr, 2;
    my $name = join(' ', map {ucfirst} @{[ split /\./, $localpart ]});
                                                # warm LISP-like feeling
    print "$name\n";

perldoc -f split
perldoc -f map
perldoc -f ucfirst

> It's part of a larger script that will be run on a
> Windows machine, so I can't make system calls to unix
> commands. (right?)

Why would you want to here :-) ?

hth
t
-- 
"With $10,000, we'd be millionaires!"
                                           Homer Simpson


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

Date: Mon, 26 Jun 2000 23:20:06 GMT
From: Tim <aranick@home.com>
Subject: Write to file problem
Message-Id: <3957E3B6.ED21C9B1@home.com>

Hello,

I'm having a problem writing to a file. The problem is that I can't get
it to print each item of info, on a new line. Some lines it works, other
times it drops down two lines instead of one. Any suggestions would be
much aprecaited. 


Write code:

open (QF, ">/qfile$qfile.txt");
print QF "$Theinfo[0]\n";
print QF "$Theinfo[1]\n";
print QF "$Theinfo[2]\n";
print QF "$Theinfo[3]\n";
print QF "$Theinfo[4]";
print QF "$Theinfo[5]";
print QF "$Theinfo[6]";
print QF "$Theinfo[7]";
close (QF);


*All the info in the scalars is fine and can be worked with. 
I've tried lots of combinations of the \n's (all, none, half, ..) But 
none work. I think it might write differently if it's a single number
then a two or 3 diget number. (Thats what the info will be, numbers)


Thanks again,


Tim


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

Date: Mon, 26 Jun 2000 20:03:18 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: Write to file problem
Message-Id: <3957EF46.1D94DC9E@cc.gatech.edu>

2 questions first:
1) Are you sure your array entries don't contain newlines?
2) Have you set $\?

Maybe something like:

open (QF, ">/qfile$qfile.txt");
$\="\n";                # newline as record separator;
foreach(@TheInfo) {
  while(chomp);    # remove all newlines.  s/[\r\c]+$//g also works (I
think)
  print QF;
}
close QF;

would do the job

Tim wrote:

> Hello,
>
> I'm having a problem writing to a file. The problem is that I can't get
> it to print each item of info, on a new line. Some lines it works, other
> times it drops down two lines instead of one. Any suggestions would be
> much aprecaited.
>
> Write code:
>
> open (QF, ">/qfile$qfile.txt");
> print QF "$Theinfo[0]\n";
> print QF "$Theinfo[1]\n";
> print QF "$Theinfo[2]\n";
> print QF "$Theinfo[3]\n";
> print QF "$Theinfo[4]";
> print QF "$Theinfo[5]";
> print QF "$Theinfo[6]";
> print QF "$Theinfo[7]";
> close (QF);
>
> *All the info in the scalars is fine and can be worked with.
> I've tried lots of combinations of the \n's (all, none, half, ..) But
> none work. I think it might write differently if it's a single number
> then a two or 3 diget number. (Thats what the info will be, numbers)
>
> Thanks again,
>
> Tim

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




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

Date: Mon, 26 Jun 2000 17:16:38 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Write to file problem
Message-Id: <Pine.GSO.4.10.10006261714540.578-100000@user2.teleport.com>

On Mon, 26 Jun 2000, Stephen Kloder wrote:

> open (QF, ">/qfile$qfile.txt");

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.

> $\="\n";                # newline as record separator;
> foreach(@TheInfo) {
>   while(chomp);    # remove all newlines.  s/[\r\c]+$//g also works (I
> think)

What did this code do when you tested it?

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 26 Jun 2000 19:25:05 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Write to file problem
Message-Id: <slrn8lfpih.8an.tadmc@magna.metronet.com>

On Mon, 26 Jun 2000 23:20:06 GMT, Tim <aranick@home.com> wrote:
>
>I'm having a problem writing to a file. The problem is that I can't get
>it to print each item of info, on a new line. Some lines it works, other
>times it drops down two lines instead of one. Any suggestions would be
>much aprecaited. 


You must show us all of the code that we need to duplicate
the problem. You haven't. We don't know what is in @Theinfo.

If there are empty strings or newlines in there, then you
could maybe get strange output, but we don't know...


>Write code:
>
>open (QF, ">/qfile$qfile.txt");


You should always, yes *always*, check the return value from open():

   open (QF, ">/qfile$qfile.txt") or 
      die "could not open '/qfile$qfile.txt'  $!";


>print QF "$Theinfo[0]\n";
>print QF "$Theinfo[1]\n";
>print QF "$Theinfo[2]\n";
>print QF "$Theinfo[3]\n";
>print QF "$Theinfo[4]";
>print QF "$Theinfo[5]";
>print QF "$Theinfo[6]";
>print QF "$Theinfo[7]";


When you find yourself typing nearly the same thing many times,
take that as a clue that you are not programming smartly.


   foreach my $info ( @Theinfo ) {
      print QF "$info\n";
#      print QF "==>$info<==\n";  # delimit for debugging
   }


>close (QF);


Explicit close() is a Very Good Idea.


>. I think it might write differently if it's a single number
>then a two or 3 diget number.


No, that does not make any difference.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 26 Jun 2000 20:42:53 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: Write to file problem
Message-Id: <3957F88C.F32EB967@cc.gatech.edu>

Tom Phoenix wrote:

> > $\="\n";                # newline as record separator;
> > foreach(@TheInfo) {
> >   while(chomp);    # remove all newlines.  s/[\r\c]+$//g also works (I
> > think)
>
> What did this code do when you tested it?
>

Whoops.  I accidentally deleted the {} when I copied the code over.  I blame
it on too much C coding.

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




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

Date: Tue, 27 Jun 2000 00:48:08 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Write to file problem
Message-Id: <cRS55.11343$fR2.136975@news1.rdc1.mi.home.com>

[Posted and mailed]

In article <3957EF46.1D94DC9E@cc.gatech.edu>,
	Stephen Kloder <stephenk@cc.gatech.edu> writes:
> Maybe something like:
> 
> open (QF, ">/qfile$qfile.txt");
> 
> would do the job
> 

Pssst!  When opening a file, you should always check to make sure
it worked:

	open (QF, ">/qfile$qfile.txt") || die "$!";


-- 
    Clinton A. Pierce              Teach Yourself Perl in 24 Hours! 
  clintp@geeksalad.org         for details see http://www.geeksalad.org
"If you rush a Miracle Man, 
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

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


Administrivia:

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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 3487
**************************************


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