[17054] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4466 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 29 06:05:26 2000

Date: Fri, 29 Sep 2000 03:05:09 -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: <970221909-v9-i4466@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 29 Sep 2000     Volume: 9 Number: 4466

Today's topics:
    Re: [IGNORE - OFF TOPIC] Re: Controlling line length re <nico@monnet.to>
    Re: Al Gore's Mother Invented Perl <bill.kemp@wire2.com>
    Re: Al Gore's Mother Invented Perl (Logan Shaw)
        Assigning to this scalar ${num}{'hex'} ? <webmaster@ostas.lu.se>
    Re: Assigning to this scalar ${num}{'hex'} ? <uri@sysarch.com>
        attachment not in body of email <hugo@fractalgraphics.com.au>
        attachment not in body of email <hugo@fractalgraphics.com.au>
        bin2hex <manfrin@tolomeo.it>
    Re: bin2hex (Logan Shaw)
    Re: Candidate for the top ten perl mistakes list <bart.lateur@skynet.be>
    Re: flock <mikecook@cigarpool.com>
    Re: flock <godzilla@stomp.stomp.tokyo>
    Re: function reference <philipg@atl.mediaone.net>
    Re: Help with Unix processes. (Urgent!) <Torsten.Schindler@ccc.uni-erlangen.de>
    Re: How to do a UDP broadcast using IO::Socket? <Thomas.Kratz@lrp.de.nospam>
    Re: How to get length of scalar? (Anthony Peacock)
    Re: How to get length of scalar? <flavell@mail.cern.ch>
    Re: How to get length of scalar? (Anthony Peacock)
        Just Another Perl Hacker <sxm124@po.cwru.edu>
        Just Another Perl Hacker <sxm124@po.cwru.edu>
        Just Another Perl Hacker <sxm124@po.cwru.edu>
    Re: Just Another Perl Hacker (Bernard El-Hagin)
    Re: need help on a small cgi thank u <scott@uq.edu.au>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 29 Sep 2000 11:03:14 +0100
From: "Nicolas MONNET" <nico@monnet.to>
Subject: Re: [IGNORE - OFF TOPIC] Re: Controlling line length read by <>
Message-Id: <X%YA5.68$N3.5467@tengri.easynet.fr>

What the fuck was David Steuber <nospam@david-steuber.com> trying to say:
> "Godzilla!" <godzilla@stomp.stomp.tokyo> writes:
> 
> ' Truth does not need to packaged and sold. Truth is
> ' self-evident. I have no interest in this type of debate.
> 
> Now I am really confused.  I have no idea what you are going on about
> now.

YHBT
HTH
HAND

-- 
perl -e 'print `echo Just a Lame Perl Luser | gzip -9 | cat | gzip -cd`'



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

Date: Fri, 29 Sep 2000 08:40:34 +0100
From: "W Kemp" <bill.kemp@wire2.com>
Subject: Re: Al Gore's Mother Invented Perl
Message-Id: <970213515.817.0.nnrp-01.c3ad6973@news.demon.co.uk>

>W Kemp <bill.kemp@wire2.com> wrote:
>>Who's Al Gore.
>>
>>Remember the world doesn't take part in "the world series".
>
>That's O.K.  Many of the registered voters in the U.S. don't take part
>either.  (About 51% of them in the last election.)
>
>By the way, we certainly hear enough about British politics and royalty
>over here on this side of the pond...


It was supposed to be a quick reminder that it was off-topic (at least by
the time we started getting into US politics),
and largely irrelevant.
I have never seen anything about british politics on this newsgroup.




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

Date: 29 Sep 2000 04:04:25 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Al Gore's Mother Invented Perl
Message-Id: <8r1lup$qa2$1@provolone.cs.utexas.edu>

In article <970213515.817.0.nnrp-01.c3ad6973@news.demon.co.uk>,
W Kemp <bill.kemp@wire2.com> wrote:
>>W Kemp <bill.kemp@wire2.com> wrote:
>>>Who's Al Gore.
>>By the way, we certainly hear enough about British politics and royalty
>>over here on this side of the pond...
>
>It was supposed to be a quick reminder that it was off-topic (at least by
>the time we started getting into US politics),
>and largely irrelevant.

Oh, O.K.  I took it as good-natured grumbling about the
general topic of hearing more about the U.S. elections
than you care to, rather than something that was specific
to this newsgroup, Usenet, or even the Internet.

>I have never seen anything about british politics on this newsgroup.

Me neither, but I have certainly seen lots about it in the
conventional media, which is why I was thinking I could commiserate.

  - Logan


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

Date: Fri, 29 Sep 2000 09:25:35 +0200
From: Jimmy Lantz <webmaster@ostas.lu.se>
Subject: Assigning to this scalar ${num}{'hex'} ?
Message-Id: <39D443E9.F8A2F26F@ostas.lu.se>

Hi, 
I've been looking for hours now for a way how to assign this scalar I
know this is as simple as .... but I cant even find it online anywhere.
Please help me if you can  with this very simple problem.
Regards
Jimmy Lantz

######################

#!perl
$num = 1;

@hits = ('HD6A:PY123:SWE123', 'PPGH:PY223:SWE223', 'HD7A:PY23:SW23');

foreach $hit (@hits)
{
(${num}{'hex'}, ${num}{'py'}, ${num}{'swe'}) = split /:/, $hit;
$num++;
}
print $1{'hex'}; Should output HD6A
print $2{'py'};  Should output PY223


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

Date: Fri, 29 Sep 2000 07:35:49 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Assigning to this scalar ${num}{'hex'} ?
Message-Id: <x77l7v7iqy.fsf@home.sysarch.com>

>>>>> "JL" == Jimmy Lantz <webmaster@ostas.lu.se> writes:

  JL> I've been looking for hours now for a way how to assign this scalar I
  JL> know this is as simple as .... but I cant even find it online anywhere.
  JL> Please help me if you can  with this very simple problem.

it is very simple but you have it all backwards. it is not a scalar you
want and you can't create or assign to $1, $2, etc. they are special to
regexes

  JL> @hits = ('HD6A:PY123:SWE123', 'PPGH:PY223:SWE223', 'HD7A:PY23:SW23');

  JL> foreach $hit (@hits)
  JL> {
  JL> (${num}{'hex'}, ${num}{'py'}, ${num}{'swe'}) = split /:/, $hit;

that has too many mistakes to even count.

one way:

	my @all_parts ;
	foreach $hit (@hits) {

		my %parts ;

		@parts{ qw( hex py swe ) } = split /:/, $hit ;

		push @all_parts, \%parts ;
	}

	print $all_parts[0]{'hex'} ; # will output HD6A

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Fri, 29 Sep 2000 12:52:11 +0800
From: Hugo Bouckaert <hugo@fractalgraphics.com.au>
Subject: attachment not in body of email
Message-Id: <39D41FFB.E845850F@fractalgraphics.com.au>

Hi 

In reply to Gwyn's email (who I cannot email directly, it seems) 
I am going to write some more terrible things. By the way, thanks for
the example Gwyn. 

Anyway, after receiving Gwyn's code, I tried to duplicate it as much as
possible in my script, and I am
finding it still does not work, thatis, I cannot get attachments NOT to
reside in the body of the email. 

This is how my code looked like (as much as possible like Gwyn's code
which works): 

At the crucial lines where Gwyn's code has: 

$msg->attach(Type => 'image/gif',
             Data => $data,
              Filename => 'userfriendly.gif'
);

I had to put: 

$msg->attach(Type => 'text/html',
             #Data => $body,
             #Filename => $att
             FH => $att
);

Because I am getting a path + filename from an upload button (as
multipart/form-data) in a html file. Using Filename didn't work - only
the FH and Path options, it seems. Note that I tried to upload both a
gif image as well as text changing to Type 'text/html' Type 'image/gif'
when appropriate - but the type shouldn't matter surely.  

I have the full script pasted in here. If anyone knows why the
attachments still appear in the body of the email, please let me know
(they shouldn't). 

Any help much appreciated. 

Thanks

Hugo 

#!/usr/sbin/perl
#----------------------------------------------------------------------------
# User variables
#----------------------------------------------------------------------------
use Email;
use CGI;
#use CGI qw(:standard);
$query = new CGI;
require Exporter;
use MIME::Lite;

$emailaddress='hugo@fractalgraphics.com.au';
$thankyoupage='http://www.fractalgraphics.com.au/fracviewer/thanks.html';
 
# Test if the forms have been filled in.

if (!$query->param('Email')) {
        &print_page_start;
        &write_form;
        &print_page_end;
        }
else {
        &print_page_start;
        &write_file;
        &print_page_end;        
        &print_refer;
}
sub print_page_start {
        print $query->header;
        print "<html><head><title>Data Conversion
Page</title>\n</head>\n<body>\n";
        print "<h1>Data Conversion page</h1>";
        }
        
sub print_page_end {
        print "</body></html>"
        }
        
sub write_form {
        print "<FORM METHOD=\"POST\" ENCTYPE=\"multipart/form-data\"
ACTION=\"http://www.fractalgraphics.com.au/cgi-bin/upload3.pl\">\n";
        print "<p>Email Address\n";
        print "<INPUT TYPE=\"TEXT\" NAME=\"Email\" SIZE=\"30\"></p>\n";
        print "<p>Name\n";
        print "<INPUT TYPE=\"TEXT\" NAME=\"Name\" SIZE=\"30\"></p>\n";
        print "<p>Company\n";
        print "<INPUT TYPE=\"TEXT\" NAME=\"Company\"
SIZE=\"30\"></p>\n";
        print "<p>File to upload\n";
        print "<INPUT TYPE=\"FILE\" NAME=\"Mdata\" SIZE=\"30\"></p>\n";
        print "<p>Submit\n";
        print "<INPUT TYPE=\"SUBMIT\" VALUE=\"Submit\"></p>";
        print "</FORM><br><br>\n";
        }

sub write_file {

$email= $query->param('Email');
$name = $query->param('Name');
$company = $query->param('Company');
$att = $query->param('Mdata');

$body  = <<MESSAGE_TO_USER;


----------------------------------------------------------------------
          These details were submitted using the WWW Form
            on the Fractal Graphics FracViewer webpage
----------------------------------------------------------------------

Please send information about the requested product to the client's
email address:

Sender's Email: $email
Name:           $name
Company:        $company

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

MESSAGE_TO_USER

my $msg = MIME::Lite->new(
                From => 'info@fractalgraphics.com.au',
                To => 'hugo@fractalgraphics.com.au',
                Subject => 'A new userfriendly image!',
                Type => 'multipart/mixed'
);

$msg->attach(Type => 'TEXT',
      Data => "Attached please find the latest image\n",
);

$msg->attach(Type => 'text/html',
             #Data => $body,
             #Filename => $att
             FH => $att
);

#----------------------------------------------------------------------------

# Generate reply for user

# Send the thankyou page to the submitter ...
print "Location: $thankyoupage\n\n";
}
exit;
 

Gwyn Judd wrote:
> 
> I was shocked! How could Hugo Bouckaert <hugo@fractalgraphics.com.au>
> say such a terrible thing:
> >Hi
> >
> >I have been trying forever now to have a perl script that sends email
> >with attachments not displayed in the body of the email. It just does
> >not want to work!! This is very frustrating.
> 
> >This is virtually identical to what is in perldoc Lite
> >
> >BUT IT DOES NOT WORK! The mail and attachment(s) are sent, but all
> >attachments, including the image, are in the body of the email
> 
> Beats me. Yours looks like it should work to my limited knowledge. Are
> you sure it's not a MUA issue? Some mailers will display any attachments
> that they know about.
> 
> >As I said, an actual working perl script would be most welcome, then I
> >can compare a working version with mine and see what goes wrong. I
> >really don't seem to get this one.
> 
> Here is a "works for me" script that attaches a gif downloaded from a
> site on the internet into a document:
> 
> #!/usr/bin/perl -w
> # get a userfriendly image and mail it
> 
> use LWP::Simple;
> use MIME::Lite;
> use strict;
> 
> my $arg = shift;
> my $debug = 0;
> 
> if (defined $arg && $arg eq '-d')
> {
>     print "setting debug option\n";
>     $debug = 1;
> }
> 
> select STDOUT; $| = 1; # make unbuffered
> select STDERR; $| = 1;
> 
> sub print_mess
> {
>     my $mess = shift or return;
> 
>     print $mess if $debug;
> }
> 
> # get a file
> sub http_get_file
> {
>     my $file = shift;
> 
>     my $data = get $file or die "Could not get $file: $!\n";
> 
>     $data;
> }
> 
> # You can change these according to the image that you want to grab
> my $document = 'http://www.userfriendly.org/static/index.html';
> my $mail_addr = 'gwyn@thislove.dyndns.org';
> 
> my $page = &http_get_file($document);
> 
> # this is the section that parses out the correct URL
> my @link = split /ALT="Latest Strip"/, $page;
> my @getlink = split />/, $link[1];
> my @findlink = split /SRC="/, $getlink[0];
> my @pullend = split /">/, $findlink[1];
> $pullend[0] =~ s/"//;
> my $the_file = $pullend[0];
> 
> &print_mess("file to get looks like $the_file\n");
> 
> my $data = &http_get_file($the_file);
> 
> my $msg = MIME::Lite->new(
>                 From => 'userf@localhost',
>                 To => $mail_addr,
>                 Subject => 'A new userfriendly image!',
>                 Type => 'multipart/mixed'
> );
> 
> $msg->attach(Type => 'TEXT',
>       Data => "Attached please find the latest userfriendly cartoon\n",
> );
> 
> $msg->attach(Type => 'image/gif',
>              Data => $data,
>              Filename => 'userfriendly.gif'
> );
> 
> $msg->send;
> 
> --
> Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
> About all some men accomplish in life is to send a son to Harvard.

-- 
Dr Hugo Bouckaert
R&D Support Engineer, Fractal Graphics 
39 Fairway, Nedlands Western Australia 6009
Tel: 9284 8442
Email:hugo@fractalgraphics.com.au
Web: http://www.fractalgraphics.com.au


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

Date: Fri, 29 Sep 2000 13:34:30 +0800
From: Hugo Bouckaert <hugo@fractalgraphics.com.au>
Subject: attachment not in body of email
Message-Id: <39D429E6.7F6C8ACA@fractalgraphics.com.au>

Hi 

In reply to Gwyn's email (who I cannot email directly, it seems) 
I am going to write some more terrible things. By the way, thanks for
the example Gwyn. 

Anyway, after receiving Gwyn's code, I tried to duplicate it as much as
possible in my script, and I am
finding it still does not work, thatis, I cannot get attachments NOT to
reside in the body of the email. 

This is how my code looked like (as much as possible like Gwyn's code
which works): 

At the crucial lines where Gwyn's code has: 

$msg->attach(Type => 'image/gif',
             Data => $data,
              Filename => 'userfriendly.gif'
);

I had to put: 

$msg->attach(Type => 'text/html',
             #Data => $body,
             #Filename => $att
             FH => $att
);

Because I am getting a path + filename from an upload button (as
multipart/form-data) in a html file. Using Filename didn't work - only
the FH and Path options, it seems. Note that I tried to upload both a
gif image as well as text changing to Type 'text/html' Type 'image/gif'
when appropriate - but the type shouldn't matter surely.  

I have the full script pasted in here. If anyone knows why the
attachments still appear in the body of the email, please let me know
(they shouldn't). 

Any help much appreciated. 

Thanks

Hugo 

#!/usr/sbin/perl
#----------------------------------------------------------------------------
# User variables
#----------------------------------------------------------------------------
use Email;
use CGI;
#use CGI qw(:standard);
$query = new CGI;
require Exporter;
use MIME::Lite;

$emailaddress='hugo@fractalgraphics.com.au';
$thankyoupage='http://www.fractalgraphics.com.au/fracviewer/thanks.html';
 
# Test if the forms have been filled in.

if (!$query->param('Email')) {
        &print_page_start;
        &write_form;
        &print_page_end;
        }
else {
        &print_page_start;
        &write_file;
        &print_page_end;        
        &print_refer;
}
sub print_page_start {
        print $query->header;
        print "<html><head><title>Data Conversion
Page</title>\n</head>\n<body>\n";
        print "<h1>Data Conversion page</h1>";
        }
        
sub print_page_end {
        print "</body></html>"
        }
        
sub write_form {
        print "<FORM METHOD=\"POST\" ENCTYPE=\"multipart/form-data\"
ACTION=\"http://www.fractalgraphics.com.au/cgi-bin/upload3.pl\">\n";
        print "<p>Email Address\n";
        print "<INPUT TYPE=\"TEXT\" NAME=\"Email\" SIZE=\"30\"></p>\n";
        print "<p>Name\n";
        print "<INPUT TYPE=\"TEXT\" NAME=\"Name\" SIZE=\"30\"></p>\n";
        print "<p>Company\n";
        print "<INPUT TYPE=\"TEXT\" NAME=\"Company\"
SIZE=\"30\"></p>\n";
        print "<p>File to upload\n";
        print "<INPUT TYPE=\"FILE\" NAME=\"Mdata\" SIZE=\"30\"></p>\n";
        print "<p>Submit\n";
        print "<INPUT TYPE=\"SUBMIT\" VALUE=\"Submit\"></p>";
        print "</FORM><br><br>\n";
        }

sub write_file {

$email= $query->param('Email');
$name = $query->param('Name');
$company = $query->param('Company');
$att = $query->param('Mdata');

$body  = <<MESSAGE_TO_USER;


----------------------------------------------------------------------
          These details were submitted using the WWW Form
            on the Fractal Graphics FracViewer webpage
----------------------------------------------------------------------

Please send information about the requested product to the client's
email address:

Sender's Email: $email
Name:           $name
Company:        $company

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

MESSAGE_TO_USER

my $msg = MIME::Lite->new(
                From => 'info@fractalgraphics.com.au',
                To => 'hugo@fractalgraphics.com.au',
                Subject => 'A new userfriendly image!',
                Type => 'multipart/mixed'
);

$msg->attach(Type => 'TEXT',
      Data => "Attached please find the latest image\n",
);

$msg->attach(Type => 'text/html',
             #Data => $body,
             #Filename => $att
             FH => $att
);

#----------------------------------------------------------------------------

# Generate reply for user

# Send the thankyou page to the submitter ...
print "Location: $thankyoupage\n\n";
}
exit;
 

Gwyn Judd wrote:
> 
> I was shocked! How could Hugo Bouckaert <hugo@fractalgraphics.com.au>
> say such a terrible thing:
> >Hi
> >
> >I have been trying forever now to have a perl script that sends email
> >with attachments not displayed in the body of the email. It just does
> >not want to work!! This is very frustrating.
> 
> >This is virtually identical to what is in perldoc Lite
> >
> >BUT IT DOES NOT WORK! The mail and attachment(s) are sent, but all
> >attachments, including the image, are in the body of the email
> 
> Beats me. Yours looks like it should work to my limited knowledge. Are
> you sure it's not a MUA issue? Some mailers will display any attachments
> that they know about.
> 
> >As I said, an actual working perl script would be most welcome, then I
> >can compare a working version with mine and see what goes wrong. I
> >really don't seem to get this one.
> 
> Here is a "works for me" script that attaches a gif downloaded from a
> site on the internet into a document:
> 
> #!/usr/bin/perl -w
> # get a userfriendly image and mail it
> 
> use LWP::Simple;
> use MIME::Lite;
> use strict;
> 
> my $arg = shift;
> my $debug = 0;
> 
> if (defined $arg && $arg eq '-d')
> {
>     print "setting debug option\n";
>     $debug = 1;
> }
> 
> select STDOUT; $| = 1; # make unbuffered
> select STDERR; $| = 1;
> 
> sub print_mess
> {
>     my $mess = shift or return;
> 
>     print $mess if $debug;
> }
> 
> # get a file
> sub http_get_file
> {
>     my $file = shift;
> 
>     my $data = get $file or die "Could not get $file: $!\n";
> 
>     $data;
> }
> 
> # You can change these according to the image that you want to grab
> my $document = 'http://www.userfriendly.org/static/index.html';
> my $mail_addr = 'gwyn@thislove.dyndns.org';
> 
> my $page = &http_get_file($document);
> 
> # this is the section that parses out the correct URL
> my @link = split /ALT="Latest Strip"/, $page;
> my @getlink = split />/, $link[1];
> my @findlink = split /SRC="/, $getlink[0];
> my @pullend = split /">/, $findlink[1];
> $pullend[0] =~ s/"//;
> my $the_file = $pullend[0];
> 
> &print_mess("file to get looks like $the_file\n");
> 
> my $data = &http_get_file($the_file);
> 
> my $msg = MIME::Lite->new(
>                 From => 'userf@localhost',
>                 To => $mail_addr,
>                 Subject => 'A new userfriendly image!',
>                 Type => 'multipart/mixed'
> );
> 
> $msg->attach(Type => 'TEXT',
>       Data => "Attached please find the latest userfriendly cartoon\n",
> );
> 
> $msg->attach(Type => 'image/gif',
>              Data => $data,
>              Filename => 'userfriendly.gif'
> );
> 
> $msg->send;
> 
> --
> Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
> About all some men accomplish in life is to send a son to Harvard.

-- 
Dr Hugo Bouckaert
R&D Support Engineer, Fractal Graphics 
39 Fairway, Nedlands Western Australia 6009
Tel: 9284 8442
Email:hugo@fractalgraphics.com.au
Web: http://www.fractalgraphics.com.au


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

Date: Fri, 29 Sep 2000 10:56:07 +0200
From: "Mauro Manfrin" <manfrin@tolomeo.it>
Subject: bin2hex
Message-Id: <8r1lfn$mp5$1@fe1.cs.interbusiness.it>

I'm trying to write a little perl function
that converts an integer (like 5632445)
in to an hex number (like 55F1BD).

I've tried with pack and unpack functions
but but I can't use them.

Someone can help me?

Thank you in advance,

MAURO




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

Date: 29 Sep 2000 04:18:24 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: bin2hex
Message-Id: <8r1mp0$qb7$1@provolone.cs.utexas.edu>

In article <8r1lfn$mp5$1@fe1.cs.interbusiness.it>,
Mauro Manfrin <manfrin@tolomeo.it> wrote:
>I'm trying to write a little perl function
>that converts an integer (like 5632445)
>in to an hex number (like 55F1BD).
>
>I've tried with pack and unpack functions
>but but I can't use them.

Do a "perldoc -f sprintf".  Read the part about "%x".

  - Logan


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

Date: Fri, 29 Sep 2000 08:06:51 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Candidate for the top ten perl mistakes list
Message-Id: <s0j8tssmtgtaens5hfq6h7dpu5l1kpp54f@4ax.com>

Ilya Zakharevich wrote:

>> Heh, you're right. It seems like
>> 
>> 	@a = qw(a b c d);
>> 	splice @a, 1, 2 = (1 .. 4);
>> 
>> should work
>
>Nope.  Wrong precedence.  And parens will make this ugly anyway.

Oops. Perl doesn't accept this either:

	$a = "abcd";
	substr $a, 1, 2 = "1234";

But this works:

	$a = "abcd";
	substr($a, 1, 2) = "1234";
	print "$a\n";
-->
	a1234d

So, similarily, it is not unreasonable to expect

	@a = qw( a b c d);
	splice(@a, 1, 2) = 1 .. 4;
	print "@a\n";

to work in a similar manner.

But, as I said before: if you're interested in getting the old values,
the 4 (or more) argument splice makes more sense:

	@a = qw( a b c d);
	@b = splice @a, 1, 2, 1 .. 4;
	print "@a -- @b\n";
-->
	a 1 2 3 4 d -- b c

In recent perls, this works for substr too:

	$a = 'abcd';
	$b = substr $a, 1, 2, '1234';
	print "$a -- $b\n";
-->
	a1234d -- bc

-- 
	Bart.


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

Date: Thu, 28 Sep 2000 22:29:39 -0700
From: "Michael Cook" <mikecook@cigarpool.com>
Subject: Re: flock
Message-Id: <6OVA5.2186$Yc.532105@news.uswest.net>

Thanks a mil GZ!!! BTW, I see I missed a word typing this - I meant to write
"I have read everything I can find on..."
    Michael
--
== CigarPool ==
http://www.cigarpool.com

"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:39D2E1C7.B2B70BD5@stomp.stomp.tokyo...
> Michael Cook wrote:
>
>
> *bites her tongue*
>
> > I have read everything I can on fcntl & flock....
>
> No. You wouldn't be asking these questions if you
> had read everything. In reality, you haven't read
> everything yet, and haven't found what you seek.
>
> http://language.perl.com/newdocs/pod/perlopentut.html#File_Locking
>
> You will find very nice information there and will find
> better methods to accomplish your task.
>
>
> > ...but I have been told more than once (but can't find any info
> > to back it up), you shouldn't unlock before a close.
>
> This is a generalized rule most mistake for an absolute rule.
> For some scripts, this general notion is a wrong notion. There
> are scripts which process input data, open a file for both
> write and read, attain a lock, 'append' processed data results,
> unlock the file, then seek and read part of this file for
> old information and newly printed information, then closure
> of the file followed by a print of this read information.
>
> Using this method speeds up a script by allowing one opening
> for both write and read, rather than two openings, one for
> write, one for read. Note this is an append type write.
>
> However, these types of scripts are rather specialized scripts
> and, a programmer needs to know how to handle this, correctly.
> Nonetheless, this style has been in use for many years and,
> used in literally thousands of scripts scattered about our net,
> without any problems.
>
> General rule, however, is to close () to break a lock and,
> close a file as quickly as possible. This answers your last
> question about close () releasing a lock.
>
>
> Godzilla!




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

Date: Thu, 28 Sep 2000 22:42:07 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: flock
Message-Id: <39D42BAF.8FC7358A@stomp.stomp.tokyo>

Michael Cook wrote:
 
> ... BTW, I see I missed a word typing this - I meant to write
> "I have read everything I can find on..."


I am an icon of the worst of pedantic people as a
science teacher, an English teacher and a Professor
of English. My science background demands precision
in parameters, controls, observations and especially
in factual statements. My English background simply
renders me an annoying bitch.

Don't take me too seriously. Few do. This works to
my greatest advantage. I am also a professional con.

Godzilla!


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

Date: Fri, 29 Sep 2000 05:01:49 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: function reference
Message-Id: <1nVA5.24823$2z2.4661499@typhoon.southeast.rr.com>

chalesx <chalesx@yahoo.com> wrote in message
news:st7e2ti40qn57b@corp.supernews.com...
> Hi,
>
> Do anyone know how to pass a function like 'sort'?
>
> Currently, I can only pass a function using reference:
> foo_caller(\&foo)
>
> or
>
> pass the string value of the function and use 'eval' the run the function.
>
> I would like to create something similar to 'sort' where you
> can pass the function 'naked'. (e.g.  sort numerically (5, 6, 1, ...))

I'm not sure if it's possible to exactly mimic the sort syntax, though I am
positive that if it is possible, someone on this list will explain.  That
being said, I have come up with this partial solution.  It almost does what
you ask, but you must separate the subroutine from the following arguments
with a comma, as opposed to whitespace only.

use strict;
sub foo_caller (*;@) {
        my $subref = shift;
        no strict 'refs';
        &$subref(@_);
}

sub foo  { print "@_\n" }

foo_caller foo,1,2,3,4;

Check out perldoc perlsub for an explanation of function prototypes.

hth,
p




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

Date: Fri, 29 Sep 2000 07:56:07 +0200
From: Torsten Schindler <Torsten.Schindler@ccc.uni-erlangen.de>
Subject: Re: Help with Unix processes. (Urgent!)
Message-Id: <39D42EF7.D5B424F@ccc.uni-erlangen.de>

Thank you Logan,

Torsten



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

Date: Fri, 29 Sep 2000 11:34:55 +0200
From: "Thomas Kratz" <Thomas.Kratz@lrp.de.nospam>
Subject: Re: How to do a UDP broadcast using IO::Socket?
Message-Id: <39d46605.0@juno.wiesbaden.netsurf.de>


Francis Litterio wrote in message ...
>Using Perl 5.005_03, there seems to be a chicken-and-egg problem when
>doing a UDP broadcast with module IO::Socket:
>
>    #!/usr/bin/perl -w
>    use strict;
>    use IO::Socket;
>
>    # Do a subnet-directed UDP broadcast.
>    my $sock = IO::Socket::INET->new(PeerAddr => '209.192.217.255',
>      PeerPort => 9999,
>      Proto => 'udp',
>      Type => SOCK_DGRAM,
>      Reuse => 1);
>    die "IO::Socket::INET->new: $!\n" unless $sock;
>
>    $sock->sockopt(SO_BROADCAST, 1) or die("sockopt: $!\n");
>    $sock->autoflush();
>
>    while (<>)
>    {
> print $sock $_;
>    }
>
>    close $sock;
>
>The above script produces this output:
>
>    IO::Socket::INET: Permission denied at ./foo line 6
>    IO::Socket::INET->new: Bad file descriptor
>


The following works for me
(5.6.0 on WinNT/5.00503 on AIX/5.00503 on VMS):

   my($BCAddr) = shift;
   my($Port)   = shift;

   $sock = new IO::Socket::INET(
                                Proto    => 'udp',
                                PeerAddr => $BCAddr,
                                PeerPort => $Port,
                               )
                or die "error opening udp channel for $Port, $!";

   $sock->sockopt(SO_REUSEADDR, 1) or die "setsockopt: $!";
   $sock->sockopt(SO_BROADCAST, 1) or die "setsockopt: $!";

   $sock->autoflush(1); # neeeded before Version 1.18

   ...send something to $sock...

Does this work for you?

Thomas




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

Date: 29 Sep 2000 06:35:48 GMT
From: a.peacock@chime.ucl.ac.uk (Anthony Peacock)
Subject: Re: How to get length of scalar?
Message-Id: <8r1d84$k3a$1@uns-a.ucl.ac.uk>

In article <8qvu41$sb9$1@neptunium.btinternet.com>, mcarruth@talk21.com says...
>
>As a large proportion of the Internet is centered around HTML, I think it is
>a good idea that whatever programme anyone writes to talk to an NNTP server
>has some form of HTML parser built in.


The Internet is NOT centered around HTML.  The World Wide Web uses HTML to 
format its documents.  Newsgroups is NOT the WWW.  Newsgroups is a plain text 
environment.

<SNIP>



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

Date: Fri, 29 Sep 2000 11:03:43 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: How to get length of scalar?
Message-Id: <Pine.GHP.4.21.0009291054590.7901-100000@hpplus03.cern.ch>

On 29 Sep 2000, Anthony Peacock wrote:

> The Internet is NOT centered around HTML. 

Right.

> The World Wide Web uses HTML to format its documents. 

No.  The World Wide Web uses HTML to mark up the structure of its
documents, and CSS to suggest their presentation.

Using (or rather, attempting to use) HTML as DTP is a widely practised
abuse.

Of course, this has very little to do with Perl [f'ups
prophylactically set]

-- 

  The solution to "my eye hurts when drinking a cup of tea" is not to 
  take a painkiller, but to remove the spoon from the cup.  - Abigail




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

Date: 29 Sep 2000 09:24:52 GMT
From: a.peacock@chime.ucl.ac.uk (Anthony Peacock)
Subject: Re: How to get length of scalar?
Message-Id: <8r1n54$kkq$1@uns-a.ucl.ac.uk>

In article <Pine.GHP.4.21.0009291054590.7901-100000@hpplus03.cern.ch>, 
flavell@mail.cern.ch says...
>
>On 29 Sep 2000, Anthony Peacock wrote:
>
>> The Internet is NOT centered around HTML. 
>
>Right.
>
>> The World Wide Web uses HTML to format its documents. 
>
>No.  The World Wide Web uses HTML to mark up the structure of its
>documents, and CSS to suggest their presentation.

Yes, my fault for using the word format in a very lazy way.  But the 
original point remians, the OP was trying to claim that the "INTERNET" 
uses HTML, my point was that HTML is the markup language of the World 
Wide Web.  The Internet is a greater being than the World Wide Web and I 
get very frustrated with people who use the two as synonyms.

>Using (or rather, attempting to use) HTML as DTP is a widely practised
>abuse.

I agree, completely.



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

Date: Fri, 29 Sep 2000 00:26:51 -0400
From: Sid Malhotra <sxm124@po.cwru.edu>
Subject: Just Another Perl Hacker
Message-Id: <39D41A0B.B7D80954@po.cwru.edu>

http://www.cpan.org/misc/japh

I recently read the infinite list of Randal Schwartz's signatures and it
definately expresses the perl theme: There's more than one way to do it.

Sid.



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

Date: Fri, 29 Sep 2000 00:30:20 -0400
From: Sid Malhotra <sxm124@po.cwru.edu>
Subject: Just Another Perl Hacker
Message-Id: <39D41ADC.A25E218E@po.cwru.edu>

http://www.cpan.org/misc/japh

I recently read the infinite list of Randal Schwartz's signatures and it
definately expresses the perl theme: There's more than one way to do it.

Sid.



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

Date: Fri, 29 Sep 2000 00:33:58 -0400
From: Sid Malhotra <sxm124@po.cwru.edu>
Subject: Just Another Perl Hacker
Message-Id: <39D41BB6.CF9B60A4@po.cwru.edu>

http://www.cpan.org/misc/japh

I recently read the infinite list of Randal Schwartz's signatures and it
definately expresses the perl theme: There's more than one way to do it.

Sid.



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

Date: 29 Sep 2000 08:30:17 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Just Another Perl Hacker
Message-Id: <slrn8t8koo.al8.bernard.el-hagin@gdndev25.lido-tech>

On Fri, 29 Sep 2000 00:33:58 -0400, Sid Malhotra <sxm124@po.cwru.edu> wrote:
>http://www.cpan.org/misc/japh
>
>I recently read the infinite list of Randal Schwartz's signatures and it
>definately expresses the perl theme: There's more than one way to do it.

Your enthusiasm towards Randal's JAPHs is understandable and
commendable, but manifesting it by sending the above 3 times is quite
unnecessary.

Cheers,
Bernard
--
perl -le 'open JustAnotherPerlHacker,""or$_="B$!e$!r$!n$!a$!r$!d$!";
print split/No such file or directory/;'


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

Date: Fri, 29 Sep 2000 16:04:01 +1000
From: "Scott Cowen-Sinclair" <scott@uq.edu.au>
Subject: Re: need help on a small cgi thank u
Message-Id: <8r1bd7$b3r$1@bunyip.cc.uq.edu.au>

For sure...

The file will be owned by the creator, and if your install is vanilla, this
will almost certainly be 'nobody'.

You'll have to either setup a page that allows the webserver to delete the
file (maybe after authentication for the security implications) or have root
chown it to someone who can delete the file.

I admit I'm not an expert with regards to this, but I have heard of it
before and these were the two solutions offered.

Hope it helps...

Scott.




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

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


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