[29119] in Perl-Users-Digest
Perl-Users Digest, Issue: 363 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 20 06:09:48 2007
Date: Fri, 20 Apr 2007 03:09:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 20 Apr 2007 Volume: 11 Number: 363
Today's topics:
Re: ActiveState vs. "C:\Program Files\" and "C:\Progra~ <bik.mido@tiscalinet.it>
Re: Any Help? Stuck trying to create cgi perl program <joe@inwap.com>
Re: Booleans in Perl <joe@inwap.com>
Re: Booleans in Perl <wahab-mail@gmx.de>
Re: FAQ 9.20 How do I send mail? -- PROBLEM SOLVED! <timdooling@qconline.com>
Re: FAQ 9.20 How do I send mail? <timdooling@qconline.com>
Re: FAQ 9.20 How do I send mail? anno4000@radom.zrz.tu-berlin.de
Re: FAQ 9.20 How do I send mail? <josef.moellers@fujitsu-siemens.com>
Re: How do I use a literal comma in a system command <joe@inwap.com>
Re: How do I use a literal comma in a system command anno4000@radom.zrz.tu-berlin.de
Re: How to make perl script executable from anywhere on <redgrittybrick@spamweary.foo>
Re: Printing the next line of text of the file <joe@inwap.com>
Re: Printing the next line of text of the file anno4000@radom.zrz.tu-berlin.de
Re: Server For Rent? Where? <nikos1337@gmail.com>
Re: Server For Rent? Where? <spamtrap@dot-app.org>
Share objects between processes - how? patrik.xx.hoiem-flyckt@ericsson.com
Re: Share objects between processes - how? <bastian.ballmann@twc.de>
Re: Share objects between processes - how? anno4000@radom.zrz.tu-berlin.de
Using a Perl program to send different images depending <timdooling@qconline.com>
Re: Using a Perl program to send different images depen <bik.mido@tiscalinet.it>
Re: What are the vestiges of Pascal left in Perl? <joe@inwap.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 20 Apr 2007 11:58:02 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: ActiveState vs. "C:\Program Files\" and "C:\Progra~1\"
Message-Id: <383h23diktba747mlesq2vnoeun0fkjm0q@4ax.com>
On 19 Apr 2007 15:53:08 -0700, pt <mnemotronic@gmail.com> wrote:
>that without the whole "C:\Program Files\ActiveState.com" dir and
>link, but I have this personal bias against installing everything
>right at the root, even though it it IS like pissing upstream into a
>brick wall. I like the ideas expressed in the Hierarchical File
I strongly agree with you. Unfortunately Windows doesn't enforce this.
Yes, typically programs install themselves under "C:\Program Files"
(which incidentally in Italy is fortunately "C:\Programmi", with no
spaces) but that's for GUI based programs. I have nothing agains GUIs,
but I often need CLI based ones too, and then the problem is that the
PATH env variable even nowadays still has a limited lenght, which is a
PITA. Thus one has first or later to resort to tricks of some sort...
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Fri, 20 Apr 2007 02:24:47 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Any Help? Stuck trying to create cgi perl program
Message-Id: <e_mdncLIfOQ85bXbnZ2dnUVZ_jqdnZ2d@comcast.com>
shadkeene@hotmail.com wrote:
> The code I was using prior to this was utilizing hashes but didn't
> return the values of unchecked boxes...
>
> my %form;
> foreach my $p (param()) {
> $form($p) = param($);
> print OUT "$form{$p},";
> }
That's exactly the thing I was warning you to not use.
If on Monday param() returns ("AE", "EG", "amTAF", "pmTAF")
and on Tuesday returns ("amTAF", "EG", "AE", "pmTAF"), then
the CSV created will be really screwed up because the fields
are not in the right order. You need to force them to be in order.
my @fields = qw(name addr1 addr2 phone zip box1 box2 box3);
print OUT join(',',@fields),"\n"; # Print header line
my @output;
push @output,(param($_) || '""') for @fields;
print OUT join(',',@output),"\n";
-Joe
------------------------------
Date: Fri, 20 Apr 2007 01:50:02 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Booleans in Perl
Message-Id: <FLednSVt0d_h7bXbnZ2dnUVZ_s-rnZ2d@comcast.com>
David Williams wrote:
> Small question.
> Why does PERL do the following
>
> $a=FALSE;
There's not any point in going any further until you understand
what Perl considers to be true and false.
foreach (TRUE, FALSE, "any non-null string", 1, 0.0, "1", "0", "00", "", undef) {
if ($_) {
print "Perl considers '$_' to be true\n";
} else {
print "Perl considers '$_' to be false\n";
}
}
------------------------------
Date: Fri, 20 Apr 2007 11:47:33 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Booleans in Perl
Message-Id: <f0a2k2$3ii$1@mlucom4.urz.uni-halle.de>
David Williams wrote:
> Small question.
> Why does PERL do the following
>
> $a=FALSE;
> $b=FALSE;
> $c=($a && $b);
> if($c){
> echo "the expr evaluates to true";
> }
> else{
> echo "the expr evaluates to false;
> }
>
> I always get "the expr evaluates to true";
>
> if it is false && false, should it not be false?
> My workaround is to use the eq operand
No, use some small code extension as shown and
proceed as you started:
==>
use strict;
use warnings;
package php;
sub echo { print @_ }
package bool;
sub true { return 1 }
sub false { return 0 }
use constant TRUE => true;
use constant FALSE => false;
package main; # <== your program starts here
my $a1 = bool::TRUE;
my $b1 = bool::FALSE;
my $c = ($a1 && $b1);
if( $c ){
php::echo "the expr evaluates to true"
}
else{
php::echo "the expr evaluates to false"
}
<==
I guess, perl6 will have the bool included.
Regards
M.
------------------------------
Date: Fri, 20 Apr 2007 03:18:20 -0500
From: "timdooling" <timdooling@qconline.com>
Subject: Re: FAQ 9.20 How do I send mail? -- PROBLEM SOLVED!
Message-Id: <1177057100_15665@sp12lax.superfeed.net>
"timdooling" <timdooling@qconline.com> wrote:
>I found the solution to the problem. It was quite simple: The server couldn't find the sendmail program because none of the directories existed as such.
I removed the directories, and simply used "sendmail -t". VOILA! it worked, and close returned 1.
I decided to try this when I checked the environmental variables for the server and determined that the "path" variable was set already to some of the paths listed in the example, so the use of the path information was not necessary and causing problems. When I removed the path info, the problem was immediately solved.
The quote marks made a difference around the \n, too. It just comes out as '\n' without the quote marks. But the mail still wasn't sent until I removed the path information from the sendmail file info.
Thanks for the help.
tim dooling
------------------------------
Date: Fri, 20 Apr 2007 02:14:47 -0500
From: "timdooling" <timdooling@qconline.com>
Subject: Re: FAQ 9.20 How do I send mail?
Message-Id: <1177053287_15341@sp12lax.superfeed.net>
"timdooling" <timdooling@qconline.com> wrote:
>I remade the code as follows (I noticed the lack of newline):
#!/usr/bin/perl --
require 5;
if (open(LOG,">>sendmail.txt"))
{
my @sendmail = (
# '/usr/sbin/sendmail -t',
# '/usr/bin/sendmail -t',
# '/usr/lib/sendmail -t',
'/usr/sendmail -t',
'/bin/sendmail -t'
);
foreach(@sendmail)
{
if (my $open_result = open(SENDMAIL, "|$_"))
{
print SENDMAIL 'From: <timdooling@qconline.com>\n';
print SENDMAIL 'To: <timdooling@qconline.com>\n';
print SENDMAIL 'Subject: test\n';
print SENDMAIL 'Content-type: text/plain\n\n';
print SENDMAIL 'test\n\n';
print LOG $_."\n";
my $close_result = close(SENDMAIL);
print LOG "open result: $open_result close result: $close_result\n";
}
}
close(LOG);
}
print "Content-type: text/html\n\n";
print "Hello, World.";
This executes and prints the "Hello, World!", so apparently there are no errors in the code.
The log file reads:
/usr/sendmail -t
open result: 23939 close result:
/bin/sendmail -t
open result: 23940 close result:
The first three are commented out because they generate errors and kill the program. The last two obviously go through.
Still no mail. I am stumped.
I assume it is a server problem at this point. Any ideas?
------------------------------
Date: 20 Apr 2007 07:28:53 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: FAQ 9.20 How do I send mail?
Message-Id: <58r8dlF2f1hnnU1@mid.dfncis.de>
timdooling <timdooling@qconline.com> wrote in comp.lang.perl.misc:
> "timdooling" <timdooling@qconline.com> wrote:
> >I remade the code as follows (I noticed the lack of newline):
>
> #!/usr/bin/perl --
> require 5;
> if (open(LOG,">>sendmail.txt"))
> {
> my @sendmail = (
> # '/usr/sbin/sendmail -t',
> # '/usr/bin/sendmail -t',
> # '/usr/lib/sendmail -t',
> '/usr/sendmail -t',
> '/bin/sendmail -t'
> );
> foreach(@sendmail)
> {
> if (my $open_result = open(SENDMAIL, "|$_"))
> {
> print SENDMAIL 'From: <timdooling@qconline.com>\n';
> print SENDMAIL 'To: <timdooling@qconline.com>\n';
> print SENDMAIL 'Subject: test\n';
> print SENDMAIL 'Content-type: text/plain\n\n';
> print SENDMAIL 'test\n\n';
> print LOG $_."\n";
> my $close_result = close(SENDMAIL);
> print LOG "open result: $open_result close result: $close_result\n";
> }
> }
> close(LOG);
> }
>
> print "Content-type: text/html\n\n";
> print "Hello, World.";
>
> This executes and prints the "Hello, World!", so apparently there are no
> errors in the code.
>
> The log file reads:
>
> /usr/sendmail -t
> open result: 23939 close result:
> /bin/sendmail -t
> open result: 23940 close result:
>
> The first three are commented out because they generate errors and kill
> the program. The last two obviously go through.
>
> Still no mail. I am stumped.
Well there wouldn't be any if sendmail wasn't found in any of the
prospective locations. It would still print "Hello, World". No
contradiction there.
> I assume it is a server problem at this point. Any ideas?
Capture the text you intend to print to sendmail and look at it. You'll
find that the header lines still run together without any line feeds.
Sendmail won't like that. Use double quotes instead of single.
Anno
------------------------------
Date: Fri, 20 Apr 2007 10:14:40 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: FAQ 9.20 How do I send mail?
Message-Id: <f09spr$8d4$1@nntp.fujitsu-siemens.com>
timdooling wrote:
> "timdooling" <timdooling@qconline.com> wrote:
> print SENDMAIL 'To: <timdooling@qconline.com>\n';
Single-quoted text won't convert escaped characters: a '\n' is two=20
characters, a "\n" is only one.
Josef
--=20
These are my personal views and not those of Fujitsu Siemens Computers!
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Fri, 20 Apr 2007 01:57:58 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: How do I use a literal comma in a system command
Message-Id: <TM6dnU6ezpbE77XbnZ2dnUVZ_gudnZ2d@comcast.com>
Tim wrote:
> $cmd="$p4 obliterate -y \@$changenumber, \@$changenumber";
> open(OBLITERATE,"$cmd|");
>
> sh: line 1: ,@813: command not found
Something to remember in the future: whenever system() or other
function gives unexpected results, be sure to print the string
you're about to execute to make sure it is what you think it is.
print "Opening a pipe to: '$cmd'\n";
open(OBLITERATE,"$cmd|") or die "Pipe open of '$_' failed: $!\n";
-Joe
------------------------------
Date: 20 Apr 2007 09:12:05 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: How do I use a literal comma in a system command
Message-Id: <58ref5F2hsq50U2@mid.dfncis.de>
Joe Smith <joe@inwap.com> wrote in comp.lang.perl.misc:
> Tim wrote:
>
> > $cmd="$p4 obliterate -y \@$changenumber, \@$changenumber";
> > open(OBLITERATE,"$cmd|");
> >
> > sh: line 1: ,@813: command not found
>
> Something to remember in the future: whenever system() or other
> function gives unexpected results, be sure to print the string
> you're about to execute to make sure it is what you think it is.
>
> print "Opening a pipe to: '$cmd'\n";
> open(OBLITERATE,"$cmd|") or die "Pipe open of '$_' failed: $!\n";
With the shell-invoking one-argument form of system(), a useful variant
is to replace the actual command with "echo" (under Unix) for a test.
That way you get to see the command arguments in the form the shell
passes them on.
Anno
------------------------------
Date: Fri, 20 Apr 2007 09:57:40 +0100
From: RedGrittyBrick <redgrittybrick@spamweary.foo>
Subject: Re: How to make perl script executable from anywhere on windows?
Message-Id: <46288091$0$6952$fa0fcedb@news.zen.co.uk>
veg_all@yahoo.com wrote:
> I have ActivePerl installed and want to place all my scripts in one
> directory but be able to execute them from anywhere. So if I type perl
> myscript.pl from any directory/folder in windows dos prompt it will
> run.
>
Add the directory which contains your scripts to the PATH variable.
For example, if you have scripts x.pl, y.pl and z.pl in
C:\My\Perl\Scripts you can type these commands from any directory
D:\Temp> PATH=%PATH%;C:\My\Perl\Scripts
D:\Temp> x.pl
D:\Temp> cd \Other
D:\Other> x.pl
You can make the PATH change permanent as follows:
# From the desktop, right click My Computer and click properties.
# In the System Properties window, click on the Advanced tab.
# In the Advanced section, click the Environment Variables button.
# Finally, in the Environment Variables window, highlight the path
variable in the Systems Variable section and click edit. Add or modify
the path lines with the paths you wish the computer to access. Each
different directory is separated with a semicolon
Note that this has *nothing* to do with perl.exe being on the path or
file associations for .pl. The ActiveState installer will already have
taken care of both of these. I think the other responder has
misunderstood your question.
------------------------------
Date: Fri, 20 Apr 2007 02:01:37 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Printing the next line of text of the file
Message-Id: <TM6dnUmezpav7rXbnZ2dnUVZ_gudnZ2d@comcast.com>
Jim Gibson wrote:
> for( <$fh> ) {
> if( /$rg_1/ ) {
> print "$1 $2\n"
> my $next = <$fh>;
Won't work. for(<$fh>) reads in the entire file, leaving
nothing for the next <$fh> to read.
Use while(<$fh>), not for(<$fh>).
-Joe
------------------------------
Date: 20 Apr 2007 10:03:30 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Printing the next line of text of the file
Message-Id: <58rhfiF2e5e5nU1@mid.dfncis.de>
Mirco Wahab <wahab-mail@gmx.de> wrote in comp.lang.perl.misc:
> Nene wrote:
> > I want to print (2007-04-18) and (00:05:05) and I want to print where
> > (login_id = 'XSKW0010') which is the next line following this huge
> > select query.
> >
> > Here is the data: (remember, everything from 00004C09 to 'restrict
> > ip' ) is one line.
>
> If I understood correctly, you want simply
> print [always] the line following your match,
> which contains a date and a time?
>
> Then something like this should work:
>
>
> open( my $fh, '<', shift ) or die "can't open file $!";
>
> my $flag = 1;
> my $rg = qr/^\w+\s+(\d{4}-\d{2}-\d{2})\s+(\d{2}:\d{2}:\d{2})(?{$flag=0})/;
>
> while( <$fh> ) {
> if( /$rg/ ) {
> print "$1 $2\n"
> }
> else {
> print unless $flag++
> }
> }
Uh... that won't print anything unless you initialize $flag to false,
and even then it'll work for only one pair of lines. Simplifying the
regex still further:
my $flag;
while ( <DATA> ) {
print if $flag; # the line after a match
print if $flag = /xxx/; # the matching line
}
Anno
------------------------------
Date: 20 Apr 2007 00:30:45 -0700
From: skieros <nikos1337@gmail.com>
Subject: Re: Server For Rent? Where?
Message-Id: <1177054245.129812.36650@y80g2000hsf.googlegroups.com>
On Apr 20, 4:39 am, Tad McClellan <t...@augustmail.com> wrote:
> Please stop littering in our park.
Please stop sending me insulting mails, contact me with insulting
messages through instant messengers and now talk to me from here you
sick person.
You send me 5 mails yesterday and every hour talk to me to IM and now
here. Youa re one sick puppy. Go stick your head somewhere...
------------------------------
Date: Fri, 20 Apr 2007 04:05:15 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Server For Rent? Where?
Message-Id: <m2abx3a2tg.fsf@local.wv-www.com>
skieros <nikos1337@gmail.com> writes:
> On Apr 20, 4:39 am, Tad McClellan <t...@augustmail.com> wrote:
>
>> Please stop littering in our park.
>
> Please stop sending me insulting mails, contact me with insulting
> messages through instant messengers and now talk to me from here you
> sick person.
>
> You send me 5 mails yesterday and every hour talk to me to IM and now
> here. Youa re one sick puppy. Go stick your head somewhere...
You're as deluded as Moronzilla.
*plonk*
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: 20 Apr 2007 01:13:40 -0700
From: patrik.xx.hoiem-flyckt@ericsson.com
Subject: Share objects between processes - how?
Message-Id: <1177056820.643867.159930@d57g2000hsg.googlegroups.com>
Hi,
I have a problem that you might help me with. I have a client app made
in perl/tk that speaks with a server (RPC::PlServer, built on
Net::Daemon). This server forks a process per product type (PT). You
can run different perl scripts for each PT (to test the PT). Since
RPC::PlClient makes synchronous calls, I want to either thread or fork
a process while running scripts for the PTs, since the scripts can
take several hours to run. Otherwise the client will get locked during
this time. I have tried a threaded solution and a forked solution and
they work fine as long as I don't have to share anything. But I have a
session object, containing session variables that I have to get back
from the child process after it's finished. I've tried threads::shared
(I get: LogHandler not of correct type or something like that) with no
success and IPC::Shareable in the forked solution with no success ( I
get: Could not create semaphore set: No space left on device). Is
there any good documentation about these different solutions out
there? Can someone point me (to anything else than the CPAN info)?
Well I've searched the net and haven't found anything that has shed
light on this. Well I've read something about the semaphore fault...
If you need more info don't hesitate to ask me. I'm on Solaris by the
way.
Regards
------------------------------
Date: Fri, 20 Apr 2007 10:43:31 +0200
From: Bastian Ballmann <bastian.ballmann@twc.de>
Subject: Re: Share objects between processes - how?
Message-Id: <f09urj$slt$1@murphy.mediascape.de>
Hi!
patrik.xx.hoiem-flyckt@ericsson.com schrieb:
> Is
> there any good documentation about these different solutions out
> there? Can someone point me (to anything else than the CPAN info)?
> Well I've searched the net and haven't found anything that has shed
> light on this. Well I've read something about the semaphore fault...
>
I dont know a documentation about the different solutions, but i've
used two different ones to solve that kind of problem.
Try to use SOAP or serialize your objects with Storable and pump them
over the pipe.
HTH
Basti
------------------------------
Date: 20 Apr 2007 08:48:17 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Share objects between processes - how?
Message-Id: <58rd2hF2hsq50U1@mid.dfncis.de>
<patrik.xx.hoiem-flyckt@ericsson.com> wrote in comp.lang.perl.misc:
> Hi,
>
> I have a problem that you might help me with. I have a client app made
> in perl/tk that speaks with a server (RPC::PlServer, built on
> Net::Daemon). This server forks a process per product type (PT). You
> can run different perl scripts for each PT (to test the PT). Since
> RPC::PlClient makes synchronous calls, I want to either thread or fork
> a process while running scripts for the PTs, since the scripts can
> take several hours to run. Otherwise the client will get locked during
> this time. I have tried a threaded solution and a forked solution and
> they work fine as long as I don't have to share anything. But I have a
> session object, containing session variables that I have to get back
> from the child process after it's finished.
Is the session object actually *shared* between processes (or threads)?
I mean, do processes access the object concurrently?
If the session object belongs to only one process at any time you can
pass it back and forth using standard serialization methods (Storable,
Data::Dumper, alternatives on CPAN) without actually sharing it.
Anno
------------------------------
Date: Fri, 20 Apr 2007 04:06:38 -0500
From: "timdooling" <timdooling@qconline.com>
Subject: Using a Perl program to send different images depending upon the user
Message-Id: <1177059998_15701@sp12lax.superfeed.net>
The following code can be used to send an HTML file:
#!/usr/bin/perl --
require 5;
print "Content-type: text/html\n\n";
if (open(HTMLFile,"<HTMLfile.txt"))
{
while (<HTMLFile>)
{
print $_;
}
close(HTMLFile);
}
I am planning on using this coding to send a file to the user depending upon such things as whether the user has cookies enabled on his browser, or is banned from viewing my website just because.
I want to be able to send an image file back to a user depending upon who the user is also. As yet, I have not been able to figure this one out.
I assume it would start out like this:
#!/usr/bin/perl --
require 5;
print "Content-type: image/gif\n\n"; # or image/jpeg or something like that depending on the file
if (open(IMGFile,"<my_image.gif")) # or my_image.jpg or whatever
{
binmode(IMGFile);
binmode(STDOUT);
while (<IMGFile>) # or whatever character-wise read would be appropriate.
{
print PACK($_);
}
close(IMGFile);
}
I have tried a couple of iterations of this without success.
Any ideas?
timdooling
------------------------------
Date: Fri, 20 Apr 2007 11:41:04 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Using a Perl program to send different images depending upon the user
Message-Id: <rb1h23d6dueabpchku33reob9aq9e4d283@4ax.com>
On Fri, 20 Apr 2007 04:06:38 -0500, "timdooling"
<timdooling@qconline.com> wrote:
>#!/usr/bin/perl --
>require 5;
Notwithstanding what our resident troll will probably tell you, always
ask perl to give you all the help it can and do a favour to yourself
just by
use strict;
use warnings;
>print "Content-type: text/html\n\n";
Notwithstanding what our resident troll will probably tell you, let
CGI.pm do the dirty work for you.
>if (open(HTMLFile,"<HTMLfile.txt"))
> {
> while (<HTMLFile>)
> {
> print $_;
Since $_ is the implicit argument to print(), for clarity you would
either omit it altogether, or use a more descriptive variable name.
>I am planning on using this coding to send a file to the user
>depending upon such things as whether the user has cookies enabled on
>his browser, or is banned from viewing my website just because.
This gets discussed quite often. Also in this case you can reinvent
the wheel yourself, with the risk of doing it wrong, or more
reasonably you can use one out of many modules dedicated to this task.
I believe CGI::Session is one such module that gets mentioned quite
often.
>I want to be able to send an image file back to a user depending upon
>who the user is also. As yet, I have not been able to figure this one
>out.
This is perfectly possible, and easy, once you spit out the correct
header, and probably take care of binmode()ing filheandles, just to be
sure.
>print "Content-type: image/gif\n\n"; # or image/jpeg or something like that depending on the file
>if (open(IMGFile,"<my_image.gif")) # or my_image.jpg or whatever
> {
> binmode(IMGFile);
> binmode(STDOUT);
> while (<IMGFile>) # or whatever character-wise read would be appropriate.
You would probably want to slurp the file in all at once. Just locally
undef $/ or... err... well... use the oft mentioned (here)
File::Slurp.
> print PACK($_);
What the hell is PACK() supposed to be? Just print().
{
open my $fh, '<:raw', 'my_image.gif' or next;
local $/;
binmode STDOUT; # if really need be.
print scalar <$fh>;
}
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Fri, 20 Apr 2007 02:06:14 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: What are the vestiges of Pascal left in Perl?
Message-Id: <a7adncIadLDV6bXbnZ2dnUVZ_uOmnZ2d@comcast.com>
Jean-Baptiste Mazon wrote:
> Hi,
>
> The perl manpage mentions the following:
>
> Perl combines (in the author's opinion, anyway) some of the
> best features of C, *sed*, *awk*, and *sh*, so people familiar
> with those languages should have little difficulty with it.
> (Language historians will also note some vestiges of *csh*,
> Pascal, and even BASIC-PLUS.)
>
> I could easily find a few examples of Perl features common with C,
> sed, awk and sh. With a little additional research, I could find
> similarities with csh and BASIC-PLUS, too.
BASIC-PLUS had a very useful idiom:
PRINT IF POS(0)
That says to output CR and LF if the terminal's print head was
not already at the left margin. I was very glad to see that
Larry Wall had adopted the
statement if condition;
syntax into Perl.
-Joe
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V11 Issue 363
**************************************