[18236] in Perl-Users-Digest
Perl-Users Digest, Issue: 404 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 3 09:05:50 2001
Date: Sat, 3 Mar 2001 06:05:21 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <983628321-v10-i404@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 3 Mar 2001 Volume: 10 Number: 404
Today's topics:
Re: command line <gellyfish@gellyfish.com>
Re: compile probem (URGENT) <gellyfish@gellyfish.com>
Re: Convert macintosh file to unix <kj@codegeek.org>
Re: Convert macintosh file to unix (Martien Verbruggen)
Re: Differences between 5.6.0 and 5.6.1 <gellyfish@gellyfish.com>
Re: flock and close with empty read strangeness <bart.lateur@skynet.be>
Re: flock and close with empty read strangeness (Martien Verbruggen)
gif problems!!! <to.da@spray.se>
Re: Global problem with array <gellyfish@gellyfish.com>
Re: Having trouble with variable scoping <c_clarkson@hotmail.com>
Re: Having trouble with variable scoping <gellyfish@gellyfish.com>
Re: Having trouble with variable scoping <bart.lateur@skynet.be>
Re: Help Matt with small programs THANKS AGAIN!! <bart.lateur@skynet.be>
Re: How do I DROP a table using XBase module <gellyfish@gellyfish.com>
Re: How the C L P M turns (Monte)
Re: Mail::Mailer & Mail::Send .. difficulties <gellyfish@gellyfish.com>
MIME::Lite and MailTools <dontspamthewebmaster@webdragon.munge.net>
Re: Para mode and <STDIN> <stephen@twocats.dont-spam.demon.co.uk>
Re: Performing Character Escape Sequences On the Fly <gellyfish@gellyfish.com>
Re: perl CGI output not shown in browser <parrot0123@yahoo.ca>
Re: Perl comments ?? <kj@codegeek.org>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 3 Mar 2001 10:21:38 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: command line
Message-Id: <97qgji$ge1$1@orpheus.gellyfish.com>
On Fri, 2 Mar 2001 13:37:13 -0500 Rafiq Mateen wrote:
> I want to use the following command line argument perl /tmp/html/pl
> /tmp/html.fax2.html
> inside of another program but I am stuck. Please help.
Inside of another *Perl* program you can use one of system(), qx() or piped
open which ever is most appropriate in the circumstances. system() and
open() or described in the perlfunc manpage, qx() is documented in perlop
under "Quotes and Quote-like operators".
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: 3 Mar 2001 11:01:31 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: compile probem (URGENT)
Message-Id: <97qiub$h3j$1@orpheus.gellyfish.com>
On Fri, 2 Mar 2001 09:11:03 -0000 Alan Carter wrote:
> Anyone have any ideas out there? I am getting this error when trying to
> compile my perl script! I am clue-less the only thing is that I am use the
> "use Socket;" in the code. Should this compile. The reason I am doing this I
> because the script in question is being run about 20 times a second, and i
> am trying to bring down the startup time, is there any other way I might
> achive this?
>
>
> Undefined first referenced
> symbol in file
> boot_DynaLoader /var/tmp/cc1UEeA6.o
> ld: fatal: Symbol referencing errors. No output written to smsc_test
> collect2: ld returned 1 exit status
>
use Dynaloader;
At the beginning of your program.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Sat, 03 Mar 2001 10:30:21 GMT
From: kj Copeland <kj@codegeek.org>
Subject: Re: Convert macintosh file to unix
Message-Id: <kj-BB149D.02353103032001@news1.crdva1.bc.home.com>
In article <mMOn6.1623$I4.189558@e420r-sjo3.usenetserver.com>,
"TcN" <aleister@nomade.fr> wrote:
> Hello,
>
> I'll try to convert a macintosh text file in Unix Format.
> My problem is with the accent (I'm french..sorry ;-)
> Do you a script to do that ??
>
> Thanks very much for your help
>
> --
> Thierry C
Hello Thierry,
If you want to edit the file on a Unix system and you are using vi,
you can likely get away with ":%s/^V^M/^V^J/g", where ^V is control-v,
^M is control-m, etc.
If you want a quick (and likely inefficient) script that can be called
like "mac2unix sourcefile destfile" or "unix2mac sourcefile destfile",
depending on which way you want it to go, try this (untested, but should
work okay):
#!/usr/local/bin/perl
use strict;
use warnings;
require 5.6.0;
my $progname = substr($0, rindex($0, '/') + 1, length($0));
open(my $ifh, "< $ARGV[0]")
|| die("can't open $ARGV[0] for input: $!\n");
open(my $ofh, "> $ARGV[1]")
|| die("can't open $ARGV[1] for output: $!\n");
if (lc($progname) eq "mac2unix") {
foreach my $line (<$ifh>) {
$line =~ s/\r/\n/g;
print $ofh $line;
}
}
elsif (lc($progname) eq "unix2mac") {
foreach my $line (<$ifh>) {
$line =~ s/\n/\r/g;
print $ofh $line;
}
}
close($ifh) || die("can't close input file $ARGV[0]: $!\n");
close($ofh) || die("can't close output file $ARGV[1]: $!\n");
On a Unix system, name the script "mac2unix" and have a "unix2mac"
symlink pointing to "mac2unix", set both executable, and it should do
the right thing, depending on what you call it.
While the /g args to the substitutions look wasteful, it simply
guarantees that it works both ways (chomp($line); print($ofh $line,
"\n"); won't work too well for mac2unix on Unix -- the CRs don't count
as line separators). If you manually set $0, you can likely use it on
the Mac, too (by de-5.6.0ing it -- use bareword filehandles and use the
-w switch on the shebang line instead of "use warnings;").
Hope this helps.
Cheers,
~kj
------------------------------
Date: Sat, 3 Mar 2001 22:12:22 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Convert macintosh file to unix
Message-Id: <slrn9a1kcm.qmu.mgjv@martien.heliotrope.home>
On Sat, 03 Mar 2001 10:30:21 GMT,
kj Copeland <kj@codegeek.org> wrote:
> In article <mMOn6.1623$I4.189558@e420r-sjo3.usenetserver.com>,
> "TcN" <aleister@nomade.fr> wrote:
>
>> I'll try to convert a macintosh text file in Unix Format.
>> My problem is with the accent (I'm french..sorry ;-)
>> Do you a script to do that ??
>
> If you want to edit the file on a Unix system and you are using vi,
> you can likely get away with ":%s/^V^M/^V^J/g", where ^V is control-v,
> ^M is control-m, etc.
That doesn't translate the character encoding correctly.
> If you want a quick (and likely inefficient) script that can be called
> like "mac2unix sourcefile destfile" or "unix2mac sourcefile destfile",
> depending on which way you want it to go, try this (untested, but should
> work okay):
The presented script doesn't work, and does basically nothing more than
the search and replace in vi. You could have done it with a one-liner on
the command line in perl. And... It still doesn't translate the
encodings.
See Bart's post for something that does take that into account. all your
post says is how to translate the Mac-specific end-of-line character to
one for the local machine.
> On a Unix system, name the script "mac2unix" and have a "unix2mac"
> symlink pointing to "mac2unix", set both executable, and it should do
> the right thing, depending on what you call it.
The sylink doesn't need to be made executable. If the thing it points to
is executable, the symlink is as well, under normal circumstances.
Martien
--
Martien Verbruggen |
Interactive Media Division | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd. | you come to the end; then stop.
NSW, Australia |
------------------------------
Date: 3 Mar 2001 09:49:05 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Differences between 5.6.0 and 5.6.1
Message-Id: <97qemh$f1d$1@orpheus.gellyfish.com>
On Sat, 03 Mar 2001 02:56:45 GMT Joseph Gottman wrote:
> Where can I find a list of the differences between Perl 5.6.0 and 5.6.1?
>
In the Changes file in the source distribution.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Sat, 03 Mar 2001 10:56:33 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: flock and close with empty read strangeness
Message-Id: <kej1at8cca3l91h6uuht4br8gbrc4bnlbd@4ax.com>
Gwyn Judd wrote:
>>Note that "+<" mode fails if the file doesn't exist. Duh!
>
>Interesting. Where in the documentation is that mentioned? This doesn't
>prevent you from checking for the existance of said file and creating it
>if necessary beforehand if necessary.
That's doing it the hard way.
I found out that opening in "+>>" (generally) doesn't prevent you from
seeking back to the start of the file. I'm not sure if it works for ALL
platforms.
--
Bart.
------------------------------
Date: Sat, 3 Mar 2001 22:34:18 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: flock and close with empty read strangeness
Message-Id: <slrn9a1llq.qmu.mgjv@martien.heliotrope.home>
On Sat, 03 Mar 2001 10:56:33 GMT,
Bart Lateur <bart.lateur@skynet.be> wrote:
> Gwyn Judd wrote:
>
>>>Note that "+<" mode fails if the file doesn't exist. Duh!
>>
>>Interesting. Where in the documentation is that mentioned? This doesn't
>>prevent you from checking for the existance of said file and creating it
>>if necessary beforehand if necessary.
>
> That's doing it the hard way.
>
> I found out that opening in "+>>" (generally) doesn't prevent you from
> seeking back to the start of the file. I'm not sure if it works for ALL
> platforms.
I don't know whether it does for all platforms. Perl has no standard
that guarantees anything like this. If these modes reflect the fopen
modes, and if fopen is used, then the C standard seems to allow this.
All a >> ("a") does is force the write to whatever the current
end-of-file happens to be, regardless of intermediate positionings. The
current end-of-file can be moved around with the truncate function:
$ cat foo
#!/usr/local/bin/perl -w
use Fcntl qw(:seek);
open FH, ">data" or die $!;
print FH "Just some crap\nAnd some more\n";
open FH, "+>>data" or die $!;
truncate FH, 0;
print FH "Overwriting line\n";
$ ./foo; cat data
Overwriting line
$
But, why would you go through the trouble of doing all this, and making
the system work like this, when sysopen with the appropriate arguments
will do this, and this is guaranteed?
Martien
--
Martien Verbruggen |
Interactive Media Division |
Commercial Dynamics Pty. Ltd. | "Mr Kaplan. Paging Mr Kaplan..."
NSW, Australia |
------------------------------
Date: Sat, 3 Mar 2001 14:58:08 +0100
From: "ToDa" <to.da@spray.se>
Subject: gif problems!!!
Message-Id: <1G6o6.5948$hi2.17318@nntpserver.swip.net>
Why doesn't my gif-images shows? It works when I run the code as html
document but not as perl code.
print <<"HTML";
<body bgcolor="#FFFFFF">
<img src="img/hr.gif" width="500" height="3">
</body>
HTML
Best regards // Tony
------------------------------
Date: 3 Mar 2001 10:26:08 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Global problem with array
Message-Id: <97qgs0$gfr$1@orpheus.gellyfish.com>
On Fri, 02 Mar 2001 20:51:08 +0000 Shazad Iqbal wrote:
> Hi
> I have just started using perl on a piece of work. What I want to do is
> read the file and assign what I find to variables which are declared
> global.
> But when I use a variable outside the for loop, it doesnt recognise it.
> The code is below could anyone see what I am doin wrong.
>
> #!/opt/perl/bin/perl -w
> use strict;
>
> my $line;
> my $Semester;
> my $Day;
> my $StartTime;
> my $Type;
> my $Week;
> my $Course;
> my $Group;
> my $Room;
> my @Semester;
> my @Day;
> my @StartTime;
> my @Type;
> my @Week;
> my @Course;
> my @Group;
> my @Room;
> my $index;
A little style point - I think most people would agree that it might be
nicer to write that as :
my ( $line,
$Semester,
$Day,
$StartTime,
$Type,
$Week,
$Course,
$Group,
$Room,
@Semester,
@Day,
@StartTime,
@Type,
@Week,
@Course,
@Group,
@Room,
$index );
And its less typing :)
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Sat, 3 Mar 2001 03:44:02 -0600
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: Having trouble with variable scoping
Message-Id: <6996EDEFB7ACBE39.22D5DD8F0B026971.7F204393B9423D2C@lp.airnews.net>
Jeffry A. Nokes <jeff_nokes@yahoo.com> wrote:
: Greetings,
: I have a problem that I cannot figure out. I have a Perl script
: (call it "main.pl" that includes another perl script (call it
: "subs.pl") containing all my subroutine definitions. I use the
: "require" function to include the file at runtime. I have "use
: strict;" in the beginning of "main.pl" and have declared all
: global variables with "my variable ...", in the largest scope
: of the script. This should allow them to be
: accessible via other internally scoped blocks.
:
: It seems I cannot access the globally declared variables by
: name via my subroutines in my included "subs.pl". I can
: access them if I pass those same variables by reference into
: the sub that needs them. Can someone shed some light on
: how I can access these variables by name directly? I
: have included some pseudo code that models my problem.
:
: ---------------------
: # file "main.pl"
: use strict;
: my $string = "Jeff needs help!";
: require "subs.pl";
: &Print_String
: exit (0);
: ---------------------
: # file "subs.pl"
: sub Print_String
: {print ("\$string = " . $string);
: }
: ---------------------
: The output to STDOUT is
: $string =
:
:
: I have just started using "use strict;" in all my Perl programs, since
: it seems prudent to do so. If I took out the "use strict;" and the "my"
: declaration, the above program works fine. Also, if I leave in the
: "use strict;", the "my" declaration, and just type the code for the sub
: definition into "main.pl" (comment out the "require ..." statemnt) it
: works fine as well. I guess I have a few questions that I need help
: with:
:
: (1) If I use "my" to declare variables in the largest scope of the
: application, are these variables still global by definition?
: (3) If I do use the "my" declaration, why can't my "required sub" see
: the variable anymore?
No. 'my' declares a variable locally aka lexically. You can declare
a variable global by placing it before use strict. Try this:
#!/usr/bin/perl
$string = 'Global'; # This is a BAD thing
use strict;
require "subs.pl";
&print_string;
--------------------
This will make $string global. Notice that we had to turn off
warnings, but what you presented above indicates you didn't
have them turned on anyway.
: (2) Why does "use strict" not allow the script to compile unless all
: declared variables have a "my", "our" or "local" in front of it?
'use strict;' incorporates use strict 'vars'. Global variables are
not safe and strict 'vars' is trying to keep you safe. Let's say your
programming an application for a bank, You probably don't
want some outside program accessing your $account_balance
variable. You also wouldn't want someone changing a variable
in subs.pl that you didn't expect would change when you wrote
the subroutines.
If your writing quick little programs, don't use strict vars. If
your new to perl keep strict. It will speed up your learning curve.
Personally, I use it in even the smallest scripts.
: (4) The million dollar question...
: How do I use the safety of "use strict;", declare my variables with
: "my", "our" or "local" so I can compile my script, and get access to
: those global variables in subroutines that are included via the
: "require" statement?
:
Change the way you write subroutines. Use @_ and shift to
import variables into your subs:
sub Print_String {
print ("\$string = $string");
}
is only usable in programs that have $string defined and are not
using strict vars. That limits its usefulness a lot.
sub Print_String {
my $string = shift;
print ("\$string = $string!");
}
Now you have to call Print_String( 'something'), but you can
print more than just $string and you can use strict with
warnings turned on.
Note that you're when you require another program, your
importing all its subroutines and any of its global variables
into your programs namespace. You might want to use a
module for your subroutines and common variables.
When you import variables into your subs, you can do
other neat things, too. Like checking to see if a list, a
reference, or a scalar was sent. Using wantarray, you can
return them in neat ways, too.
my @list = (1 .. 200);
print max(\@list);
sub max {
# allow lists and references to lists
@_ = @{$_[0]} if ref($_[0]) eq 'ARRAY';
my $max = shift;
map {$max = $_ if $_ > $max} @_;
return $max;
}
HTH,
Charles K. Clarkson
------------------------------
Date: 3 Mar 2001 11:53:39 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Having trouble with variable scoping
Message-Id: <97qm03$ho8$1@orpheus.gellyfish.com>
On Fri, 02 Mar 2001 23:47:20 -0800 Jeffry A. Nokes wrote:
> Greetings,
> I have a problem that I cannot figure out. I have a Perl script (call
> it "main.pl" that includes another perl script (call it "subs.pl")
> containing all my subroutine definitions. I use the "require" function
> to include the file at runtime. I have "use strict;" in the beginning
> of "main.pl" and have declared all global variables with "my variable
> ...", in the largest scope of the script. This should allow them to be
> accessible via other internally scoped blocks.
>
> It seems I cannot access the globally declared variables by name via my
> subroutines in my included "subs.pl". I can access them if I pass those
> same variables by reference into the sub that needs them. Can someone
> shed some light on how I can access these variables by name directly? I
> have included some pseudo code that models my problem.
>
Thats right. The largest possible scope of a lexical ('my' ) variable is
the file in which it is declared. In order to access variables that are
defined in another file those variables will need to have package scope
( which can extend beyond a single file ). As you will have noticed
simply omitting the 'my' will cause strict to complain. You will need to
declare the variables which need to seen in the other file with either
'use vars' or 'our' (in 5.6.0 and later) - in the main file that needs
to access the variables you can refer to them with the fully package
qualified name - $main::variable for instance.
You might also consider making your required file a proper module with its
own package declaration indeed you could start by running pl2pm on the
file - you could even go as far as to use the Exporter module to export
your variables into the namespace of the program that uses it.
I would recomend that you read the perlmod manpage, and the manpages for
'vars' and 'strict' in the first place.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Sat, 03 Mar 2001 13:33:26 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Having trouble with variable scoping
Message-Id: <t5s1at0mhnui517mfh0lbfngjvatnfgo28@4ax.com>
Jeffry A. Nokes wrote:
>I have a problem that I cannot figure out. I have a Perl script (call
>it "main.pl" that includes another perl script (call it "subs.pl")
>containing all my subroutine definitions. I use the "require" function
>to include the file at runtime.
>---------------------
># file "main.pl"
>use strict;
>my $string = "Jeff needs help!";
>require "subs.pl";
>&Print_String
>exit (0);
>---------------------
># file "subs.pl"
>sub Print_String
> {print ("\$string = " . $string);
> }
>---------------------
>The output to STDOUT is
>$string =
You don't seem too familair wit hwath lexical scoping actualy means. You
declare the scalar $string with "my", with makes this a lexical
variable. The range of lexical variables is the surrounding block, or
the current file, if it's top level. In short: "my $string;" makes that
$string cannot possibly be read from within different source files.
There. Drop the "my" declaration, drop the "use strict;" if you can't
get it to work otherwise, too. Now it works, doesn't it? Because $string
now is a global variable. That's what you want.
Dawn this "use strict" everywhere philosophy, even for beginners! The
only way beginners know how to get rid of perl's complaints about
undeclared variables, is by using "my", but that is not the solution to
every single problem. Especially not if you NEED global variables.
Ok. Now that it works, try putting in "use strict" again. Let's try to
get rid of perl's complaints, without using "my".
The first way, is to use fully qualified variables, i.e. you explicitely
mention the package names. If your variable is in main, then you can use
the shorter "::" instead of "main::", thus: $::string is in ppackage
main. "strict" doesn't complain.
The other way, is to declare your global variables. If you need
compatibility with older perls, use "use vars", as in
use vars '$string';
Note that the variable name(s) all form an array of strings, including
the non-word prefix, '$'.
From 5.6.0 onwards, you can use our(). The advantage is that its syntax
is closer to "my".
our $string;
--
Bart.
------------------------------
Date: Sat, 03 Mar 2001 13:36:20 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Help Matt with small programs THANKS AGAIN!!
Message-Id: <5rs1atg5p533u4s5cikdp3n89t75j9n08d@4ax.com>
mshort wrote:
> HA!!! I got it!!
>
>$num=0;
> while ($num>=0){
> $num++;
> next if (int($num / 5) != ($num/5));
> last if $num==100;
> print "$num ";$num++;
> }
Note that now $num is updated at the start of the block. If you want to
update it at theEND of the block instead, it's safest to put the
"$num++" in a "continue" block.
--
Bart.
------------------------------
Date: 3 Mar 2001 10:52:01 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How do I DROP a table using XBase module
Message-Id: <97qich$gv8$1@orpheus.gellyfish.com>
In comp.lang.perl.misc Ben Kennedy <bkennedy99@home.com> wrote:
>
> "Don" <don@lclcan.com> wrote in message news:3A9E8F2F.8065A723@lclcan.com...
>
>> However, the docs state that the above statement will NOT overwrite if
>> it already exists. It then states that the table must be DROPPED first
>> via the "drop" method. Unfortunately, the docs don't state how to use
>> it nor is there an example.
>
> Well, I'm not sure about if there is an official method for it, but why not
> just unlink() the dbf file as you would any other?
>
(the original post hadnt turned up)
In fact the XBase manual does mention unlink() in the same paragraph.
drop must be called on an instance of XBase opened on the table you want
to drop :
use XBase;
my $foo = XBase->new('foo.dbf');
$foo->drop();
will drop foo.dbf.
Of course this all begs the question why the OP isnt using DBD::XBase where
the SQL syntax 'DROP TABLE foo' would work. DBD::XBase is installed alongside
XBase nowadays.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Sat, 03 Mar 2001 11:55:46 GMT
From: montep@about.com (Monte)
Subject: Re: How the C L P M turns
Message-Id: <3aa0db7c.46671630@news.hal-pc.org>
On 3 Mar 2001 07:10:11 GMT, dkcombs@panix.com (David Combs) wrote:
>In article <3A9D8490.4D6755FD@stomp.stomp.tokyo>,
>Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
>>
>>My Roberta The Remarkable Robot is now 1200 lines of Perl code
>>supported by over a gigabyte of data bases. Linking Roberta to her
>>databases is not a problem. However, more than half of her main
>>program is dedicated to grammar checking and writing mechanics.
>>Even so, she still creates, at times, on-the-fly, some of the
>>most wanged out crazy statements you could ever read, all perfectly
>>grammatically correct and highly logical yet so strange as to cause
>>me to tug at my dyed black corkscrewy hair. She is a cute one
>>capable of very clever conversation.
>>
>
>So, where IS this thing?
>
>David
Belleview, third ward, room fourteen. The one with the note on the
door saying "PLEASE DO NOt FORGET TO MEDICATE"
;)
f your gonna spam.....
admin@loopback, $LOGIN@localhost, $LOGNAME@localhost,
$USER@localhost, $USER@$HOST, -h1024@localhost, root@mailloop.com
root@localhost, postmaster@localhost, admin@localhost, abuse@localhost
Chairman Reed Hundt: rhundt@fcc.gov
Commissioner James Quello: jquello@fcc.gov
Commissioner Susan Ness: sness@fcc.gov
Commissioner Rachelle Chong: rchong@fcc.gov
US Postal Service: customer@email.usps.gov
Fraud Watch: fraudinfo@psinet.com
Pyramid Schemes: pyramid@ftc.gov
Federal Trade Commission: consumerline@ftc.gov
net-abuse@nocs.insp.irs.gov
------------------------------
Date: 3 Mar 2001 09:48:06 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Mail::Mailer & Mail::Send .. difficulties
Message-Id: <97qekm$epp$1@orpheus.gellyfish.com>
On Fri, 2 Mar 2001 15:28:03 -0800 Mahesh A wrote:
<snip>
> my %headers = {"From" => 'Perl Mailer <me@myhome.com>',
> "To" => 'me@myoffice.com',
> "Cc" => 'me@club.com',
> "Bcc" => 'me@shhh.com'
> };
> $mailer = new Mail::Mailer 'smtp', Server => 'mail.myhost.com';
> $mailer->open(\%headers);
>
>
If you had warnings switched on you would have got a message similar to:
Reference found where even-sized list expected
when you ran the code. You either want to change the curly braces in the
hash initialization to normal brackets or change headers to a normal scalar
$header and pass that directly to open without taking its reference.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: 3 Mar 2001 10:21:24 GMT
From: "Scott R. Godin" <dontspamthewebmaster@webdragon.munge.net>
Subject: MIME::Lite and MailTools
Message-Id: <97qgj4$f65$1@216.155.33.35>
Just curious:
Is it possible to create a MIME::Lite e-mail containing two file
attachments and then send said MIME::Lite 'object' using MailTools
instead of the default sendmail/smtp options in MIME::Lite?
The reason I mention this is that Net::SMTP isn't sending RFC-822 (is
that the correct rfc? it's been a while since I last got that error
message and started using MailTools instead) compliant headers on the
system I'm testing on.
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: Sat, 3 Mar 2001 12:42:07 -0000
From: "Stephen Collyer" <stephen@twocats.dont-spam.demon.co.uk>
Subject: Re: Para mode and <STDIN>
Message-Id: <983623452.4177.0.nnrp-02.9e98901a@news.demon.co.uk>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:97o58v$sto$1@mamenchi.zrz.TU-Berlin.DE...
> Buffering may have to do with what you have observed, but it's
> output buffering. If you set $| = 1, you'll get a clearer image.
Right, the penny's finally dropped - it's a trivial problem: with
$/ = '', perl does *not* return the terminator with data when
<STDIN> returns, so the original loop:
while(<STDIN>)
{
print;
}
has nothing to flush the buffer with, even in line mode.
>
> Doing that, you will observe there *is* a quirk with reading
> paragraphs from a tty. A sequence of newlines is only recognised
> when the first line of the next paragraph (or the final EOF) is
> ready to be read. This, however, is quite understandable: $/ = ''
> means that any sequence of two or more "\n" ends a paragraph.
> This implies that all trailing "\n" belong to the preceding
> paragraph, and this can only be recognized when something other
> than a "\n" is seen.
I'm not sure I'd call that a quirk. However, <STDIN> does
something different with terminators when $/ = "\n" and when
$/ = '' - I'd call that a quirk, if a relatively trivial one.
Steve Collyer
Netspinner Ltd.
------------------------------
Date: 3 Mar 2001 10:16:52 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Performing Character Escape Sequences On the Fly
Message-Id: <97qgak$gc0$1@orpheus.gellyfish.com>
On 3 Mar 2001 04:14:54 GMT John M. Gamble wrote:
>
> Is there any built-in perl method for taking a sequence of characters
> headed by a backslash, and replacing that with the actual
> character-escaped value?
>
> For example, say that i have a character string with a backslash
> immediately followed by an n. I want to change that into a newline
> character.
>
string eval will be what you are looking for here:
@a = qw(ab cd \ n 12 34 \ n);
$t = join "", @a;
$x = eval qq%"$t"% ;
print $x;
If the string is coming from a source you do not control you would be well
advised to examine its contents very closely before eval()ing it however.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Sat, 03 Mar 2001 11:48:39 GMT
From: "Parrot" <parrot0123@yahoo.ca>
Subject: Re: perl CGI output not shown in browser
Message-Id: <rS4o6.302327$Pm2.4386255@news20.bellglobal.com>
Ivica Letunic <Ivica.Letunic@EMBL-Heidelberg.de> wrote in message
news:uv8u25cik1e.fsf@nora.EMBL-Heidelberg.DE...
> My problem is that browsers do not show any output (or sometimes just the
> part that gets generated before the loop is shown) while the script is in
> the loop. So the 'print STDOUT ". $my_number...' is shown AFTER script
gets
> out of the loop.
>
> How do I make browsers print all output as soon as it is generated? I
> thought $| = 1 should be enough, but it isn't.
>
I haven't seen your entire program, so I don't know if you've done this, but
before your output will be displayed by the browser you must tell it that
you're actually giving it something to display. You do so with this line:
print "Content-type: text/html\n\n";
Then usually you'll want to print your normal HTML file stuff :
print "<HTML><HEAD><TITLE>My Page</TITLE></HEAD><BODY>";
What people like to do is put all this into a sub procedure and call it the
header. You print the header before you display anything to the browser -
and usually things work out fine.
Hope this helps.
------------------------------
Date: Sat, 03 Mar 2001 10:02:33 GMT
From: kj Copeland <kj@codegeek.org>
Subject: Re: Perl comments ??
Message-Id: <kj-4B4D90.02074303032001@news1.crdva1.bc.home.com>
In article <d8an6.217$_4.159258@news6-win.server.ntlworld.com>,
"deborah.knight1" <debbie.knight@ntlworld.com> wrote:
> Hello,
>
> I've edited a cgi scrpit using notepad, wordpad and ultraedit, using both
> the # and /*..*/ for comments but none work, with the comments showing up in
> both netscape and IE from home and my server.
>
> This is the code:
>
> #!/usr/local/bin/perl
>
> /*comment see if it works*/
> #this perhaps
>
> print "content-type:text/html\n\n";
>
> <HTML><HEAD><TITLE>Hiya there</TITLE></HEAD>
> <BODY><H1>Web page</H1></BODY></HTML>
>
> Any hints gratefully recieved.
>
> Debbie Knight
Hello Debbie,
I can't comment on Windows editors, but using one that understands
Unix line breaks will make your life easier on some systems.
Perl comments use '#' at the beginning of the comment, which extends
to the end of the line.
If the webserver is showing you the source to the CGI, it is likely
that the webserver is expecting the CGI script to have a given extension
(usually .cgi, but this is a configurable thing on most webservers).
When a CGI script doesn't have the extension the webserver is expecting,
it won't execute. A fairly typical webserver configuration will send
anything it doesn't understand as text/plain, hence your script doesn't
get run, but simply output.
Note also that if it is a Unix box (I can't comment on IIS -- I don't
use it), the CGI script has to be set executable. Usually you can do
this with "site CHMOD 0755 filename.cgi" from a command-line ftp client,
or from the command line (if ssh/telnetted into the Unix box) with
"chmod 0755 filename.cgi" (or "chmod +x filename.cgi", if that's easier
for you to remember.
Hope this helps.
Cheers,
~kj
------------------------------
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 V10 Issue 404
**************************************