[18544] in Perl-Users-Digest
Perl-Users Digest, Issue: 712 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 19 09:11:20 2001
Date: Thu, 19 Apr 2001 06:11:05 -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: <987685864-v10-i712@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 19 Apr 2001 Volume: 10 Number: 712
Today's topics:
Re: CGI variables BUG ? <tony_curtis32@yahoo.com>
Re: CGI.pm V. Here Docs . . . <dan@nospam_dtbakerprojects.com>
Re: Cookie/Hash help needed nobull@mail.com
Curious Scalar-Interpolation <beratung@apo-im-plauen-park.de>
Re: Curious Scalar-Interpolation nobull@mail.com
Distance between zip codes? (Gil G.)
Re: Distance between zip codes? (Gil G.)
Re: does perl implement polymorphism (late binding)? <ubl@schaffhausen.de>
Re: does perl implement polymorphism (late binding)? <bart.lateur@skynet.be>
Re: Duplicate Emails <tlav1@mediaone.net>
Re: Exec format error <eaglelw@gmx.de>
Re: expected result with locking issue? (David Efflandt)
FAQ .: How to contribute to this document <faq@denver.pm.org>
Re: FAQ 9.3: How do I remove HTML from a string? <bart.lateur@skynet.be>
Re: Filehandle problem (glob) less@rude.not
Re: Filehandle problem (glob) <ren@tivoli.com>
Re: Filehandle problem (glob) (Tad McClellan)
Re: Filenames from Windows OS nobull@mail.com
Re: Filenames from Windows OS <mjcarman@home.com>
Re: Filenames from Windows OS <bart.lateur@skynet.be>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Apr 2001 03:52:00 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: CGI variables BUG ?
Message-Id: <877l0l9qhb.fsf@limey.hpcc.uh.edu>
>> On 16 Apr 2001 04:59:06 GMT,
>> "Philip M. Gollucci" <philip@p6m7g82k.student.umd.edu> said:
> using FreeBSD v 4.1 perl 5.6.0 CGI.pm 2.753
> I can say the following url:
> http://www.test.p6m7g8.com/cgi-bin/test.cgi?Show=1 and
> get Show = 1
> but, using the perl 5.6.1, not only is there no value
> for Show, but the query_string is none existant as well.
> Whats the deal ?
> test.cgi below [squashed]
> #!/usr/local/bin/perl -w
> use strict;
> my $query = CGI->new();
> my $show = $query->param("Show");
> print $query->header();
> print "Show = $show <P>\n";
> exit;
$ perl thiscode
Can't locate object method "new" via package "CGI" at thiscode line 3.
$
Testing the code on the command-line shows you the problem
immediately. CGI.pm is not "use"d. When that's fixed:
$ perl thiscode Show=99
Content-Type: text/html; charset=ISO-8859-1
Show = 99 <P>
$
hth
t
--
Just reach into these holes. I use a carrot.
------------------------------
Date: Thu, 19 Apr 2001 12:21:55 GMT
From: Dan Baker <dan@nospam_dtbakerprojects.com>
Subject: Re: CGI.pm V. Here Docs . . .
Message-Id: <3ADED71C.360EC0F7@nospam_dtbakerprojects.com>
> >CGI.pm isn't bad. It's just slow for many reasons I won't get into.
-------------------
compared to the time it takes for the server-client response, cgi.pm
speed seems trivial. I would recommend only pulling in the pieces you
need. Its very easy.... with a statement like this:
use CGI qw( cookie param ); # just add whatever subs you are actually
using
D
------------------------------
Date: 19 Apr 2001 08:33:37 +0100
From: nobull@mail.com
Subject: Re: Cookie/Hash help needed
Message-Id: <u91yqpgu9n.fsf@wcl-l.bham.ac.uk>
Bryan Coon <bcoon@sequenom.com> writes:
> I am having some trouble getting the proper values from CGI::Cookie by
> hash...
>
> I am setting the cookie like this:
> $c = new CGI::Cookie(-name=>"cookiename", -value=>{-logname=>"login",
> -pass=>"password"});
> %cookie = fetch CGI::Cookie;
> $cookie{cookiename}{value}[0];
>
> But this also seems a bit strange, as the script tells me that my -value
> is an array, rather than a hash. I can only access the elements by
> number, and they are reversed (i.e. ...{value}[0] is password,
> ...{value}[1] is pass, etc.
Are you sure? I would expect $cookie{cookiename}{value} to be
['-pass', 'password', '-logname','login'] or
['-logname','login','-pass', 'password']. (The result of linerizing a
hash should not be treated as derministic.)
> Any ideas or suggestions?
By using {value} on a CGI::Cookie object you are bypassing the public
API and looking at the object's internals. You should, strictly
speaking, use the value() method. Not that this helps much as you'll
still get the same list ('-pass', 'password', '-logname','login').
To convert a list to a hash use an assignment:
my %cookie_value = $cookie{cookiename}->value;
my $password = $cookie_value{-pass};
my $logname = $cookie_value{-logname};
Or if you want to avoid a named temporary hash use the { } operator
and a slice:
my ($logname,$password) =
@{{$cookie{cookiename}->value}}{qw(-logname -pass)};
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 19 Apr 2001 12:16:54 +0200
From: "Andreas Muck" <beratung@apo-im-plauen-park.de>
Subject: Curious Scalar-Interpolation
Message-Id: <3adebcff$0$1819$4dbef881@businessnews.de.uu.net>
Hallo, out there,
I'm about writing a shopping-card-application and I got following problem
with a subroutine:
After adding products to his shopping-card or after making corrections to
his card a costumer should see his actual card. The shopping is maintained
via a DB-File. I thought to use the following code:
sub show_card{
my $q = shift;
my $id = shift;
my ( %card, $pzn_card, $menge_card );
dbmopen %card, $cardfile, 0666 or die ( "Opening " . $cardfile . ":" .
$! );
print
$q->header(),
$q->start_html( "Aktueller Warenkorb"),
$q->h1( "Ihr aktueller Warenkorb" );
print( '<TABLE>' );
print $q->Tr( $q->th( [ 'PZN', 'Menge' ] ) );
while ( ( $pzn_card, $menge_card ) = each %card ) {
print
$q->Tr(
[ $q->start_form( -method => "POST", -action => "shop.pl"),
$q->td( [ $pzn_card,
$q->textfield( -name => "menge",
-value => $menge_card,
-size => "2",
-maxlength => "2"
),
$q->hidden( -name => "pzn",
-value => $pzn_card
),
$q->submit( -name => "action",
-value => "Korrigieren"
)
]
),
$q->end_form
]
);
}
print( '</TABLE>');
print $q->end_html;
dbmclose %card;
}
But after two runs, the first adding value 1 of Prod.-No. 56789012 and the
second adding value 2 of Prod.-No. 67890123 to the card, I've got following
HTML-Code:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML><HEAD><TITLE>Aktueller Warenkorb</TITLE></HEAD>
<BODY>
<H1>Ihr aktueller Warenkorb</H1>
<TABLE>
<TR>
<TH>PZN</TH>
<TH>Menge</TH>
</TR>
<TR>
<FORM METHOD="POST" ACTION="shop.pl"
ENCTYPE="application/x-www-form-urlencoded">
</TR>
<TR>
<TD>67890123</TD>
<TD><INPUT TYPE="text" NAME="menge" VALUE="2" SIZE=2 MAXLENGTH=2></TD>
<TD><INPUT TYPE="hidden" NAME="pzn" VALUE="67890123"></TD>
<TD><INPUT TYPE="submit" NAME="action" VALUE="Korrigieren"></TD>
</TR>
<TR>
</FORM>
</TR>
<TR>
<FORM METHOD="POST" ACTION="shop.pl"
ENCTYPE="application/x-www-form-urlencoded">
</TR>
<TR>
<TD>56789012</TD>
<TD><INPUT TYPE="text" NAME="menge" VALUE="2" SIZE=2 MAXLENGTH=2></TD>
<TD><INPUT TYPE="hidden" NAME="pzn" VALUE="67890123"></TD>
<TD><INPUT TYPE="submit" NAME="action" VALUE="Korrigieren"></TD>
</TR>
<TR>
</FORM>
</TR>
</TABLE>
</BODY></HTML>
As you can see, the displayed Prod.-No. (first column, PZN) is correct, but
the hidden fields contain the same value (67890123) instead the correct
Prod.-No. and the value "menge" is always "2". But I entered different
values ("1" and "2") for the different products. In the perl-code the
scalars that are called are identical ($pzn_card or $pzn_menge) but they are
not changing their values while running through the hash %card. I do not
understand this! If I run the subroutine without the form to give the
possibility to change the card-values (only displaying PZN and value) the
code works. Has anybody some hints to fix my code?
Thanks for your effort!
Ciao
Andreas
------------------------------
Date: 19 Apr 2001 12:36:43 +0100
From: nobull@mail.com
Subject: Re: Curious Scalar-Interpolation
Message-Id: <u9pue9f7ec.fsf@wcl-l.bham.ac.uk>
"Andreas Muck" <beratung@apo-im-plauen-park.de> writes:
> Subject: Curious Scalar-Interpolation
Nothing to do with scalar interpolation.
> $q->hidden( -name => "pzn",
> -value => $pzn_card
> ),
>
> But after two runs...
> ...the hidden fields contain the same value...
The -value parameter on the CGI->hidden() (et al) is actually an alias
for -default paramter. This IMNSHO was a poor design decision.
Change '-value' to '-default' and the script will behave _exactly_ the
same but now the behaviour is what you'd expect of a parameter called
'default'!
To change the value of a hidden field that already has a value in the
CGI query object..
$q->param( "pzn", $pzn_card );
...
$q->hidden( -name => "pzn")
or
$q->hidden( -name => "pzn",
-value => $pzn_card,
-force => 1
),
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Mon, 16 Apr 2001 22:59:59 GMT
From: gil@nospam-keskydee.com (Gil G.)
Subject: Distance between zip codes?
Message-Id: <3adb78f2.1508969@news-server>
Hello,
Is there a module to do this, or some formula/database that will allow
this calculation?
Thanks, sincerely,
Gil.
Need a Perl programmer?
http://keskydee.com/freelance.php
------------------------------
Date: Tue, 17 Apr 2001 01:10:55 GMT
From: gil@nospam-keskydee.com (Gil G.)
Subject: Re: Distance between zip codes?
Message-Id: <3adb97d2.9414069@news-server>
On Mon, 16 Apr 2001 23:47:03 -0000, cberry@cinenet.net (Craig Berry)
wrote:
>Gil G. (gil@nospam-keskydee.com) wrote:
>: Is there a module to do this, or some formula/database that will allow
>: this calculation?
>
>The code isn't the hard part for this one; the trick is to create, find,
>or buy a database that provides latitude and longitude information for all
>the zip codes. Once you have that, finding the distance is a simple
>exercise in spherical trig (or a complicated exercise, if your required
>precision necessitates that you account for Earth's deviation from a
>perfect sphere).
>
>--
> | Craig Berry - http://www.cinenet.net/~cberry/
> --*-- "When the going gets weird, the weird turn pro."
> | - Hunter S. Thompson
Hello,
Interesting, thank you all :-)
Anybody has an already made solution ?
That would be great!!!
Gil.
------------------------------
Date: Thu, 19 Apr 2001 09:01:07 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: does perl implement polymorphism (late binding)?
Message-Id: <3ADE9B43.79B9593A@schaffhausen.de>
Lachlan Rosenberg schrieb:
>
> Hi
>
> I come from a Java C++ background and am just learning perl for cgi.
>
> perl 5 says that it is OO and i can find information about its encapsulation
> and inheritance mechanisms via packages (just like Ada95 in fact) but i cant
> find anywhere how it implements polymorphism (i dont think it does).
>
> By polymorphism i mean the invoking of a method of an object via a reference
> to the object as an instance of its base class resulting in the execution of
> the method defined by the objects actual superclass definition (in Java, the
> base class method is abstract, in c++ its virtual or pure virtual and the
> superclass redefines the method).
>
> Can anyone tell me if perl5 has polymorphism like the features im used to
> implementing in the compiled languages like Java, C++, Ada95 or is it just
> OO without polymorphism?
go ahead and try it.
->malte
PS: Yes it does, in fact Perl supports both inheritance and interface polymorphism.
------------------------------
Date: Thu, 19 Apr 2001 09:09:27 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: does perl implement polymorphism (late binding)?
Message-Id: <jdatdtor9qf81jp91e245ma61sgh4uoemf@4ax.com>
Lachlan Rosenberg wrote:
>By polymorphism i mean the invoking of a method of an object via a reference
>to the object as an instance of its base class resulting in the execution of
>the method defined by the objects actual superclass definition
Keyword to look for: "SUPER".
But I don't think that is the actual meaning of the word "polymorphism".
I think that, if one object is a Square, and the other a Circle,
polymorphism allows you to do:
$object->draw;
where one object will execute the Square::draw method, and the other
Circle::Draw. You DON'T need a superclass in order to be able to do
that. All that you need is that the methods exist in the individual
class packages.
--
Bart.
------------------------------
Date: Tue, 17 Apr 2001 22:33:19 GMT
From: ted <tlav1@mediaone.net>
Subject: Re: Duplicate Emails
Message-Id: <3ADCEF9F.E4722779@mediaone.net>
I ran into a similar problem once before and this is how I solved it: I
made the all the email addresses the keys of a hash, then check for the
existence of the email address. If it already existed in the hash, I just
skipped it. Something like this...
foreach (sort keys %all_emails) {
if ( exists $all_emails{$_} ) { next; }
$all_emails{$_} = $all_emails{$_} + 1;
# do some stuff here #
}
Hope this helps,
ted
Darnell Kelly wrote:
> To All,
>
> i have written this perl script that sends email but, as i am more of a
> tcl programmer
> these days than perl, i haven't been able to write the portion of the
> script that accepts
> email addresses, checks to see if any one of them are duplicates, and
> sends mail
> only to the unique address. Basically, i do not want to send multiple
> email messages
> to the same address. in tcl/vignette i have written a library with these
> parameters:
>
> [SET send_email [exec /usr/local/apache/cgi-bin/dz_easy_smtp.pl [SHOW
> email]
> [SHOW cc] [SHOW from] [SHOW subject] [SHOW message]]]
>
> before i get to this library with these parameters what perl will do is
> read from a text
> file, grab all emails, send those, then close. this works fine except i
> have been
> unsuccessful in filtering out duplicates.
>
> my perl script is as follows:
>
> #!/usr/local/bin/perl
>
> use Net::SMTP;
>
> print "Content-type: text/html\n";
> my ($to,$cc,$from,$subject,$message) = @ARGV;
>
> #$to = [SHOW email], $cc = [SHOW cc], $from = [SHOW from], $subject =
> [SHOW subject], $message = [SHOW message]
>
> my $smtp = Net::SMTP->new('my_ip_address') or die "Can't open
> mail
> connection\n";
>
> $smtp->mail($from); # who is mailing
>
> my $text;
> my @response;
>
> $smtp->to($to);
>
> #below: attempt at filtering dupe emails in $to field coming in from
> tcl/vignette page
>
> $_ = $to;
>
> @duplicates = /.*\@.*\..*/;
>
> if ($to != ""){
> print "The duplicates are: @duplicates";
>
> }
> #end of attempt
>
> # get rid of nasty carraige returns
> chomp($subject);
> chomp($to);
> @response = ("To: $to\n", "CC: $cc\n",
> "Subject:" . $subject . "\n",
> "From: $from\n\n",
> $message,
> );
> $smtp->data(@response);
> $smtp->quit;
>
> i've just ben trying to grab the duplicates and then grab the unique one
> to send will
> come later.
>
> i hope someone in thid\s group receives this email and give me much
> needed advice.
> i would truly appreciate all immediate help to the solution of this
> problem as it is part
> of an ongoing project.
>
> thanks for your time,
> darnell
------------------------------
Date: Tue, 17 Apr 2001 19:27:33 +0200
From: Lars <eaglelw@gmx.de>
Subject: Re: Exec format error
Message-Id: <9bhu94$is$5@surz18.uni-marburg.de>
Lars schrieb:
> hi,
>
> beim ausführen eines perl-scripts bekomme ich diese meldung in die
> http-error.log datei.
>
> [Fri Apr 13 20:24:51 2001] [error] (8)Exec format error: exec of ...
>
> was heißt das genau? - ansonsten scheint alles im script korrekt zu sein.
Lars schrieb:
> Roland Steinbach schrieb:
>
>> Lars <eaglelw@gmx.de> wrote:
>>
>>> [Fri Apr 13 20:24:51 2001] [error] (8)Exec format error: exec of ...
>>> was heißt das genau? - ansonsten scheint alles im script korrekt zu sein.
>>
>> Ist wohl ne *nix-Kiste und das Script wurde unter Windows bearbeitet. Ich
>> wuerde mal auf falsche Zeilenumbrueche tippen.
>>
>> Loesung: Script im ASCII-Modus uebertragen
>>
> hi,
>
> auch schon gemacht, und mit je einer kopie habe ich dos2unix und duconv
> ausprobiert.
> dos2unix sagte dann irgendwas mit: recode: mein.pl failed: ambiguous output
> in CR-LF..data
>
>
> duconv hat alles ohne fehler gemacht mit -u aber auch da ohne erfolg, d.h.
> selbe fehlermeldung
>
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: print: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
./mein.pl: =: command not found
und das passiert, wenn ich das script direkt aufrufe.
./mein.pl: line 46: syntax error near unexpected token `chop($datum)'
./mein.pl: line 46: `$datum = `$date_pfad +"%A, %B %d, %Y at %T
(%Z)"`; chop($datum);'
fehlermeldug ist zwar etwas unklar, aber nicht das eigentliche problem!
--
cya & thx lars .-. - LINUX >> Phear the Penguin -
O-O - Woah.. I did a -
www.lars-witter.de / v \ - cat /boot/vmlinuz >> /dev/dsp" -
LinuxUser: #205319 /(TUX)\ - and I think I heard god -
^^ ^^
------------------------------
Date: Wed, 18 Apr 2001 04:37:07 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: expected result with locking issue?
Message-Id: <slrn9dq6fi.jc6.see-sig@typhoon.xnet.com>
On Wed, 18 Apr 2001, Dan Baker <dan@nospam_dtbakerprojects.com> wrote:
> I have a script which could *potentially* be fired up by more than one
> user at once. The process takes about a second to run, and opens and
> appends to a debug file during execution... just a simple trace in most
> cases.
>
> What I am wondering is what would be the EXPECTED result if a second
> user fires up an instance on the process while another is executing?
> would it crash the process, or just return an error from the open()? I'm
> having trouble trying to figure out a way to actually test this
> condition opening the same file in append mode from two different
> processes.
>
> The debug file is opened in append mode.
After the open, you would want to flock the filehandle (which should wait
for the first process to finish) then seek the end of the file before
writing, like the example in: perldoc -f flock
--
David Efflandt (Reply-To is valid) http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Thu, 19 Apr 2001 12:16:11 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ .: How to contribute to this document
Message-Id: <fGAD6.1304$T3.197051904@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
How to contribute to this document
You may mail corrections, additions, and suggestions to
perlfaq-suggestions@perl.com . This alias should not be used to *ask*
FAQs. It's for fixing the current FAQ. Send questions to the
comp.lang.perl.misc newsgroup.
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep comming up. If you are some how irritated by
seeing these postings you are free to ignore them or add the sender
to your killfile. If you find errors or other problems with these
postings please send corrections or comments to the posting email
address.
If you are not able to find this or other Perl documentation from
your installation you may access it via the web by following the
appropriate links from one of the addresses listed below.
http://theoryx5.uwinnipeg.ca/mod_perl/cpan-search
http://www.perldoc.com
http://www.cpan.org
http://www.perl.com
Answers to questions about LOTS of other stuff, mostly not related to
Perl, can be found at
news:news.answers
and in the many thousands of other useful Usenet news groups.
Please note that the FAQ text posted by this server has been modified
from that distributed in the stable Perl release. It has been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ is available on request.
The perlfaq manual pages contain the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
When included as an integrated part of the Standard
Distribution of Perl or of its documentation (printed or
otherwise), this work is covered under Perl's Artistic
License. For separate distributions of all or part of
this FAQ outside of that, see the perlfaq manpage.
Irrespective of its distribution, all code examples here
are public domain. You are permitted and encouraged to
use this code and any derivatives thereof in your own
programs for fun or for profit as you see fit. A simple
comment in the code giving credit to the FAQ would be
courteous but is not required.
This work is provided in the hope that it will be useful but does
not represent a commitment of any kind on the part of the contributers,
authors or their agents.
--
This space intentionally left blank
------------------------------
Date: Tue, 17 Apr 2001 08:06:06 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: FAQ 9.3: How do I remove HTML from a string?
Message-Id: <s9undtgstarso7a3n7hs8grnqd066fpgua@4ax.com>
Any particular reason why these same FAQs are being posted after just
four and a half days?
I thought there were many more than this.
--
Bart.
------------------------------
Date: 19 Apr 2001 08:33:55 GMT
From: less@rude.not
Subject: Re: Filehandle problem (glob)
Message-Id: <9bm7tj$vja$1@news.netmar.com>
In article <x71yqqkykd.fsf@home.sysarch.com>, Uri Guttman <uri@sysarch.com>
writes:
> l> my $file = new IO::File( ">/tmp/bar" ) or die ("Could not open
file.\n");
>
>indirect object calls are not considered as good style nor oare they
>safe. there are some potential gotchas with them. use direct object
>calls.
Interesting, do you have further literature on these 'gotchas'?
> also put $! in the die message:
It has been a while since I posted on usenet, and I am 'out of touch'
with just how persnickerty one has to be. During actual development,
the code will probably look more like this (waiving the point above):
my $iofile;
unless( $opfile = new IO::File( ">/tmp/bar$$" ) )
{
print "Could not create iofile ($iofile) for writing: $!\n";
# Do some more debug reporting....
}
For brevity I will not go into further details.
> l> my $msg_line = "Some foo in bar diddly.\n";
> l> $self->process_message_line ($msg_line, $file);
> l> $file->close;
>
>either you are not indenting the code which is bad or your news setup is
>losing the indent which is bad. either way it looks wrong here. you
>appear to be using a web based newsfeed and that is almost always bad.
I do indent, in fact, I do so fastidiously.
I do not like this newsfeed. I await in happy anticipation for the return
of deja. As you can see by my miserable tripple post. I was informed all
three times that the post was unsucessful. So I decided to read more
newsgroups and come back to it later, only to find....
Hopefully Google will not be too long. For now, though, I am stuck with
web based usenet access, as I have no alternative. If only LaunchPad
still existed!
Thank you for your helpful advice.
TCB
----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web -----
http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
NewsOne.Net prohibits users from posting spam. If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net
------------------------------
Date: 17 Apr 2001 11:02:14 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Filehandle problem (glob)
Message-Id: <m3r8yr4ird.fsf@dhcp9-172.support.tivoli.com>
On 17 Apr 2001, you_smell@fuckyou.co.uk wrote:
> I am having a problem with filehandles as typeglobs.
>
> To simplify my code, it looks like this:
Looks like you simplified it a bit too much. Not only does it not
compile, it doesn't really do anything once the typos are fixed.
> #!/use/bin/perl
>
> packge FOO;
Here's the typo. Please copy-and-paste working (or as close to it as
possible) code when posting.
> sub handle_file
> {
> my $self = shift;
> my $file = IO::File( ">/tmp/bar" ) or die ("Could not open
> file.\n");
I assume this is another type? That should be IO::File->new, right?
In addition, there was no "use IO::File;" above.
> my $msg_line = "Some foo in bar diddly.\n";
>
> $self->process_message_line ($msg_line, $file);
> $file->close;
> }
>
> sub process_message_line
> {
> my ($self, $msg_line, $file) = @_;
> print $file "$msg_line";
> }
>
> Why is /tmp/bar empty? What am I doing wrong?
Well, based on this code, nothing ever calls handle_file. Also,
nothing ever creates a FOO object. I assume you just left those
things out in the post, but making the above fixes and adding:
$foo = {};
bless $foo, FOO;
$foo->handle_file;
leads to it working for me.
If that doesn't get things going for you, post a self-contained piece
of code that has the problem.
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Thu, 19 Apr 2001 07:41:28 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Filehandle problem (glob)
Message-Id: <slrn9dtjn8.2ik.tadmc@tadmc26.august.net>
less@rude.not <less@rude.not> wrote:
>In article <x71yqqkykd.fsf@home.sysarch.com>, Uri Guttman <uri@sysarch.com>
>writes:
>> l> my $file = new IO::File( ">/tmp/bar" ) or die ("Could not open
>file.\n");
>>
>>indirect object calls are not considered as good style nor oare they
>>safe. there are some potential gotchas with them. use direct object
>>calls.
>
>Interesting, do you have further literature on these 'gotchas'?
perldoc perlobj
See the "WARNING" section (but you must surely have seen that already
as perlobj seems an obvious place to look).
>> also put $! in the die message:
>
>It has been a while since I posted on usenet, and I am 'out of touch'
>with just how persnickerty one has to be.
People are watching/learning/copying what goes on here.
They will be back later asking how to get more info on why it is failing.
Doing it right the first time precludes that unnecessary traffic.
>During actual development,
>the code will probably look more like this (waiving the point above):
>my $iofile;
>unless( $opfile = new IO::File( ">/tmp/bar$$" ) )
>{
> print "Could not create iofile ($iofile) for writing: $!\n";
> # Do some more debug reporting....
>}
Thanks :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 17 Apr 2001 17:28:04 +0100
From: nobull@mail.com
Subject: Re: Filenames from Windows OS
Message-Id: <u9zodfij8r.fsf@wcl-l.bham.ac.uk>
"David Pratt" <pratt@biop.ox.ac.uk> writes:
> My CGI script is accepting files from both UNIX and Windows (and potentially
> MacOS). The problem with Windows is the returned file name is of the type
>
> C:\Docs\newstuff\thisfile.txt
>
> A simple regex to extract thisfile.txt is falling over at the " \t " and "
> \n" etc are being interpreted as special characters.
There is no problem. Perl treats the \ as special in literal strings
in scripts. It does not treat it as special in data.
If you are getting into difficulties then you are not telling us the
whole truth here.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 17 Apr 2001 11:08:15 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Filenames from Windows OS
Message-Id: <3ADC6A6F.7D6C98E2@home.com>
David Pratt wrote:
>
> My CGI script is accepting files from both UNIX and Windows (and
> potentially MacOS). The problem with Windows is the returned file
> name is of the type
>
> C:\Docs\newstuff\thisfile.txt
>
> A simple regex to extract thisfile.txt is falling over at the
> " \t " and "\n" etc are being interpreted as special characters.
> I've looked on the web and my perl book but can find an obvious
> way to "turn off" the special meaning of " \".
First: Perl will understand unix-style path seperators regardless of
platform. e.g.
C:/Docs/newstuff/thisfile.txt
That's the way to go if you control the data, but you probably don't
here.
Second: only double-quoted strings are interpolated. In other words,
"\t" and '\t' are not the same thing. Don't double-quote anything you
don't need to.
If you're still having troubles after that, you will need to either
translate all '\' to '/' or escape them with another backslash. e.g.
"\\t" is the same as '\t'. Of course, you only want to do this if the
path is a DOS/Win* one -- Unix uses a backslash to escape special chars
too; such as whitespace. (Ugly, but legal.)
-mjc
------------------------------
Date: Tue, 17 Apr 2001 17:49:12 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Filenames from Windows OS
Message-Id: <8f0pdt8bp2buk55p29no9nk4808oc7pl4l@4ax.com>
David Pratt wrote:
>My CGI script is accepting files from both UNIX and Windows (and potentially
>MacOS). The problem with Windows is the returned file name is of the type
>
>C:\Docs\newstuff\thisfile.txt
>
>A simple regex to extract thisfile.txt is falling over at the " \t " and "
>\n" etc are being interpreted as special characters.
Eh, no. If that is indeed in user supplied data, then there is no
problem. What you describe is part of the interpolation process, and it
never happens by itself on user supplied data. It only happens in data
entered directly inside a script.
If you worry about paths entered directly in a script, then use forward
slashes instead of backslashes. Works fine on Windows.
--
Bart.
------------------------------
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 712
**************************************