[8086] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1705 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 22 16:19:30 1998

Date: Thu, 22 Jan 98 13:00:22 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 22 Jan 1998     Volume: 8 Number: 1705

Today's topics:
        Apache:  Using SSI within perl script-generated web pag (Gail Hunn)
    Re: Basename with perl (NT) (Mark Meyer)
    Re: CGI / foreach loop question <dboorstein@shopcfn.com>
        CGI/Perl Consultant Needed <cyber@cybsearch.com>
    Re: Counting Backslashes <rootbeer@teleport.com>
        Finding the missing bracket? (Junbiao Zhang)
        Having Perl output to a specific html form field <orangutan@grungyape.com>
    Re: Need to send mail from web page as user other than  <rootbeer@teleport.com>
        None (Hal Wigoda                     )
        OPEN command problem <snorris@post.cis.smu.edu>
        RE: Outlook 97 and perl scripts <swein@sapient.com>
    Re: PERL Newbie Question (Wiley Scott McIntyre)
    Re: Perl vs C++ for CGI <jdporter@min.net>
    Re: POSIX (?) under perl for Win95 <jack_h_ostroff@groton.pfizer.com>
        re-route the standard-out from NT into Perl? (Christian Bobber)
    Re: sysread vs <> and others (Mike Linksvayer)
    Re: Trouble with a regex <jdporter@min.net>
    Re: URL-getting when User-Agent demanded (Charles Packer)
    Re: We ain't payin' shit! <dcbenton@sni.net>
        Win32 PERL Newbie question (Steven Savage)
        win32:ftp (Michael Hartley)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 22 Jan 1998 20:09:36 GMT
From: hunngai@fast.net (Gail Hunn)
Subject: Apache:  Using SSI within perl script-generated web page
Message-Id: <34c7a769.3220114@news.fast.net>

Hi.

I have a perl script that generates a web page, and the generated web
page includes a "virtual include" SSI.

At the moment, this doesn't work.  The dynamic page is generated, and
it contains the "virtual include" line as a comment, but it doesn't
execute it.

I have the mod_include module compiled into Apache, and SSI works fine
in my static pages.  The Options Includes statement is in the
access.conf file for my cgi directory.

Can anybody steer me towards a solution for this?  Thanks in advance.


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

Date: Thu, 22 Jan 1998 12:54:17 -0600
From: mmeyer@dseg.ti.com (Mark Meyer)
Subject: Re: Basename with perl (NT)
Message-Id: <mmeyer-ya02408000R2201981254170001@news.dseg.ti.com>

In article <01bd26b8$b0fdc160$0c07000a@dns1.filnet.fr>, "Olivier"
<PAYS@FILNET.fr> wrote:
>  would like to use the same command as basename (UNIX)
> 
> to obtain with a path like
> c:\folderA\folderB\file.txt  -->file.txt
> 
> This expression is not good why ???
> 
> $base=($File=~m|.*\\([^\\]+)$|)


Ooh, I think I know this!

When you do a match in a scalar context as you have, what is returned is
true or false, depending on whether the match succeeds.  Try doing the
match in a list context, to get everything matched by the parentheses:

($base) = $File =~ m|.*\\([^\\]+)$|

-- 
Mark Meyer                                  Net:   mmeyer@dseg.ti.com
Raytheon TI Systems, Inc.  Plano, TX       ICBM: 33d3'55"N 96d41'41"W
My opinions.  Mine!  How many times do I gotta explain it?
We are Chuckie of Borg.  We don't think resistance is such a good idea.


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

Date: Thu, 22 Jan 1998 15:31:03 -0500
From: Dan Boorstein <dboorstein@shopcfn.com>
Subject: Re: CGI / foreach loop question
Message-Id: <34C7AC87.3C5E1ED5@shopcfn.com>

Mike Heins wrote:
> 
> Robert Goodwin (goodwin@cuug.ab.ca) wrote:
> :
> : Hi there,
> :
> : I'm trying to do something really simple but don't know much about perl and
> : could find anything that talks about this specifically.  As in most for
> : interpreters I have an array of keys and contents.
> :
> : I want to go through the values of each of these and remove all the
> : whitespaces.  This is what I tried and doesn't seem to work.
> :
> : foreach $item (@fields) {
>                  ^^^^^^^ array
> :         $fields{$item}=~s/\s//g;
>           ^^^^^^^^^^^^^^ hash
> :         }
> 
> You can't access an array element with {}, it is a numbered
> array.
> 
> Not knowing which you are really trying to do, here are
> both correct ones. It is probably:
> 
> foreach $item (@fields) {
>     $item =~ s/\s+//g;
> }
> 
> \s+ will be more efficient than just \s.
> 

and don't overlook the amazingly quick tr:

foreach $item (@fields) {
    $fields{$item} =~ tr/ \n\t\r\f//d;
}

though not as clean in appearance always, it's tough to beat for
single character substitiution and deletions:

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

timethese(20000,
 {
  'i_s_m','$_ = "noun verbed pronoun adverbly period\n"; s/\s+//g;      
',
  'i_s_s','$_ = "noun verbed pronoun adverbly period\n"; s/\s//g;       
',
   'i_tr','$_ = "noun verbed pronoun adverbly period\n"; tr/
\n\t\r\f//d;',
  'r_s_m','$_ = "column1     column2     column3    \n"; s/\s+//g;      
',
  'r_s_s','$_ = "column1     column2     column4    \n"; s/\s//g;       
',
   'r_tr','$_ = "column1     column2     column4    \n"; tr/
\n\t\r\f//d;',
 }
);

Benchmark: timing 20000 iterations of i_s_m, i_s_s, i_tr, r_s_m, r_s_s,
r_tr...
     i_s_m:  4 secs ( 3.79 usr  0.26 sys =  4.05 cpu)
     i_s_s:  5 secs ( 3.83 usr  0.22 sys =  4.05 cpu)
      i_tr:  0 secs ( 0.55 usr  0.05 sys =  0.60 cpu)
     r_s_m:  2 secs ( 3.43 usr  0.30 sys =  3.73 cpu)
     r_s_s:  6 secs ( 5.00 usr  0.40 sys =  5.40 cpu)
      r_tr:  1 secs ( 0.57 usr  0.05 sys =  0.62 cpu)


dan boorstein


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

Date: Thu, 22 Jan 1998 13:21:20 -0600
From: Craig Sherwood <cyber@cybsearch.com>
Subject: CGI/Perl Consultant Needed
Message-Id: <34C79C30.4FF2@cybsearch.com>

Title:          CGI/Perl  Consultant (1)
Rate:		50hr-75Hr                     
Location:       Detroit, MI
Length:         3-6 months


Provides sever support UNIX to Netscape clients, develop and maintain
operational practices and procedures, support implementation of new
technology and  applications & monitor Web services.

Job Descripton/Responsibilities:
7 Must have exp. W/Directory Server systems:
1. CGI, Perl and Java or Javascript, and Expect programming skills
desirable.
2. Shell and Korn Scripting a strong plus
3. Network tuning.
4. Operations Standards (usage,  logs,  consumption trends,  tasks and
procedure's) 
5. Support and Services  (creating accounts,  applying patches,...) 
6. Project Planning (identify activities, identify requirements,
prioritize) 
7. Attitude,  Can do,  Done right the first time! 
8. Must be very familiar with common Internet protocols (SMTP, HTTP,
NNTP, DNS). 
9. Familiarity with UNIX security tasks and encryption  technologies a
plus. 


Strong Pluses:


7 Ability to manage vital information such as username, passwords,
certificates, e-mail addresses and contact information
7 Have strong knowledge of the LDAP protocol and know how to integrate
into many other systems such as NetWare NDS and Banyan Street Talk. 
7 Must know how to deploy Directory Server on a large scale distributed
intranets.

If you are interested in this position please contact  CyberSearch, Ltd. 
Renee Nichols @ Netscape Communication Corporation
Co/ CyberSearch,Ltd 
P-847-357-0200 or fax 847-357-0219 - 
Email: renee@cybsearch.com


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

Date: Thu, 22 Jan 1998 11:08:32 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: wchrist@flagmail.wr.usgs.gov
Subject: Re: Counting Backslashes
Message-Id: <Pine.GSO.3.96.980122110039.20494h-100000@user2.teleport.com>

On Wed, 21 Jan 1998 wchrist@flagmail.wr.usgs.gov wrote:

> I am trying to search a data file and return any words that have a
> backslash(\) in them, along with a count of the number of backslashes. 
> The backslashes, along with the next character are used to represent a
> diacritical character.	I am using the following code to do this:
> 
>     while (chop($nline = <FILE>)) {

That's not good! You're using the return value of chop. As a general rule,
the return value of chop is probably not what you want. I think you should
use code like this instead, using chomp instead of chop. 

    while (defined($nline = <FILE>)) {
	chomp $nline;
	...

>       $offset = ($nline =~ s/\\/\\/g);
> 
>       if($offset != 0){

Is $offset supposed to be the number of backslashes? (If it's a count, why
is it called "offset"?) Maybe you want this, which should be faster.

    next unless $count = $nline =~ tr/\\//;

> This method works most of the time, but some words are coming back with
> the wrong count.

I couldn't reproduce this problem. If you're using a version of Perl at
least as recent as 5.004, could you post a small example of code and data
which will show the problem you're having? Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 22 Jan 1998 14:21:48 -0500
From: junzhang@athos.rutgers.edu (Junbiao Zhang)
Subject: Finding the missing bracket?
Message-Id: <6a868c$nbj$1@athos.rutgers.edu>

Hi there,

	I was modifying a fairly big perl script and accidentally missed a
right bracket in a subroutine. The compiler complained about this but gave 
me no useful hint as it always pointed to the end of the script. Bracket 
matching in emacs didn't help either because of those weird regular
expressions(these caused, e.g. an extra right bracket to match a left 
parenthesis in a regular expression). I ended up doing a binary search
(inserting a right bracket at a place and compile) to identify the problem.

	Is there a better way to deal with such a problem? 

	Email preferred. Thanks in advance. 

--Junbiao


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

Date: Thu, 22 Jan 1998 15:42:58 -0500
From: "Franklin L. Petersen" <orangutan@grungyape.com>
Subject: Having Perl output to a specific html form field
Message-Id: <6a8auc$310$1@cletus.bright.net>

I have an html form, done in perl, that has a lot of fillins and check
boxes.

It has 2 submit buttons.

1 standard submit takes you to a "preview" and confirm form....no trouble
here.

the second, I would like it to read the fields, check boxes, and tally a
price depending on what it selected.  ( I already have it doing this)
but....instead of making a whole new page to tell them the price and all,
I'd rather have it print it to one of the current form boxes on the page
without touching/erasing anything else.

Can someone help.  I hope this is not easy common practice, but i cannot get
it to work.

Franklin

orangutan@grungyape.com




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

Date: Thu, 22 Jan 1998 10:59:16 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Michael O'Sullivan <osullm@cork.cig.mot.com>
Subject: Re: Need to send mail from web page as user other than "nobody"
Message-Id: <Pine.GSO.3.96.980122105554.20494g-100000@user2.teleport.com>

On Wed, 21 Jan 1998, Michael O'Sullivan wrote:

> I have a web page which sends a structured email to our helpdesk.
> 
> The problem is that I want the email to be sent as the user who
> completed the form, using their email address. 

Of course, there is no way in general to be sure that you have the right
email address of the person who is filling out the form. Or, for that
matter, that they have an email address at all! :-)

> Is there any way I can format the email AND have it sent from the user
> completing the form?

You can format the email (or any other data) within Perl. As far as
sending mail as if it were from any particular email address, if you can
do that with any other programming language, you can use the same
technique from Perl. Once you find out what the technique is, if you have
troubles implementing it in Perl, feel free to post again. Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Thu, 22 Jan 1998 13:58:54 -0600 (CST)
From: hwigoda@Mcs.Net (Hal Wigoda                     )
Subject: None
Message-Id: <199801221958.NAA04438@Jupiter.Mcs.Net>


A associate of mine has a cgi form and script
and he is getting the message "Document has no data".

The data aceepted by the form was not written to the flat file in his home 
directory.

An help.

Any help.




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

Date: Thu, 22 Jan 1998 14:43:33 -0600
From: "Scott Norris" <snorris@post.cis.smu.edu>
Subject: OPEN command problem
Message-Id: <6a8atv$srn$1@hermes.seas.smu.edu>

I have tried to edit files in one of my scripts; sort of a simple database
management project to benefit my school. However, my scripts crash. Among
other problems, it says I am using the wrong syntax on the OPEN command. I
have tried to understand what is wrong here, but I copied the syntax staight
from the camel book, so I don't see what's wrong. Here is what I ran:

&getdata

open LIST, "+>>/textbook/booklist.csv";

while (<LIST>) {
  if /$form{IDno}/ {
    s/<LIST>// or die "Can't delete record";
    $success = 1;
    last;
  }
}

Then, is the s/<LIST>// an acceptable way to erase a line in a data file? or
do I have to do something more complex.

Thank you for your time.

-Scott Norris




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

Date: Thu, 22 Jan 1998 15:11:21 -0500
From: Scott Weinstein <swein@sapient.com>
Subject: RE: Outlook 97 and perl scripts
Message-Id: <0685A427A719D11197BB00A024D3994502B52824@delphi.sapient.com>

Here is a program I'm working on at the moment. It's still in draft form
however.
It uses Win32::OLE to open up the outlook object and read from the
contacts list.


Let me know if you have any questions.

--Scott Weinstein
swein@sapient.com


================== CUT HERE ==============
#!/usr/bin/perl -w

#use strict;

=pod

=head1 NAME 

phone_print - print a credit card size listing of phone numbers

=head1 DESCRIPTION

This program reads from the Outlook contacts list to create 
a credit card sized list of phone numbers. Usefull if you don't own a 
pilot.
For best results:
Have outlook already started
Use a good printer (>= 600 dpi)

=head1 CAVEATS

This is pre-alpha software,
Please send bug-reports, 
  bug-fixes, 
  suggestions for enhancements, 
  enhancements, 
  or help on postscript to me.

I'd like to turn this program into a full-featured thing.

=head1 NOTES

todo:
 
 Add the ability to sort and group by categories. ie
 Family in one section
 Local friends in a section
 Bussiness contacts in another

 Add the abilty to selectivly not print some contacts

 Add area-code factorization.

=head1 AUTHOR

Scott Weinstein (swein@sapient.com)

=cut




my @c_list =  sort { uc($a->{name} ) cmp uc($b->{name}) }
Contact_List::contact_list();

#do 'd.pl';

@c_list or die ("unable to read contact info\n");
unlink ("t.ps");
open (F,">t.ps") || die ("Failed to open file $!\n");


my ($x,$contact,$n,$N,$line_counter,@X,%ps_opt);

$X[0] = { SYM => 80, NUM => 84 } ;
$X[1] = { SYM => 120, NUM => 124} ;

%ps = (
      );

print F <<"EOF";
%%!PS
%%BeginProlog
% 50 xmoveto, move horizontally to the 50th point on page
/xmoveto { currentpoint exch pop moveto } bind def
% Carrige Return
/CR { $ps{X} currentpoint exch pop moveto } bind def
% 5 down, moves down 5 points 
/down { -1 mul 0 exch rmoveto } bind def
% draw a horizontal line from $ps{X1} to $ps{X} at current vertical
position
% return to starting point after line is drawn
/xline { currentpoint 
	     $ps{X1} currentpoint exch pop  
	     $ps{X} currentpoint exch pop 
	     moveto lineto stroke 
	  moveto } bind def

/FSD { findfont exch scalefont def } bind def
/SMS { setfont xmoveto show } bind def

%%EndProlog

/LG $ps{l_font_size} /$ps{l_font} FSD 
/SM  $ps{s_font_size} /$ps{s_font} FSD 
LG
0 setlinewidth
$ps{X} $ps{Y} moveto
EOF

$line_counter = 0;
foreach $contact (@c_list)
{
  $phone_count = @{$contact->{phone_list}};
  print F $ps->new_line();

  if (defined $contact->{email} && ($phone_count %2 == 1))
  {
    
  

  for ($n=0 ;  $n <  ;  $n++ )
  {
    $N = $contact->{phone_list}->[ $n ];
    $x = $X[ $n % 2 ];

    if ( $n % 2 == 0)
    {
      $line_counter++;
      print F ($contact->{name}) $ps{X} LG SMS\t";
    }
    print F "($N->{code}) $x->{SYM} SM SMS ($N->{num}) $x->{NUM} LG
SMS\n";
  }
  print F "$ps{spacer_hight} down xline ";
  
  if ($line_counter > $ps{page_length} && $line_counter < (
$ps{page_length} + 3))
  {
    my $ltime = localtime();
    print F <<"EOF";
CR $ps{l_font_size} down
(---     Fold Here   ----    phone_print, created at $ltime   ---
Fold Here   ---- ) 
50 SM SMS
$ps{spacer_hight} down xline
EOF
    $line_counter = 0;
  }
}
print F "showpage\n%%EOF";
close F;

exit 0;

package PS;

sub new{
  my $s= 
  {
   X			    => 30,
   X1			    => 200,
   Y			    => 720,
   l_font		    => 'Helvetica',
   s_font		    => 'Helvetica-Oblique',
   l_font_size		    => 5,
   s_font_size		    => 3,
   spacer_hight		    => .8,
   page_length		    => 40,
  };
  return bless $s, shift;
}

sub new_line
{
  my $s = shift;
  return "CR $s->{l_font_size} down\n";
}


package Contact_List;


sub contact_list 
{
  my %phone_types = (
		     HomeTelephoneNumber	=> 'h',
		     BusinessTelephoneNumber	=> 'B',
		     MobileTelephoneNumber	=> 'c',
		     Home2TelephoneNumber	=> 'p',
		    );
  my $o = Outlook->new() or return () ;
  my $o_contacts = $o->GetNameSpace("MAPI")->GetDefaultFolder(10) or
return () ;

  my ($o_contact,$ii,$count,$o_ph,$pn,$pc,@contact_list);
  @contact_list = ();
  $count = $o_contacts->items->count;  
  for ($ii = 1;$ii < $count;$ii++)
  {
    my $c;
    $o_contact = $o_contacts->items($ii);
    $c->{name} = $o_contact->fullname ;
    $c->{email} = $o_contact->Email1Address;

    while ( ($o_ph,$pc) = each (%phone_types))
    {
      $pn = $o_contact->$o_ph();
      $pn =~ s/\((\d{3})\) /$1./;
      $pn =~ s/\s+//g;		
      if ( $pn ne '') 
      { 
	push @{$c->{phone_list}}, { num => $pn, code => $pc };
      }
    }
    if (defined $c->{phone_list} and  scalar( @{$c->{phone_list}}) > 0 )

    {
      push @contact_list, $c;
    }
  }

  return @contact_list;
}

package Outlook;
use Win32::OLE;

sub new {
  my $s = {};
  if ($s->{Ex} = Win32::OLE->new('Outlook.Application')) {
    return bless $s, shift;
  }
  return undef;
}

sub DESTROY {
  my $s = shift;
  if (exists $s->{Ex}) {
#    print "# closing connection\n";
#    $s->{Ex}->Quit;
    return undef;
  }
}
sub AUTOLOAD {
  my $s = shift;
  $Outlook::AUTOLOAD =~ s/^.*:://;
  $s->{Ex}->$Outlook::AUTOLOAD(@_);
}


1;

# -*- perl -*-

============================ CUT HERE =====================



> -----Original Message-----
> From:	Tony Arnold [SMTP:tony.arnold@mcc.ac.uk]
> I believe it ought to be possible to process mail folders etc., in
> Outlook 97 from a perl script. Has anyone done this? If so, I would
> appreciate seeing an example of the techinique.
> 
> Tony Arnold, University of Manchester, UK.



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

Date: Thu, 22 Jan 1998 19:13:36 GMT
From: mcintyres@hjc.cc.md.us (Wiley Scott McIntyre)
Subject: Re: PERL Newbie Question
Message-Id: <34c7999b.9935485@nntpserver.pppl.gov>

On Tue, 20 Jan 1998 16:39:52 -0500, comdog@computerdog.com (brian d
foy) wrote:

>In article <34c50e49.28426020@nntpserver.pppl.gov>, mcintyres@hjc.cc.md.us posted:
>
>>I am a real newbie to PERL.  I was wondering... I would like to
>>install PERL on our Sun Netra web server and would like to know where
>>I can get the latest version for Unix System 5 Release 4.  Then, I
>>would like to know how can I install it?
>
>go to <URL:http://www.perl.com>
>
>download the latest perl distribution (latest.tar.gz)
>
>gunzip and un-tar it.
>
>read the README.
>
Been there, done that.  I also found out that when we ordered our web
server, it didn't have a unix C compiler.  Where can I get and install
one of those.

Lately, It has been one step forward, two steps back.

Any additional help on this subject will, as always, be greatly
appreciated.

BTW, where would be the best place to install PERL on our server?



Best Regards,
Scott McIntyre

======================================================================
  HAGERSTOWN JUNIOR COLLEGE           E-MAIL: mcintyres@hjc.cc.md.us
  11400 ROBINWOOD DRIVE                PHONE: 301-790-2800 x327
  HAGERSTOWN MD 21742-6590 USA           FAX: 301-739-0737
======================================================================
                  Home Page: http://www.hjc.cc.md.us/
======================================================================


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

Date: Thu, 22 Jan 1998 14:04:34 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Perl vs C++ for CGI
Message-Id: <34C79842.7606@min.net>

If you are using a web server which can access and run your code without
launching a new process for each request (as CGI does unfortunately),
you stand to gain a lot, regardless of the language.  Netscape has its
NSAPI, M$ IIS has its ISAPI, WebSite from O'Reilly has WSAPI (which is
something of an extension to ISAPI), and Apache has a powerful API which
can allow access to/from Perl via a module called mod_perl.

Even if you stay with CGI, whether you realize much of a speed-up from
converting to C++ is very application-dependent.  You might not get
much, especially if the program loads, spits out some HTML with very
little processing, and exits; or stuff like connecting to other servers
over the network, reading and writing records to a database, or waiting 
for other processes to do their thing.
If, on the other hand, your program does a lot of its own cpu-intensive 
"chewing", then you may (or may not) get substantial speed-up from a
low-level language like C++.  Perl does certain things very efficiently
--
at least, more efficiently than you're likely to be able to whip up in
C++
-- such as regular expressions.

If you decide that C++ is the way to go, you don't have to sacrifice the
power of Perl.  You can call the Perl library in your C++ program, or
you
can create an interface to your C(++) code in Perl using XS.

Personally, I would have to have more reasons -- and with much more
compelling reasons than spead -- to rewrite a single line of Perl code
in
C++.  Just my $0.02.

John Porter




Jerry Davis wrote:
> 
> I have spent the last 2-3 months learning perl and I know why it is the
> language of choice for cgi.  I have written a fairly large script in perl
> (two 18K files, plus an assortment of smaller ones). I recently learned that
> c++ is a faster language for cgi programs. Since perl handles text
> manipulation so easily rewriting my code into c would be a tiresome chore.
> The question is:
> 
> How much speed increase is gained by using c instead of perl?
> (Note: memory is not a concern, only speed)
> Would you consider it worthwhile for the time required to rewrite huge
> sections of code?
> 
> Jerry


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

Date: Thu, 22 Jan 1998 13:53:41 -0500
From: "Jack H. Ostroff" <jack_h_ostroff@groton.pfizer.com>
To: Lynchqvctc <lynchqvctc@aol.com>
Subject: Re: POSIX (?) under perl for Win95
Message-Id: <34C795B5.D9C@groton.pfizer.com>

Lynchqvctc wrote:
> 
> I have a wonderful program that I'd like to run on my server (for a local
> historical society-- so I'm doing all gratis); my computer is a Win95, and a
> basic "Sambar4" server, with perl 5.003 build315.  My question is-- anyone know
> where "POSIX" is, or whether it will even be recognized under this build of
> perl? (Or... whether there is another build for Win95 that contains it?) I have
> searched docs, searched my file structure etc., and only find cryptic reference
> to POSIX (which I believe is related to UNIX).  The module is actully listed on
> CPAN... but it is one of a few that is not downloadable separately!  It seems
> to be my last barrier to running this program (an historical-picture
> archive)... I'd appreciate any constructive input/insight on this.
> Thanks.... Brian D-L,
Brian,

The POSIX module is not downloadable separately because is bundled with
Perl.  If you don't have it in your installation, you need to get a more
recent version of Perl.


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

Date: Thu, 22 Jan 1998 19:46:20 GMT
From: cbo@informatik.tu-chemnitz.de (Christian Bobber)
Subject: re-route the standard-out from NT into Perl?
Message-Id: <34c7a175.1129987@nntphost.hrz.tu-chemnitz.de>

Hallo,
I would call an  .EXE-program (NT) from my perl-script and analyse it
later in this calling perl-script. 

Now I use the system()-call and re-route the .EXE-output with the '>'
into a file. Then I open, analyse, close and delete this file.

Is there a better way to analyse the output from a called EXE-program?

Thanks for your help

Christian
------------------------------------------
Name :   Christian Bobber 
Org. :   gedas consult GmbH
Email:   Christian.Bobber@gedas.de


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

Date: 22 Jan 1998 11:04:23 -0800
From: ml@gondwanaland.com (Mike Linksvayer)
Subject: Re: sysread vs <> and others
Message-Id: <6a857n$121$1@shell3.ba.best.com>

In article <En6zCw.KK8@world.std.com>, Andrew M. Langmead <aml@world.std.com> wrote:
>For regular disk files, sysread will turn into a huge performance
>killer if the blocks you are reading are not multiples of the
>filesystems blocksize.

Are you saying that if my blocksize is 512 bytes and I do

$offset = 0;
$bytes = 2000;
while (sysread(F,$buf,$bytes,$offset)) {
   $offset += $bytes;
}

I would be better off using read?


In trying to test this I came up with these results (which seem to
confirm what you are saying)

Benchmark: timing 50000 iterations of r, rw, s, sw...
         r: 75 secs (39.90 usr 33.52 sys = 73.42 cpu)
        rw: 68 secs (29.24 usr 34.84 sys = 64.08 cpu)
         s: 104 secs (29.49 usr 73.40 sys = 102.89 cpu)
        sw: 38 secs ( 6.37 usr 29.16 sys = 35.53 cpu)

for the following program:
-------------------------------------------------------------
use Benchmark;

# s = sysread 2000 bytes at a time
# r = read 2000 bytes at a time
# sw = sysread whole file
# rw = read whole file
# oratune.log is a 62k file
 
timethese(50000,{
s => 'my $offset; my $bytes = 2000; open(F,"oratune.log"); while (sysread(F,$buf,$bytes,$offset)) { $offset += $bytes; }  close(F);',
r => 'my $offset; my $bytes = 2000; open(F,"oratune.log"); while (read(F,$buf,$bytes,$offset)) { $offset += $bytes; }  close(F);',
sw => 'open(F,"oratune.log"); @stat = stat F; sysread(F,$buf,$stat[7]); close(F);',
rw => 'open(F,"oratune.log"); @stat = stat F; read(F,$buf,$stat[7]); close(F);'
});
-------------------------------------------------------------

The moral appears to be to use sysread for reading whole files but
stick with read when reading N bytes at a time as you can't know
what blocksize the disks your program might run on will use.  Is this
a reasonable conclusion?

--
Mike Linksvayer   http://gondwanaland.com/ml/


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

Date: Thu, 22 Jan 1998 15:40:40 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Trouble with a regex
Message-Id: <34C7AEC8.77D9@min.net>

Joe Gottman wrote:
> 
> Mike Hammernik wrote:
> >
> > I have a list of ip addresses that I'm trying to pull out the ones that
> > contain a particular range in the last digits.  A list of
> > 192.168.120.101
> > 192.168.116.94
> > 192.168.133.10
> > 192.168.121.30
> > etc
> >
> > I would like to obtain only the group of ip address that in the last
> > field contain numbers from 01 to 30. expressions thatare like
> > 192\.168\.*\.[01-39] of course match 139 as well as 39. In going through
> > Mastering regex book and my perl books I have been unable to find a way
> > to do this. I've even gone through all my copies of postings in the hope
> > I would find one that asked this question before,
> > Your time and help is greatly appreciated
> >
> 
> This is a difficult regex problem, but it actually is easy if you
> don't confine yourself to regular expressions.  Try
>    if ( ($ip =~ /(\d\d$)/) and ($1 >= 1) and ($1 <= 30) )
> 
> The regular expression pulls the last 2 digits out of the ip address and
> stores them in $1. Then the two comparisons check whether the digits are
> between 1 and thirty.

Well, not as easy as you thought, apparently.
Your version incorrectly passes addresses like "127.0.0.222", not
mention
things which aren't IP addresses at all, such as '987654321'.

Here's one way to get the numeric value for each of the parts of an IP
address, with an arbitrary test on an arbitrary part:

	$numeric_regex = '([1-9][0-9]*|0[0-7]*|0x[0-9a-fA-F]+)';
	$ipaddr_regex = join( "\\.", ( $numeric_regex ) x 4 );

	$addr = '127.0.1.222'; # or whatever
	if ( $addr =~ /\b$ipaddr_regex\b/ ) {
	  my @part = ( $1, $2, $3, $4 );
	  map { $_ = oct($_) if /^0/ } @part; # handles hex also
	  # perform an arbitrary test:
	  if ( $part[3] >= 1 and $part[3] <= 30 ) {
	    # do whatever...
	  }
	}
	else {
	  # hey, not a valid IP address.
	}

This isn't so sophisticated as to tell you which part, if any, is
in error.  It also doesn't handle the valid IP address forms with
fewer than four parts (e.g. 127.0.1024 is valid, AYMNK).

hth,
John Porter


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

Date: 22 Jan 1998 19:36:39 GMT
From: packer@fermi.gsfc.nasa.gov (Charles Packer)
Subject: Re: URL-getting when User-Agent demanded
Message-Id: <slrn6cf80c.n0l.packer@fermi.gsfc.nasa.gov>

In article <slrn6ceqio.mec.packer@fermi.gsfc.nasa.gov>, Charles Packer wrote:
>from the Web with great success. Now, however, I'm up against
>a Web site that requires "browser/proxy identification,"


After a little more experimentation, I've determined that
I need to send a "User-Agent" header. It doesn't have
anything to do with the http_proxy environmental variable.
The problem now is where to send it. I tried sending it
at the same point where I would send user authorization code
if I needed one. For a user-agent string, I used the one
that Lynx apparently sends:

Lynx/2-4-2  libwww/2.14

However, the web site in question still didn't recognize it.


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

Date: Thu, 22 Jan 1998 13:38:34 -0700
From: "Daniel C. Benton Jr." <dcbenton@sni.net>
To: ari@imaristudios.com
Subject: Re: We ain't payin' shit!
Message-Id: <34C7AE4A.205BFB5B@sni.net>

Ari Burton, President of IMARI STUDIOS wrote:
> 
> JUNIOR PROGRAMMERS WANTED! Are you starting out as a new programmer?

No, because I'm a senior programmer.

> 
> Do you want to get your feet wet working on real-world applications?

By 'Real-world' I'm willing to bet you mean 'Boring'.

> 
> We are looking for new programmers of...
> 
> PERL/CGI/C/C+/C++/JAVA/Visual Basic   etc.

Wow! Not Cobol or Fortran? You *are* progressive.

> 
> Whether you know one, some, or all, you are welcome!
> 
> NOTE: We are telling you right now ahead of time that these
> "positions" are *****NON-PAYING*****!

So why would anybody want to help you?

BTW, what is the definition of a job? What you want are
unpaid slave labor. if you are training people, maybe you
should say you want 'students'.

> 
> We are offering you the opportunity to get real experience behind you
> by working on real applications on live websites.

Or they can learn a lot more with their own personal Linux or NT
systems.

> 
> We will also list you, and a short biography about you on a CREDITS
> page
> for any project you work on.

Oh! That's worth it. 

> 
> This will server as your first reference and JOB EXPERIENCE
> when you go out hunting for real paying clients and jobs.

This will server as? WTF?

> 
> We believe this is an honest and fair trade for new beginning
> programmers.

Why don't you pay them? Why don't you get a couple of pros to
work on your site? Maybe because you are a fly-by-night operation
with no money, and you are too damn stupid to program your own
application.

> 
> Work from wherever you like. Your location, age, etc. are not
> important to us.

We want you to stay in our wonderful gulags, with cold running
water. That is important to us.

> Your desire to learn, grow, and become the best you can be IS
> important to us!

That you work for nothing is important to us!

> 
> If you, or any of your friends are interested, please contact us!
> Visit IMARI STUDIOS at    http://www.imaristudios.com

Interesting....

Imari Studios (IMARISTUDIOS-DOM)
   3770 South Swenson#E-109
   Las Vegas, NV 89119
   US

   Domain Name: IMARISTUDIOS.COM

   Administrative Contact:
      Burton, Ari  (AB480)  ari@IMARISTUDIOS.COM
      +702 732-1965

-----

I may be flaming the mafia, but what the heck.
 
> 
> E-Mail us at the contact address listed there.
> (We don't post our E-Mail address here because of the spam-bots.)

Your email address was in your signature, which spam-bots read anyway,
moronski.

> 
> I hope to hear from you all SOON!

I hope you are ignored.

> 
> Warmest regards,

Hottest flames!

> Ari Burton, President of
> IMARI STUDIOS
> http://www.imaristudios.com
> ari@imaristudios.com

Notice the email address.

"Oh please let me work for nothing at your nothing company."

Dan "I well-paid programmer/system admin" Benton

--
Daniel C. Benton Jr.
mailto:dcbenton@sni.net
http://www.sni.net/dcbenton
--


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

Date: 22 Jan 1998 20:40:00 GMT
From: badger@infinet.com (Steven Savage)
Subject: Win32 PERL Newbie question
Message-Id: <6a8ar0$8gl@news1.infinet.com>


This is a bit embarassing, but I figured some of the folks here could 
help me.

I'm investigating PERL as a possible CGI language, and am evaluating it 
on a Win32 system.  However there is one thing I can't solve (related to 
Win32), namely associations.  Obviously this is ignorance of Win32 on my 
part.

Essentially, i wish to be able to type the name of a perl program with 
the .pl extension and have perl.exe run it, passing the command line, 
etc.  Unfortunately despite Associating in Explorer, I found no way to do 
this.  My own Win32/DOS ignorance I know, but I can locate no way to do this.

Anyone with a way to accomplish this, please write badger@infinet.com.


--
BADGER
(aka Steve Savage)

---------------------------------------------------------------
  /------\    BBB   AA  DDD   GG  EEEE RRR
[/  |  |  \]  B  B A  A D  D G    E    R  R
// O|  |O \\  BBB  AAAA D  D G GG EEE  RRR
\\  |  |  //  B  B A  A D  D G  G E    R  R
 \  |  |  /   BBB  A  A DDD   GG  EEEE R  R
  \ |..| / 
   \____/     Badger's Den - http://www.infinet.com/~badger

MEMBER OF:
Association of Internet Professionals: http://www.association.org/
Java Lobby: http://www.javalobby.com/
---------------------------------------------------------------


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

Date: Thu, 22 Jan 1998 20:40:44 GMT
From: michael@hartleym.force9.co.uk (Michael Hartley)
Subject: win32:ftp
Message-Id: <34c7ae51.5769475@nntp.netcomplete>

Hi,

does anyone know if there are any win32:ftp modules freely available?
I just need the ability to ftp to a unix server and get a single file,
then shutdown.

Help very much appreciated.

Michael Hartley. mailto://hartleym@netcomuk.co.uk


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.  

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 1705
**************************************

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