[19822] in Perl-Users-Digest
Perl-Users Digest, Issue: 2017 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 26 14:06:49 2001
Date: Fri, 26 Oct 2001 11:05:13 -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: <1004119512-v10-i2017@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 26 Oct 2001 Volume: 10 Number: 2017
Today's topics:
Re: $ENV not defined (Tad McClellan)
Re: $ENV not defined (Tad McClellan)
Re: Automated html index ? <please@no.spam>
Re: CPAN.pm complaining all the time <lmoran@wtsg.com>
Re: Filling in PDF files using PERL <cpryce@pryce.net>
Re: getting %errorlevel% values with perl? <darkon@one.net>
Re: handling numbers with leading zeros <zkent@adelphia.net>
hash slices through references <gopalan@cs.sc.edu>
Re: hash slices through references <uri@sysarch.com>
Re: implicit split to @_ (Andrew J. Perrin)
Re: Memory management <dan@tuatha.sidhe.org>
Re: NEWBIE: double sort on a string <uri@sysarch.com>
Re: NEWBIE: double sort on a string <please@no.spam>
Re: NEWBIE: double sort on a string <please@no.spam>
Re: NEWBIE: double sort on a string <uri@sysarch.com>
PATH and output questions <lmoran@wtsg.com>
Re: Ping Script Help Needed <alexd@NOSPAMsynergycsi.com>
Print Question (file & cgi) <craigandbarbara@pacbell.net>
Re: Printing Images in a Web browser <jeff@vpservices.com>
Re: Printing Images in a Web browser <bart.lateur@skynet.be>
Re: problem with break... (Mark Jason Dominus)
Regular expression help <witkowsk@pop900.gsfc.nasa.gov>
Re: Regular expression help (Tad McClellan)
Re: Regular expression help <witkowsk@pop900.gsfc.nasa.gov>
Re: Security- Upload scripts (EED)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 26 Oct 2001 14:03:10 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: $ENV not defined
Message-Id: <slrn9tija6.6gc.tadmc@tadmc26.august.net>
Lars Snith <lars.snith@inpactmicro.com> wrote:
>I traced the problems to the $ENV variable that
>is undefined.
There is no scalar $ENV. The environment is in the %ENV _hash_.
>print "At $date, $ENV{'REMOTE_HOST'} came here from <a
>href=\"$ENV{'HTTP_REFERER'}\">$ENV{'HTTP_REFERER'}</a> using
>$ENV{'HTTP_USER_AGENT'}.\n";
>
>LOG using -w:
>Use of uninitialized value at snok.pl line 117.
>Use of uninitialized value at snok.pl line 117.
>Use of uninitialized value at snok.pl line 117.
Nope. It has nothing to do with Perl. perl just captures whatever
environment the server sets up for it. Your new server appears
to not set some of the env vars.
You have a server question, not a Perl question. Try asking in
a WWW-related newsgroup.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 26 Oct 2001 15:02:07 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: $ENV not defined
Message-Id: <slrn9tiqcc.6q3.tadmc@tadmc26.august.net>
Lars Snith <lars.snith@inpactmicro.com> wrote:
>OK, OK!
>
>Thanks for the help on the matter,
You are the only person who knows who you are addressing.
You should quote the text you're commenting on, or at the very least
include a correct References header. (you are talking to yourself
when you followup to your own posting)
>off-topic or not.
Everybody makes mistakes. Just try and not make it the next time.
It is a symptom that you have not correctly identified the nature
of your problem.
>But reading up on the subject takes time, and I needed
>to find a quick way
Be very careful.
That sounds like transfering your work to hundreds of others.
I hope that isn't what happened.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 26 Oct 2001 15:48:39 GMT
From: Andrew Cady <please@no.spam>
Subject: Re: Automated html index ?
Message-Id: <87hesmz9og.fsf@homer.cghm>
"Leary" <leary@foad.NOSPAM.org> writes:
> While this provides a wealth of information and code to play with, I
> need to get the "title" and "updated" info from within each html
> doc, not the file mod time. I could really use a working example of
> using the HTML::Parser or other routine. I played with HTML::Parser
> quite a while yesterday and am not having much luck so far.
I'm not sure exactly how the update time is stored in your HTML files.
Here's how to get just the title:
#!/usr/bin/perl -w
use strict;
use HTML::HeadParser;
use File::Slurp;
for (< *.{htm,html} >) {
my $html = new HTML::HeadParser;
$html->parse(scalar read_file($_));
printf "%s:\nTitle: %s\n\n", $_, $html->header('Title');
}
This is basically taken out of the HTML::HeadParser man page...
------------------------------
Date: Fri, 26 Oct 2001 10:04:10 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: CPAN.pm complaining all the time
Message-Id: <58qittspkkcr7065dum0nn1mk4i1h2b0uc@4ax.com>
On 25 Oct 2001 21:00:29 -0700, toddrw69@excite.com (trwww) wrote
wonderful things about sparkplugs:
>perl -MCPAN -e 'force install Net::FTP' ...?
oh that's what "won't install with out force means"
thanks
>
>Lou Moran <lmoran@wtsg.com> wrote in message news:<2k3gttc10oaf9ilice5s0lu6ubjg43132e@4ax.com>...
>> On Wed, 24 Oct 2001 19:28:14 BST, spam@freeuk.com (Stephen Patterson)
>> wrote wonderful things about sparkplugs:
>>
>> SNIP
>> >>> but it always complains about
>> >>> Net::FTP but won't let me install Net::FTP!
>> >
>> >Have you tried just 'install Net::FTP'?
>>
>> doesn't work. It's no big deal I guess
--
TMTOWTDI: My way tends to be wrong...
lmoran@wtsg.com
------------------------------
Date: Fri, 26 Oct 2001 10:30:35 -0500
From: cpryce <cpryce@pryce.net>
Subject: Re: Filling in PDF files using PERL
Message-Id: <B7FEEBCB.1B9C%cpryce@pryce.net>
in article 86ofmvwupn.fsf@jon_ericson.jpl.nasa.gov, Jon Ericson at
Jon.Ericson@jpl.nasa.gov wrote on 10/25/01 11:27 AM:
>> I have a PDF file (application form) in which I would like to create form
>> fields using Adobe Acrobat (writer). I'm wondering whether there is a way to
>> fill in the fields I create in the PDF file using PERL?
>
> Have you looked at CPAN? <http://search.cpan.org> If you have to
> modify or write a module, consider contibuting your code so others can
> use it.
There are modules on CPAN to create PDF files from scratch. A good one is
Matt Seargent's PDFLib.
However, if you are just filing in PDF forms, that can be done with Perl
with out the use of any additional modules and without using any of Adobe's
Tools. Adobe Acrobat uses a special format for its forms, FDF. However, FDF
is a simple to understand text format.
If you have the full version of Acrobat, fill out a form, and export it,
choosing FDF if you have the choice. Save the FDF file to disk, and examine
it in a Text editor. You will see that the format can be recreated.
We have written Perl scripts to fill in Corporate forms, calendars, etc via
PDF. All without modules or scripting the Acrobat Writer.
I have a silly demonstration in progress, if you'd like, contact me via
e-mail and we'll take up the off-topic conversation, and I can send a URL to
a demonstration page.
cp
------------------------------
Date: Fri, 26 Oct 2001 15:35:08 -0000
From: David Wall <darkon@one.net>
Subject: Re: getting %errorlevel% values with perl?
Message-Id: <Xns914675C3CB83Edarkononenet@207.126.101.97>
ek <e_kelleher@hotmail.com> wrote on 26 Oct 2001:
> Tha's exactly what I'm looking to catch (the 2 value that echo
> %errorlevel% returns after the dir rubbish) and cannot with perl. If,
> as I said, I do it with a batch file it returns 2 from echo
> %errorlevel% but perl returns zero. At the moment the only way I can
> get around it is to call a 2-line batch file with perl but if at all
> possible I need to get away from any dependency on batch files to make
> it portable to Solaris.
Without seeing your code, none of us here can offer much in the way of
suggestions. (Assuming they're interested; some aren't because it
involves MS Windows) What is the code you are using? What output or
error messages do you get?
Or maybe you could tell us more about what you're trying to do instead of
the problems with the particular approach you've been trying? That might
evoke some more useful suggestions than what I've been able to offer.
--
David Wall
darkon@one.net
------------------------------
Date: Fri, 26 Oct 2001 17:01:13 GMT
From: "Zachary Kent" <zkent@adelphia.net>
Subject: Re: handling numbers with leading zeros
Message-Id: <tFgC7.11006$EO1.1165223@news1.news.adelphia.net>
----- Original Message -----
From: "John W. Krahn" <>
> Zachary Kent wrote:
> >
> > Our website collects Social Security Numbers and I have had problems
with
> > Perl assuming that leading zeros are not needed and throws them out.
How do
> > I tell Purl(sic)[1] to treat a variable as a string when it contains
only numbers?
Now how many programmers actually know what sic means? Ex-journalists
maybe? My wife is a writer....
> One word - context - if you use a scalar in a numerical context it's a
> number, in a string context it's a string.
I understand the context issue. The problem is that Perl thinks that
012345678 should be 12345678 (removes the leading zero). However, there are
SSNs that contain leading zeros. I have been thinking about prefacing the
number with a letter just to keep Perl from making the assumption that it is
a number and losing the zero.
> [1] I assume you mean Perl :-)
Yes, I do. That was a typo that my spell checker missed. I've been using
Perl for years. When I saw that I yelled, "I'll look like a newb!"<sigh>
Zach
------------------------------
Date: Fri, 26 Oct 2001 11:21:59 -0500
From: Gopi Sundaram <gopalan@cs.sc.edu>
Subject: hash slices through references
Message-Id: <Pine.A41.4.33.0110261115580.15790-100000@gopi.austin.ibm.com>
Hello all,
I have a hash-ref like so:
$hashref = { one => 1, two => 2, three => 3, ...};
Is there a clean way of taking a slice of this hash? Right now, I have
this bletcherousness:
@ar = @{%{$hashref}}{'one', 'three'};
Thanks,
Gopi.
--
Gopi Sundaram
gopi@cse.sc.edu
------------------------------
Date: Fri, 26 Oct 2001 16:43:00 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: hash slices through references
Message-Id: <x766921hdp.fsf@home.sysarch.com>
>>>>> "GS" == Gopi Sundaram <gopalan@cs.sc.edu> writes:
GS> Hello all,
GS> I have a hash-ref like so:
GS> $hashref = { one => 1, two => 2, three => 3, ...};
GS> Is there a clean way of taking a slice of this hash? Right now, I have
GS> this bletcherousness:
GS> @ar = @{%{$hashref}}{'one', 'three'};
that is bletcherousness because it is wrong. you don't need the %{} as
the @{}{} is the proper way to deref a hash ref and make a slice.
@ar = @{$hashref}{'one', 'three'};
it still isn't pretty but it works.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs -------------------------- http://jobs.perl.org
------------------------------
Date: 26 Oct 2001 11:19:56 -0400
From: aperrin@email.unc.edu (Andrew J. Perrin)
Subject: Re: implicit split to @_
Message-Id: <87u1wml97n.fsf@hm269-26876.socsci.unc.edu>
tadmc@augustmail.com (Tad McClellan) writes:
> Andrew J. Perrin <aperrin@email.unc.edu> wrote:
> [snip]
> >Is there another avenue I
> >should be taking?
>
>
> Count how many non-space chunks there are:
>
> my $length = () = $string =~ /(\S+)/g;
>
Ah, perfect - thanks!
ap
--
----------------------------------------------------------------------
Andrew J Perrin - andrew_perrin@unc.edu - http://www.unc.edu/~aperrin
Assistant Professor of Sociology, U of North Carolina, Chapel Hill
269 Hamilton Hall, CB#3210, Chapel Hill, NC 27599-3210 USA
------------------------------
Date: Fri, 26 Oct 2001 15:36:20 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Memory management
Message-Id: <UpfC7.129289$NT3.13572145@news1.rdc1.ct.home.com>
Logan Shaw <logan@cs.utexas.edu> wrote:
> In article <m3pu7bqs7x.fsf@mumonkan.sunstarsys.com>,
> Joe Schaefer <joe+usenet@sunstarsys.com> wrote:
>>logan@cs.utexas.edu (Logan Shaw) writes:
>>> {
>>> # create a variable with a huge value
>>> my $x = "random junk" x 1_000_000;
>>> }
>>Care to wager on that? The memory allocated to $x is not freed when
>>the block exits, and it is never "reclaimed" by perl for any other
>>purpose.
> That's surprising.
No, that's a performance hack. (Well, OK, it might be surprising, but
it's still a performance hack :) The assumption is that if you entered
a block once, you'll probably do it again, and the second time perl
won't have to allocate the memory because it's already around from
the last run through the loop.
Yes, it can cause leaks. It only happens with lexicals, so if you
have a large variable and you're done with it you can undef it and
perl will reclaim the memory.
Dan
------------------------------
Date: Fri, 26 Oct 2001 15:37:23 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: NEWBIE: double sort on a string
Message-Id: <x7hesm1kf2.fsf@home.sysarch.com>
>>>>> "AC" == Andrew Cady <please@no.spam> writes:
AC> "John W. Krahn" <krahnj@acm.org> writes:
>> Andrew Cady wrote:
>>
>> > @sorted_array = map { $_->[2] }
>> > sort { $a->[0] cmp $b->[0] || $a->[1] cmp $b->[1] }
>> > map { [ (split '|', lc)[0,1], $_ ] } @array_to_sort;
>> ^^^^^^^^^
>> > Tada. It's faster, yet still easier to write, easier to
>> > understand, and idiomatic.
>> ^^^^^^^^^
>> split /\|/, ... would have been idiomatic.
AC> Using the regex syntax isn't an idiom, it's just typical (although I
AC> frequently see strings used for splits on a single character).
AC> Unfortunately, I somehow forgot that the escape is still necessary
AC> when you use a string, so my original code would not have worked.
AC> Oops. And '\|' doesn't near the aesthetic appeal of '|'. Perhaps
AC> this (in addition to the special handling of ' ') illustrates the
AC> danger in using a string to supply a regex...
wrong. the first arg to split IS ALWAYS a regex. even if it is in quotes
and just a single character! so '|' will not split correctly. you are
not escaping a char in a string but you ARE ESCAPING a metachar in a
regex.
so use // to always remind yourself that it is a regex. only the special
case of ' ' (rtfm) must have quotes instead of //.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs -------------------------- http://jobs.perl.org
------------------------------
Date: Fri, 26 Oct 2001 16:18:59 GMT
From: Andrew Cady <please@no.spam>
Subject: Re: NEWBIE: double sort on a string
Message-Id: <87bsiuz89v.fsf@homer.cghm>
Uri Guttman <uri@sysarch.com> writes:
> Andrew Cady writes:
>
> > Using the regex syntax isn't an idiom, it's just typical (although
> > I frequently see strings used for splits on a single character).
> > Unfortunately, I somehow forgot that the escape is still necessary
> > when you use a string, so my original code would not have worked.
> > Oops. And '\|' doesn't near the aesthetic appeal of '|'. Perhaps
> > this (in addition to the special handling of ' ') illustrates the
> > danger in using a string to supply a regex...
>
> wrong.
How?
> the first arg to split IS ALWAYS a regex. even if it is in quotes
> and just a single character!
True. Hence, "using a string to supply a regex".
> so '|' will not split correctly.
As I said.
> you are not escaping a char in a string but you ARE ESCAPING a
> metachar in a regex.
Yep.
> so use // to always remind yourself that it is a regex. only the
> special case of ' ' (rtfm) must have quotes instead of //.
How is what you said in any way contradictory to what I said? In
fact, how is it any more than a rewording of what I said?
------------------------------
Date: Fri, 26 Oct 2001 16:23:51 GMT
From: Andrew Cady <please@no.spam>
Subject: Re: NEWBIE: double sort on a string
Message-Id: <877ktiz81r.fsf@homer.cghm>
Dave Tweed <dtweed@acm.org> writes:
> I wrote:
>
> > @sorted = map {$_->[0]} sort {$a->[1] cmp $b->[1]}
> > map {[$_, lc join '',(split /|/)[$sortfield,1]]} @data;
>
> Oops. I guess there ought to be a delimiter in there that sorts
> before any character in your strings. Try ' ' instead, assuming your
> strings don't contain control characters, or use "\0" to be sure.
Also, split's | needs to be escaped ;)
------------------------------
Date: Fri, 26 Oct 2001 16:35:39 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: NEWBIE: double sort on a string
Message-Id: <x78zdy1hpz.fsf@home.sysarch.com>
>>>>> "AC" == Andrew Cady <please@no.spam> writes:
AC> Uri Guttman <uri@sysarch.com> writes:
>> Andrew Cady writes:
>>
>> > Using the regex syntax isn't an idiom, it's just typical (although
>> > I frequently see strings used for splits on a single character).
my point is that it is wrong and shouldn't be typical.
>> > Unfortunately, I somehow forgot that the escape is still necessary
>> > when you use a string, so my original code would not have worked.
that is why you should use //. to remind yourself it is a regex.
>> > Oops. And '\|' doesn't near the aesthetic appeal of '|'. Perhaps
what does aesthetics have to do with correctness?
AC> True. Hence, "using a string to supply a regex".
doesn't matter. did you know that the right side of =~ can be ANY
expression and not m// and it will be converted to a regex? yet, do you
see anyone doing that?
>> you are not escaping a char in a string but you ARE ESCAPING a
>> metachar in a regex.
AC> Yep.
you didn't state that in the string form it needs escaping for that reason.
>> so use // to always remind yourself that it is a regex. only the
>> special case of ' ' (rtfm) must have quotes instead of //.
AC> How is what you said in any way contradictory to what I said? In
AC> fact, how is it any more than a rewording of what I said?
see above.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs -------------------------- http://jobs.perl.org
------------------------------
Date: Fri, 26 Oct 2001 12:52:47 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: PATH and output questions
Message-Id: <ch4jtt8ags0l6ldj24j25ug7hq6qfue462@4ax.com>
From the Perl Cookbook (9.6) I whipped up this:
#! /usr/bin/perl -w
use strict ;
use diagnostics ;
my $path = 'N:\domino\reports\679160001' ;
opendir (DIR, $path) or die "No! $!" ;
my @files = grep {/\.*$/} readdir (DIR) ;
closedir DIR ;
print @files ; #just here to see if it worked
and I have 2 questions:
1 -- I'd like to use a UNC but:
$path = '\\server\path\to\dir' ;
doesn't work.
2 -- The print @files prints out (as expected) in a line, while I
probably won't ever look at the actual output of this I'd like to know
how to format the output.
Thanks.
--
TMTOWTDI: My way tends to be wrong...
lmoran@wtsg.com
------------------------------
Date: 26 Oct 2001 15:07:45 GMT
From: "Alex Davidson" <alexd@NOSPAMsynergycsi.com>
Subject: Re: Ping Script Help Needed
Message-Id: <9rbu81$skv@dispatch.concentric.net>
With this:
<SCRIPT LANGUAGE="PerlScript" RUNAT="Server">
use Net::Ping;
$ip = "216.115.108.245";
my $p = Net::Ping->new("icmp");
if ($p->ping($ip,2)) {
$Response->Redirect("pingresult.asp?Error=No");
} else {
$Response->Redirect("pingresult.asp?Error=Yes");
}
</SCRIPT>
I get:
$ip = "216.115.108.245"; my $p = Net::Ping->new("icmp"); error '80004005'
icmp socket error - Unknown error
/smi/test.asp, line 4
If I take out the "icmp" on the "my $p..." line I get taken to page
"pingresult.asp?Error=No" regardless:
"speakeasy" <nospam_artd@speakeasy.net> wrote in message
news:tth73b3944o78b@corp.supernews.com...
> I'm no expert, and I'm sure this snippet will get criticized by all the
Perl
> Gods, but here:
>
> my $p = Net::Ping->new("icmp");
> if ($p->ping($ip)) {
> # code here
> };
>
>
> "Alex Davidson" <alexd@NOSPAMsynergycsi.com> wrote in message
> news:9r9bh6$id3@dispatch.concentric.net...
> > I have the following script in a page in order for me to determine an IP
> > being available so I can use an alternate site if necessary:
> >
> > <SCRIPT LANGUAGE="PerlScript" RUNAT="Server">
> > use Net::Ping;
> > $host = "216.98.200.32";
> > $p = Net::Ping->new();
> > $retval = $p->ping($host,1);
> > $p->close();
> > if ($retval = 0) {
> > $Response->Redirect("pingresult.asp?Error=Yes");
> > } else {
> > $Response->Redirect("pingresult.asp?Error=No");
> > }
> > </SCRIPT>
> >
> > 216.98.200.32 comes back as "Destination specified is invalid" when I
PING
> > it yet this script returns no error.
> >
> > I have tried:
> > if ($retval = "0") {
> > if ($retval == "0") {
> > if ($retval == 0) {
> >
> > with similar results (bad and good IPs both show either good or bad) - I
> > can't find the syntax to discriminate correctly between reachable and
> > unreachable IPs.
> >
> > As you can tell I am a complete neophyte and not sure of the syntax to
> use.
> >
> > Can someone correct it for me?
> >
> > Thanks.
> >
> >
>
>
------------------------------
Date: Fri, 26 Oct 2001 10:07:54 -0700
From: craig <craigandbarbara@pacbell.net>
Subject: Print Question (file & cgi)
Message-Id: <3BD9986A.A292E743@pacbell.net>
Hello All:
I have a question about printing to a file and cgi in the same program.
Below is the code.
print $cgi->header();
print $cgi->start_html (-title => 'Generate Key Words');
print 'Hello';
# this part prints to the browser ok
my $old = '../LASER-U.TAB';
my $new = '../laser-u.ready';
open(OLD1, "< $old") or die "can't open $old: $!";
open(NEW1, "> $new") or die "can't open $new: $!";
select(NEW1);
while (<OLD1>)
{
$_ =~ s!lb.gif!../lb.gif!g;
$_ =~ s!a.htm!../a.htm!g;
print NEW1 $_ or die "can't write $new: $!";
}
close (OLD1) or die "can't close $old: $!";
close(NEW1) or die "can't close $new: $!";
# this part prints to the file NEW1 ok
print "\n<br>$old file has been processed";
#this gives this error
#generateKeyTest.pl: print() on closed filehandle main::NEW1 at
generateKeyTest.pl line 61.
The part I don't understand is why does the last print statement think
that I am trying to print to NEW1
when I do not directly say
print NEW1
Many thanks
Craig
------------------------------
Date: Fri, 26 Oct 2001 07:22:37 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Printing Images in a Web browser
Message-Id: <3BD971AD.9E2CE45E@vpservices.com>
Benjamin Goldberg wrote:
>
> print "Content-type: image/gif\n\n";
> binmode STDOUT;
> print $ref->{pict};
From perldoc -f binmode:
binmode() should be called after open() but before any I/O is
done on the filehandle.
In other words, that should be:
binmode STDOUT;
print "Content-type: image/gif\n\n";
print $ref->{pict};
--
Jeff
------------------------------
Date: Fri, 26 Oct 2001 14:41:01 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Printing Images in a Web browser
Message-Id: <a7titt02skgiuql1l7u7o0ki9uqvp1qttp@4ax.com>
Jeff Zucker wrote:
>From perldoc -f binmode:
>
> binmode() should be called after open() but before any I/O is
> done on the filehandle.
>
>In other words, that should be:
>
> binmode STDOUT;
> print "Content-type: image/gif\n\n";
> print $ref->{pict};
Yet the other way around appears to work -- but only (reliably), with $|
set.
Note that the header is text, but the remainder is a binary chunk of
bytes. Oh well.
--
Bart.
------------------------------
Date: Fri, 26 Oct 2001 14:05:28 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: problem with break...
Message-Id: <3bd96da7.5079$117@news.op.net>
In article <vd_B7.6379$cE2.259030@weber.videotron.net>,
Jerome <tanathos21@yahoo.com> wrote:
>Hi, here is a piece of code I am working on, and I'm not sure that the
>function break works the same way in perl than in C.
In Perl, 'break' calls the 'break' function if there is one, and
otherwise does nothing.
Perl uses 'last' in place of 'break', and 'next' in place of 'continue'.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Fri, 26 Oct 2001 10:50:11 -0400
From: Michael Witkowski <witkowsk@pop900.gsfc.nasa.gov>
Subject: Regular expression help
Message-Id: <3BD97823.B4A35947@pop900.gsfc.nasa.gov>
I have three lines of code that I use to remove string
literals from fortran code:
$stringb =~ s/['][^']*[']//;
$stringb =~ s/[`][^`]*[`]//;
$stringb =~ s/[\"][^\"]*[\"]//;
It would be nice to write this as:
$stringb =~ s/(['`\"])([^'`\"]*)(['`\"])//;
But I need to modify the second and third groups so
that they match (for third group) and don't match
(for second group). I need to ensure this so that I do
not get mucked up with embedded ['`\"]'s like:
string => ' this " is an embedded double quote '
In this case everything between and including the [']'s
needs to be replaced. The permutations on this should
be obvious.
Is there a nice way to do this or am I stuck with three
lines of code. I have other places where this would be
very useful to me so it's not just the 3 lines.
Michael Witkowski
------------------------------
Date: Fri, 26 Oct 2001 15:31:30 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Regular expression help
Message-Id: <slrn9tit9n.71j.tadmc@tadmc26.august.net>
Michael Witkowski <witkowsk@pop900.gsfc.nasa.gov> wrote:
>I have three lines of code that I use to remove string
>literals from fortran code:
It's been 25 years since I used FORTRAN. Can the delim chars
be escaped and included in the string?
eg: 'cat\'s pajamas'
Neither your solution nor mine handles that...
> $stringb =~ s/['][^']*[']//;
> $stringb =~ s/[`][^`]*[`]//;
> $stringb =~ s/[\"][^\"]*[\"]//;
^ ^ ^
^ ^ ^ useless uses of backslash
Can you have more than one string on a line in FORTRAN?
Probably want a 'g' option on those...
>It would be nice to write this as:
>
> $stringb =~ s/(['`\"])([^'`\"]*)(['`\"])//;
>I need to ensure this so that I do
>not get mucked up with embedded ['`\"]
>Is there a nice way to do this
$stringb =~ s/(["'`]).*?\1//gs;
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 26 Oct 2001 13:52:29 -0400
From: Michael Witkowski <witkowsk@pop900.gsfc.nasa.gov>
Subject: Re: Regular expression help
Message-Id: <3BD9A2DD.5CFD2795@pop900.gsfc.nasa.gov>
Tad McClellan wrote:
> Michael Witkowski <witkowsk@pop900.gsfc.nasa.gov> wrote:
> >I have three lines of code that I use to remove string
> >literals from fortran code:
>
> It's been 25 years since I used FORTRAN. Can the delim chars
> be escaped and included in the string?
>
> eg: 'cat\'s pajamas'
Just FYI
The fortran 90/95 spec allows an embedded delim char
as part of the string if it is "doubled" so to get the string
"cat's pajamas" the string assignment would be:
stringb = 'cat''s pajamas'
Which makes the matching and replacement trivial. Thank
goodness I don't need to worry about escapes.
>
>
> Neither your solution nor mine handles that...
>
> > $stringb =~ s/['][^']*[']//;
> > $stringb =~ s/[`][^`]*[`]//;
> > $stringb =~ s/[\"][^\"]*[\"]//;
> ^ ^ ^
> ^ ^ ^ useless uses of backslash
>
Thanks.... I thought I had a problem with the " awhile
back but I must've developed a bad habit!
> Probably want a 'g' option on those...
yup... my oversight.
>
>
> >It would be nice to write this as:
> >
> > $stringb =~ s/(['`\"])([^'`\"]*)(['`\"])//;
>
> >I need to ensure this so that I do
> >not get mucked up with embedded ['`\"]
>
> >Is there a nice way to do this
>
> $stringb =~ s/(["'`]).*?\1//gs;
>
Hmmm... nongreedy match. I got caught up tring to force
a negative match. Thanks!
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
Thanks again for your response.
--
Michael Witkowski
------------------------------
Date: Fri, 26 Oct 2001 18:38:06 +0200
From: "Alexander Farber (EED)" <eedalf@eed.ericsson.se>
Subject: Re: Security- Upload scripts
Message-Id: <3BD9916E.6B3CCE94@eed.ericsson.se>
spamfree wrote:
> I'm wanting to modify a simple upload script.
> Any recommended resources/tuts on the many security issues using upload
> scripts in perl to Unix?
Use File::Temp and the recently added upload-function in CGI.pm
------------------------------
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.
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 2017
***************************************