[24035] in Perl-Users-Digest
Perl-Users Digest, Issue: 6232 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 8 06:05:32 2004
Date: Mon, 8 Mar 2004 03:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 8 Mar 2004 Volume: 10 Number: 6232
Today's topics:
Re: hex conversion after unpack <beable+unsenet@beable.com.invalid>
Re: How to get system date in perlscript from bi <krahnj@acm.org>
How to get system date in perlscript from bios (Jonay Herrera)
Re: How to get system date in perlscript from bi <beable+unsenet@beable.com.invalid>
how can I use "class" and "id" elements in my tag? <ckacka@163.com>
how do print the complete DOCTYPE <ckacka@163.com>
Re: how do print the complete DOCTYPE <ckacka@163.com>
Re: how to see how many open file descriptors my progra (Rex Gustavus Adolphus)
Re: IMAP via ssl? <josef.moellers@fujitsu-siemens.com>
Re: IMAP via ssl? <josef.moellers@fujitsu-siemens.com>
Re: more efficient way of updating a file? <usenet@morrow.me.uk>
Re: more efficient way of updating a file? <beable+unsenet@beable.com.invalid>
Re: more efficient way of updating a file? <tore@aursand.no>
Re: MS SQL 2000 <kz15@earthling.net>
Re: MS SQL 2000 <Petri_member@newsguy.com>
Re: open (FAILEHANDLER, ">>$filename") what is the ron (Sameh Abdelatef)
Re: printf (Anno Siegel)
Re: String Search containing a '/' character <bumble@what.the.heck>
Re: teaching myself perl - stumped on this one! <mjpliv@hfx.eastlink.ca>
Re: teaching myself perl - stumped on this one! <mjpliv@hfx.eastlink.ca>
Re: teaching myself perl - stumped on this one! <mjpliv@hfx.eastlink.ca>
the 3 options(-base, -xbase, -target)'s meaning in star <ckacka@163.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 08 Mar 2004 10:05:45 GMT
From: Beable van Polasm <beable+unsenet@beable.com.invalid>
Subject: Re: hex conversion after unpack
Message-Id: <bs7jxvu02s.fsf@dingo.beable.com>
markwitczak@yahoo.com (woodywit) writes:
>
> So for example how does one get 11909.9957869676 decimal from
> 40c742ff75f285cc hex. Also -4547.33695644214 decimal from
> c0b1c35642c7032b.
Have you looked at the ANSI/IEEE Standard 754-1985 for floating
point numbers?
http://www.psc.edu/general/software/packages/ieee/ieee.html
--
"Driving ME nuts" = "driving MY nuts"! I get it now! -- John Burrage
http://beable.org
------------------------------
Date: Mon, 08 Mar 2004 10:58:46 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: How to get system date in perlscript from bios and not from OS ?
Message-Id: <404C51CB.9FDF27B9@acm.org>
Jonay Herrera wrote:
>
> Subject: How to get system date in perlscript from bios and not from OS ?
The date in the BIOS and the OS should be the same because the BIOS is
where the OS gets the date when you boot your computer.
> I have a little problem:
>
> I want to get the system date/time , and I use this to get it :
> #get timestamp
> ###############################################################################################
> sub get_date {
> chomp ($sysdate = `date /T`);
> chomp ($systime = `time /t`);
> $madate = substr($sysdate,4,2) . substr($sysdate,7,2) . substr($sysdate,12,2);
> $montime = substr($systime,0,2) . substr($systime,3,2);
> $timestamp = $madate . $montime ;
Perl provides the localtime() and gmtime() functions to get the current
date and time.
my @date = localtime;
my $timestamp = sprintf '%02d%02d%02d%02d%02d',
$date[5] + 1900, $date[4] + 1, @date[3,2,1];
Or use the POSIX::strftime() function.
use POSIX 'strftime';
my $timestamp = strftime '%y%m%d%H%M', localtime;
> }
> It works, but I get the time from windows and when we use the
> script on another pc with a another regional setting than is the
> output wrong. how can I resolve my problem ?
Use UCT (GMT) instead of your computers local time.
John
--
use Perl;
program
fulfillment
------------------------------
Date: 8 Mar 2004 02:19:14 -0800
From: balki@pandora.be (Jonay Herrera)
Subject: How to get system date in perlscript from bios and not from OS ?
Message-Id: <dff5acaf.0403080219.4b408056@posting.google.com>
Hello,
I have a little problem:
I want to get the system date/time , and I use this to get it :
#get timestamp
###############################################################################################
sub get_date {
chomp ($sysdate = `date /T`);
chomp ($systime = `time /t`);
$madate = substr($sysdate,4,2) . substr($sysdate,7,2) .
substr($sysdate,12,2);
$montime = substr($systime,0,2) . substr($systime,3,2);
$timestamp = $madate . $montime ;
}
It works, but I get the time from windows and when we use the
script on another pc with a another regional setting than is the
output wrong. how can I resolve my problem ?
thanks,
balki
------------------------------
Date: Mon, 08 Mar 2004 10:43:10 GMT
From: Beable van Polasm <beable+unsenet@beable.com.invalid>
Subject: Re: How to get system date in perlscript from bios and not from OS ?
Message-Id: <dv3c8jtya9.fsf@dingo.beable.com>
balki@pandora.be (Jonay Herrera) writes:
> Hello,
>
> I have a little problem:
>
> I want to get the system date/time , and I use this to get it :
> #get timestamp
> chomp ($sysdate = `date /T`);
> chomp ($systime = `time /t`);
Have you tried one of the time functions documented in "perldoc
perlfunc"? You might like to use gmtime(), localtime(), or time(),
depending on what you actually want.
See "perldoc perlfunc" for details.
--
"Driving ME nuts" = "driving MY nuts"! I get it now! -- John Burrage
http://beable.org
------------------------------
Date: Mon, 8 Mar 2004 18:35:06 +0800
From: "ckacka" <ckacka@163.com>
Subject: how can I use "class" and "id" elements in my tag?
Message-Id: <c2hi8l$1terps$1@ID-224383.news.uni-berlin.de>
ie.
print $q->p (
...
);
------------------------------
Date: Mon, 8 Mar 2004 17:49:59 +0800
From: "ckacka" <ckacka@163.com>
Subject: how do print the complete DOCTYPE
Message-Id: <c2hfk2$1s7bee$1@ID-224383.news.uni-berlin.de>
I use
-dtd => qq(-//W3C//DTD XHTML 1.0 Strict//EN),
and this can only ouput
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">
how can I do? thanks.
------------------------------
Date: Mon, 8 Mar 2004 18:30:37 +0800
From: "ckacka" <ckacka@163.com>
Subject: Re: how do print the complete DOCTYPE
Message-Id: <c2hi0i$1slqs4$1@ID-224383.news.uni-berlin.de>
got it. I use it like this:
-dtd => qq('-//W3C//DTD XHTML 1.0 Strict//EN'
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd),
any better method?
"ckacka" <ckacka@163.com> дÈëÓʼþ
news:c2hfk2$1s7bee$1@ID-224383.news.uni-berlin.de...
> I use
> -dtd => qq(-//W3C//DTD XHTML 1.0 Strict//EN),
> and this can only ouput
> <!DOCTYPE html
> PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">
>
> how can I do? thanks.
>
>
------------------------------
Date: 8 Mar 2004 02:50:10 -0800
From: uffesterner@spamhole.com (Rex Gustavus Adolphus)
Subject: Re: how to see how many open file descriptors my program has?
Message-Id: <c70a85ff.0403080250.2b78250e@posting.google.com>
pkent <pkent77tea@yahoo.com.tea> wrote :
> (Rex Gustavus Adolphus) wrote:
>
> > I have a problem with a deamon-program I've written that after a
> > couple of days/weeks runs out of file descriptors.
> >
> > I wonder if there is a command
> > to see how many open file descriptors my program has?
> >
> > And is there a command
> > to see how many open file descriptors the system has?
>
> The ulimit command might be of use in raising the limit, although that
> doesn't really solve the problem.
>
> > I am not opening them explicitly,
> > I think they are being opened by
> > glob() and/or File::Copy::move
>
> Interesting - I'd have thought that these wouldn't leak filehandles...
> One thing that I've seen is where someone used an opendir() to open a
> directory and then they did close() on that handle, not closedir(). Soon
> the program ran out of directory handles.
>
> Grep through your code for any occurence of 'open' or creating a new
> Filehandle object of some kind. In long-running processes like your
> daemon you should probably keep the scope of filehandle objects as tight
> as possible, maybe localise normal file/directory handles, and ensure
> that you close handles as soon as you possibly can.
The only explicit 'open'-calls I do, is at the very start of the
program
where I open STDIN, STDOUT and STDERR.
When I did 'ls -lab' I also found an FD pointing at
"/oracle/ias/rdbms/mesg/ocis.msb",
it must be opened when I call DBI:connect() I guess.
and a fifth FD pointing at a socket (I have a very vague understanding
of sockets), I have no idea where this come from, or what it is for.
>
> The /proc filesystem mentioned by zentara is common but not available on
> all systems - just something to watch out for. The handy thing about the
> links in fd is that they point, on my system anyway, to the actual
> filenames, so if I do 'ls -lab' in that directory I can see what files
> are open.
Thanks!
This was great for seeing what's opened at least!
Now I know where to look if/when the problem appears again.
>
> P
------------------------------
Date: Mon, 08 Mar 2004 09:09:29 +0100
From: =?ISO-8859-1?Q?Josef_M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: IMAP via ssl?
Message-Id: <c2h9mq$skj$1@nntp.fujitsu-siemens.com>
Abhinav wrote:
>=20
>=20
> Josef M=F6llers wrote:
>=20
>> Hi,
>>
>> according to IMAPClient's manual page, it should be possible to access=
=20
>> an IMAP server via an SSL connection.
>> I tried:
>> ($server is the right server name and $prot is "imaps", $user and=20
>> $password are also correct)
>>
> Hope you have added the following :
>=20
> use strict;
> use warnings;
Yes, no change.
>> if ($prot eq "imaps") {
>> $port =3D getservbyname($prot, 'tcp');
>=20
>=20
> $port should be initialised ??? (use strict to find out) if=20
> getservbyname() actually returns something..you may want to do
> my $port;
> $port =3D getservbyname($prot, 'tcp') or die ("Could Not get Server By=
=20
> Name");
There's a "print "port=3D$port\n" there which prints
port=3D993
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Mon, 08 Mar 2004 09:30:34 +0100
From: =?ISO-8859-1?Q?Josef_M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: IMAP via ssl?
Message-Id: <404C2F2A.9010102@fujitsu-siemens.com>
Abhinav wrote:
>=20
>=20
> Josef M=F6llers wrote:
>=20
>> Hi,
>>
>> according to IMAPClient's manual page, it should be possible to access=
=20
>> an IMAP server via an SSL connection.
>> I tried:
>> ($server is the right server name and $prot is "imaps", $user and=20
>> $password are also correct)
>>
> Hope you have added the following :
>=20
> use strict;
> use warnings;
>=20
>> if ($prot eq "imaps") {
>> $port =3D getservbyname($prot, 'tcp');
>=20
>=20
> $port should be initialised ??? (use strict to find out) if=20
> getservbyname() actually returns something..you may want to do
> my $port;
> $port =3D getservbyname($prot, 'tcp') or die ("Could Not get Server By=
=20
> Name");
>=20
>> my $s =3D IO::Socket::SSL->new(PeerAddr=3D>$host,
>> PeerPort =3D> $port,
>> Proto =3D> 'tcp');
>> die $@ unless defined $s;
>>
>> $imap =3D Mail::IMAPClient->new(Socket =3D> $s,
>> User =3D> $user,
>> Password =3D> $password,);
>> $imap->State($imap->Connected());
>> $imap->login or die $@;
>>
>> but I get the error message
>> Use of uninitialized value in string eq at=20
>> /usr/lib/perl5/site_perl/5.8.1/Mail/IMAPClient.pm line 1435.
>> and then
>> Error sending '1 Login "XXXXXXXX" {12}
>> YYYYYYYYYYYY
>> ' to IMAP: at Perl/IMAP.pl line 45
>> Error sending '1 Login "XXXXXXXX" {12}
>> YYYYYYYYYYYY
>> ' to IMAP: at Perl/IMAP.pl line 45.
>>
>> What am I doing wrong?
I had thought that the {12} thing was OK, but, apparently it isn't.
I changed the appropriate line in IMAPClient.pm to leave out the=20
{12}\r\n and it fixed my problem.
NB I BCC'ed the author.
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Mon, 8 Mar 2004 08:08:02 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: more efficient way of updating a file?
Message-Id: <c2h9l2$gnn$1@wisteria.csv.warwick.ac.uk>
Quoth s99999999s2003@yahoo.com (mike):
>
> i have made a text file called status.out which contains just "0 0 0 0
> 0".
> In my perl script, i would like to update this status.out file with a
> "1" by position.
> I wrote a subroutine "updatestatus" that goes like this:
>
> sub updatestatus {
> $stat = $_[0];
^^
my
Why aren't you using 'strict'?
> chomp($stat);
Why?
> open (STATOUT, ">status.temp") or die "Cannot open status.temp for
> writing\n";
Use lexical FHs.
open my $STATOUT, '>', 'status.temp' or die...;
> open (STAT , "< status.out") or die "Cannot open status.out for
> reading\n";
> while ($status = <STAT>)
> {
> chomp($status);
> ($status1, $status2, $status3, $status4, $status5) = split(' ',
> $status );
> }
The file has only one line.
my @status = split ' ', <STAT>;
> if ($stat == 1)
<snip>
> }
$status[$stat] = 1;
local ($\, $,) = ("\n", ' ');
print STATOUT @status;
> close(STAT);
> close(STATOUT);
No need for close if you used lexical FHs.
> rename "$HOMEDIR\\status.temp" , "$HOMEDIR\\status.out";
Are these files in $HOMEDIR or in the current directory? In any case, use /
instead of \, even on win32.
Ben
--
perl -e'print map {/.(.)/s} sort unpack "a2"x26, pack "N"x13,
qw/1632265075 1651865445 1685354798 1696626283 1752131169 1769237618
1801808488 1830841936 1886550130 1914728293 1936225377 1969451372
2047502190/' # ben@morrow.me.uk
------------------------------
Date: Mon, 08 Mar 2004 08:28:18 GMT
From: Beable van Polasm <beable+unsenet@beable.com.invalid>
Subject: Re: more efficient way of updating a file?
Message-Id: <1wfzcju4l9.fsf@dingo.beable.com>
Ben Morrow <usenet@morrow.me.uk> writes:
>
> Use lexical FHs.
>
> open my $STATOUT, '>', 'status.temp' or die...;
>
> $status[$stat] = 1;
> local ($\, $,) = ("\n", ' ');
> print STATOUT @status;
^^^^^^^
$STATOUT
--
"Driving ME nuts" = "driving MY nuts"! I get it now! -- John Burrage
http://beable.org
------------------------------
Date: Mon, 08 Mar 2004 11:32:09 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: more efficient way of updating a file?
Message-Id: <pan.2004.03.08.10.28.13.326142@aursand.no>
On Sun, 07 Mar 2004 23:37:31 -0800, mike wrote:
> sub updatestatus {
> $stat = $_[0];chomp($stat);
> open (STATOUT, ">status.temp") or die "Cannot open status.temp for
> writing\n";
> open (STAT , "< status.out") or die "Cannot open status.out for
> reading\n";
> while ($status = <STAT>)
> {
> chomp($status);
> ($status1, $status2, $status3, $status4, $status5) = split(' ',
> $status );
> }
>
> if ($stat == 1)
> {
> print STATOUT "1 $status2 $status3 $status4 $status5" ;
>
> }
> if ($stat == 2)
> {
> print STATOUT "$status1 1 $status3 $status4 $status5" ;
> }
>
> if ($stat == 3)
> {
> print STATOUT "$status1 $status2 1 $status4 $status5" ;
> }
>
> if ($stat == 4)
> {
> print STATOUT "$status1 $status2 $status3 1 $status5" ;
> }
>
> if ($stat == 5)
> {
> print STATOUT "$status1 $status2 $status3 $status4 1" ;
> }
> close(STAT);
> close(STATOUT);
> rename "$HOMEDIR\\status.temp" , "$HOMEDIR\\status.out";
>
>
> } # end sub
Seems like this sub could be rewritten like this (untested);
sub update_status {
my $stat = shift || 0;
if ( $stat >= 1 && $stat <= 5 ) {
open( STATOUT, '>', 'status.tmp' ) or die "$!\n";
open( STAT, '<', 'status.out') or die "$!\n";
while ( <STAT> ) {
chomp;
my @status = split( ' ', $_ );
$status[$stat-1] = 1;
print STATOUT join(' ', @status);
}
close( STAT );
close( STATOUT );
rename( "$HOMEDIR/status.tmp", "$HOMEDIR/status.out" );
}
}
--
Tore Aursand <tore@aursand.no>
"I am become Death, shatterer of worlds." -- J. Robert Oppenheimer,
upon witnessing the explosion of the first atomic bomb.
------------------------------
Date: Mon, 8 Mar 2004 09:48:23 +0100
From: "kz" <kz15@earthling.net>
Subject: Re: MS SQL 2000
Message-Id: <OzW2c.832$nl3.182887@news.uswest.net>
"Ben Morrow" <usenet@morrow.me.uk> wrote in message
news:c2dt41$juh$1@wisteria.csv.warwick.ac.uk...
>
> anonymous@coolgroups.com wrote:
> > Does anyone know how to connect to an MS SQL 2000 db from
> > Perl?
>
> I have had success (under linux) with DBI and DBD::Sybase. From Windows
> I guess you can use DBD::ODBC.
>
> Ben
...and I thought database drivers were vendor specific...I could have never
imagine that DBD::Sybase connects to a M$ SQL database.
DBD::ODBC is a really universal driver IMO. Even MySQL AB has developed an
ODBC driver (horribile dictu)...
You have to set a DSN up in your Control Panel/Data Sources section and then
you can use it just like any other DB driver:
use strict;
use warnings;
use DBI;
use DBD::ODBC;
my $dsn = ....
my $login = ...
my $password = ...
...
my $dbh = DBI->connect("dbi:ODBC:$dsn,$login,$password,{'RaiseError' => 1});
$dbh->do($query);
$dbh->disconnect;
...
HTH,
Zoltan Kandi, M. Sc.
------------------------------
Date: 8 Mar 2004 02:05:17 -0800
From: Petri <Petri_member@newsguy.com>
Subject: Re: MS SQL 2000
Message-Id: <c2hggt0k8j@drn.newsguy.com>
In article <OzW2c.832$nl3.182887@news.uswest.net>, kz says...
> "Ben Morrow" <usenet@morrow.me.uk> wrote in message
> news:c2dt41$juh$1@wisteria.csv.warwick.ac.uk...
>> I have had success (under linux) with DBI and DBD::Sybase.
>> From Windows I guess you can use DBD::ODBC.
> ...and I thought database drivers were vendor specific...I could
> have never imagine that DBD::Sybase connects to a M$ SQL database.
Why not?
MS SQL Server more or less _is_ Sybase SQL Server.
Bill and his boys bought the source code from Sybase a decade ago.
(They had MS Access. How do you think they made the jump to SQL Server?)
Petri
------------------------------
Date: 8 Mar 2004 00:22:08 -0800
From: samehabdelatef@yahoo.com (Sameh Abdelatef)
Subject: Re: open (FAILEHANDLER, ">>$filename") what is the rong with that
Message-Id: <a2f806f.0403080022.b3e6840@posting.google.com>
Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us> wrote in message news:<um5b2c.116.ln@goaway.wombat.san-francisco.ca.us>...
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> [comp.lang.perl is dead, baby]
>
> On 2004-03-06, Sameh Abdelatef <samehabdelatef@yahoo.com> wrote:
> >
> > I used to use[ open (FAILEHANDLER, ">>$filename");] to open and add
> > new lines to $filename, but it didn't work any more.
>
> Define ''didn't work''--post a short script that duplicates the problem,
> and what happens when you run the script.
When the script run it did not write any thing to the file as
expected, also return empty page with out completing the rest of
script. There is no error occurs at the error log file.
I'm so sorry if I describe the problem in brief
------------------------------
Date: 8 Mar 2004 09:18:31 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: printf
Message-Id: <c2hdp7$3he$1@mamenchi.zrz.TU-Berlin.DE>
kielhd <kielhd@freenet.de> wrote in comp.lang.perl.misc:
> Hi NG,
> ich muß Variablen mit mehr als 50 Zeichen Länge in einem Script
> verarbeiten.
> U. a. muß ich diese Variable auch via printf ausgeben, aber nciht die
> gesamte Veriable, sondern nur die ersten 30 Zeichen.
> Natürlich bietet Perl viele Möglichkeiten die Variable entsprechend zu
> kürzen und dann auszugeben - dies kommt in meinem konkreten Fall aber
> nicht in Frage.
Why not?
> Frage: Gibt es eine Option von printf, die nur die ersten 30 Zeichen
> einer 50 Zeichen langen Variable ausgibt?
Have you read the doc about printf, and the one about sprintf that it
points you to? It's all there.
Anno
------------------------------
Date: Mon, 8 Mar 2004 10:01:51 -0000
From: "Bumble" <bumble@what.the.heck>
Subject: Re: String Search containing a '/' character
Message-Id: <c2hg8b$p01$1@newsg1.svr.pol.co.uk>
Anno Siegel wrote:
> Bumble <bumble@what.the.heck> wrote in comp.lang.perl.misc:
>> Basically I have a date, say 02/04, in a text file. I need to find
>> that so i've got
>>
>> if ($line=~m/\d\d??\d\d/)
>>
>> to find the 2 lots of digits (the date and month) but I can't work
>> out how I add the / in there (in place of the ??) I've tried a few
>> things but nothing is working?
>
> Did "a few things" include escaping the "/" with a backslash? That
> isn't the best method, but it is certainly something to try, and it
> works. It's better to use an alternative delimiter instead of "/".
> So both "/\d\d\/\d\d/" and "m!\d\d/\d\d!" should work.
>
> Anno
Thanks, I did actually try that but it didn't seem to work. Maybe it was
another problem, I will give it a go! Thanks again.
--
Bumble
http://bumble.rumble.at
http://www.cossar.co.uk
"PaulB is nowt more than a top-posting fuckwit. Ignore the prat." -
Paul-B
------------------------------
Date: Mon, 8 Mar 2004 06:59:07 -0400
From: "Martin Livingston" <mjpliv@hfx.eastlink.ca>
Subject: Re: teaching myself perl - stumped on this one!
Message-Id: <UjY2c.2755$kc2.55625@nnrp1.uunet.ca>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnc4null.vv5.tadmc@magna.augustmail.com...
> Martin Livingston <mjpliv@hfx.eastlink.ca> wrote:
>
> > The html gets written correctly to the server but the image
> > file only creates the file name without any data in the permanent images
> > directory.
>
> > Here is the first portion of the script (with the absolute paths blanked
> > out). I am sure I am just using the FILEHANDLES incorrectly and would
> > appreciate any help available out there.
>
>
> Read about the $/ variable in perlvar.pod, and about binmode()
> in perlfunc.pod.
>
>
> > #!/usr/bin/perl
>
> You should ask for all the help you can get:
>
> use warnings;
> use strict;
>
>
> > $meta = $catagory . " " . $name . " " . $description . " " . $source . "
" .
> > $origin;
>
>
> my $meta = "$catagory $name $description $source $origin";
> ^
> ^ sic
>
>
> Much easier to see what's going on, don't you think?
>
>
> > open (TEMPORARY,
"</xxx/xxx/x/xx/xx/xxxxx/web/nugget/temp/$imgfilename");
>
>
> You should always, yes *always*, check the return value from open():
>
> open (TMPIMAGE, "</xxx/xxx/x/xx/xx/xxxxx/web/nugget/temp/$imgfilename")
> or die "could not open .../$imgfilename $!";
>
>
> TEMPORARY is a pretty useless choice of name.
>
>
> > $temp_img=(TEMPORARY);
>
>
> You use <angle brakets> for reading from a filehandle, not (parenthesis).
>
> If you use the <input operator> in scalar context like that, you
> may leave part of the file unread...
>
>
> > open (IMAGEFILE,
> > ">>/xxx/xxx/x/xx/xx/xxxxx/web/nugget/cookbook/images/$imgfilename");
>
>
> Why are you open()ing for append rather than for write?
>
> Have you turned binmode() on?
>
> Check the return value from open().
>
>
> > print IMAGEFILE "$temp_img";
> ^ ^
> ^ ^ A useless use of double quotes
>
>
> What's wrong with always quoting "$vars"?
>
>
> > open (PAGEFILE,
> > ">/xxx/xxx/x/xx/xx/xxxxx/web/nugget/cookbook/$catagory/$filename");
> > print PAGEFILE
qq(<html>\n<head>\n<title>$name</title>\n</head>\n<body>\n);
> ^^^^^^
> > print PAGEFILE qq(<META NAME=description CONTENT=$description>\n);
> > print PAGEFILE qq(<META NAME=keywords CONTENT= $meta>\n);
> > print PAGEFILE qq(<body bgcolor="#e6e6fa" TOPMARGIN=5 LEFTMARGIN=2
> ^^^^^
>
> How many <body> elements are you supposed to have in an HTML document?
>
>
> > MARGINHEIGHT=0 MARGINWIDTH=2>\n);
> > print PAGEFILE qq(<table width=600 align=center CELLPADDING=0 border=0
> > CELLSPACING=0>\n);
>
>
> Use a here-doc instead of a bazillion print()s:
>
> print PAGEFILE <<ENDHTML;
> <html>
> <head>
> <title>$name</title>
> </head>
> <body>
> <META NAME=description CONTENT=$description>
> <META NAME=keywords CONTENT= $meta>
> <body bgcolor="#e6e6fa" TOPMARGIN=5 LEFTMARGIN=2 MARGINHEIGHT=0
MARGINWIDTH=2>
> <table width=600 align=center CELLPADDING=0 border=0 CELLSPACING=0>
> ENDHTML
>
>
> Much easier to see what's going on, don't you think?
>
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Mon, 8 Mar 2004 07:00:24 -0400
From: "Martin Livingston" <mjpliv@hfx.eastlink.ca>
Subject: Re: teaching myself perl - stumped on this one!
Message-Id: <1lY2c.2756$kc2.55773@nnrp1.uunet.ca>
Thanks for the advice! I will work on it!
Martin L.
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnc4null.vv5.tadmc@magna.augustmail.com...
> Martin Livingston <mjpliv@hfx.eastlink.ca> wrote:
>
> > The html gets written correctly to the server but the image
> > file only creates the file name without any data in the permanent images
> > directory.
>
> > Here is the first portion of the script (with the absolute paths blanked
> > out). I am sure I am just using the FILEHANDLES incorrectly and would
> > appreciate any help available out there.
>
>
> Read about the $/ variable in perlvar.pod, and about binmode()
> in perlfunc.pod.
>
>
> > #!/usr/bin/perl
>
> You should ask for all the help you can get:
>
> use warnings;
> use strict;
>
>
> > $meta = $catagory . " " . $name . " " . $description . " " . $source . "
" .
> > $origin;
>
>
> my $meta = "$catagory $name $description $source $origin";
> ^
> ^ sic
>
>
> Much easier to see what's going on, don't you think?
>
>
> > open (TEMPORARY,
"</xxx/xxx/x/xx/xx/xxxxx/web/nugget/temp/$imgfilename");
>
>
> You should always, yes *always*, check the return value from open():
>
> open (TMPIMAGE, "</xxx/xxx/x/xx/xx/xxxxx/web/nugget/temp/$imgfilename")
> or die "could not open .../$imgfilename $!";
>
>
> TEMPORARY is a pretty useless choice of name.
>
>
> > $temp_img=(TEMPORARY);
>
>
> You use <angle brakets> for reading from a filehandle, not (parenthesis).
>
> If you use the <input operator> in scalar context like that, you
> may leave part of the file unread...
>
>
> > open (IMAGEFILE,
> > ">>/xxx/xxx/x/xx/xx/xxxxx/web/nugget/cookbook/images/$imgfilename");
>
>
> Why are you open()ing for append rather than for write?
>
> Have you turned binmode() on?
>
> Check the return value from open().
>
>
> > print IMAGEFILE "$temp_img";
> ^ ^
> ^ ^ A useless use of double quotes
>
>
> What's wrong with always quoting "$vars"?
>
>
> > open (PAGEFILE,
> > ">/xxx/xxx/x/xx/xx/xxxxx/web/nugget/cookbook/$catagory/$filename");
> > print PAGEFILE
qq(<html>\n<head>\n<title>$name</title>\n</head>\n<body>\n);
> ^^^^^^
> > print PAGEFILE qq(<META NAME=description CONTENT=$description>\n);
> > print PAGEFILE qq(<META NAME=keywords CONTENT= $meta>\n);
> > print PAGEFILE qq(<body bgcolor="#e6e6fa" TOPMARGIN=5 LEFTMARGIN=2
> ^^^^^
>
> How many <body> elements are you supposed to have in an HTML document?
>
>
> > MARGINHEIGHT=0 MARGINWIDTH=2>\n);
> > print PAGEFILE qq(<table width=600 align=center CELLPADDING=0 border=0
> > CELLSPACING=0>\n);
>
>
> Use a here-doc instead of a bazillion print()s:
>
> print PAGEFILE <<ENDHTML;
> <html>
> <head>
> <title>$name</title>
> </head>
> <body>
> <META NAME=description CONTENT=$description>
> <META NAME=keywords CONTENT= $meta>
> <body bgcolor="#e6e6fa" TOPMARGIN=5 LEFTMARGIN=2 MARGINHEIGHT=0
MARGINWIDTH=2>
> <table width=600 align=center CELLPADDING=0 border=0 CELLSPACING=0>
> ENDHTML
>
>
> Much easier to see what's going on, don't you think?
>
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Mon, 8 Mar 2004 07:01:00 -0400
From: "Martin Livingston" <mjpliv@hfx.eastlink.ca>
Subject: Re: teaching myself perl - stumped on this one!
Message-Id: <BlY2c.2757$kc2.55881@nnrp1.uunet.ca>
Thanks for the second set of eyes, I believe you are correct!
Martin L.
"Abhinav" <Me@myco.com> wrote in message
news:KlT2c.3$ql6.157@news.oracle.com...
> Hi Martin,
>
> Martin Livingston wrote:
> > Hi,
> >
> > I bought a book ( PERL and CGI For the World Wide Web - Elizabeth
Castro )
> > learn the basics. I have put together a dozen or so working scripts but
this
> > one has me stumped.
> >
> > This is a "real world" exercise. I am putting together a "cookbook" for
a
> > friend. She fills in a form with the recipe details and selects a image
file
> > to appear on the finished web page. When she "submits" the form it
returns a
> > copy of the preview page with the image in place where the image file is
> > stored in a temporary location on my server. Up to this point everything
> > works just fine.
> >
> > If she is happy with the preview page, she "submits" this page to be
stored
> > on the server. The html gets written correctly to the server but the
image
> > file only creates the file name without any data in the permanent images
> > directory. However, the script deletes the old file properly.
> >
> > Here is the first portion of the script (with the absolute paths blanked
> > out). I am sure I am just using the FILEHANDLES incorrectly and would
> > appreciate any help available out there. I used comment lines to explain
> > what I am trying to do.
> >
> > Thanks
> > Martin L.
> >
> > #!/usr/bin/perl
> > use CGI ':standard';
> >
> > #import the data from the hidden fields from the recipe preview page
> >
> > $catagory=param("catagory");
> > $name=param("name");
> > $description=param("description");
> > $source=param("source");
> > $origin=param("origin");
> > $ingredients=param("ingredients");
> > $method=param("method");
> > $service=param("service");
> > $picture=param("picture");
> > $filename= param("filename");
> > $imgfilename = param("imgfilename");
> >
> > #build the meta tags for the website search engine
> >
> > $meta = $catagory . " " . $name . " " . $description . " " . $source . "
" .
> > $origin;
> >
> > #see if picture file was uploaded
> >
> > if ($picture) {
> >
> > #get image from temporary image directory
> >
> > open (TEMPORARY,
"</xxx/xxx/x/xx/xx/xxxxx/web/nugget/temp/$imgfilename");
> >
> > $temp_img=(TEMPORARY);
> >
> > close (TEMPORARY);
> >
> > #delete temporary image file
> >
> > unlink ("/xxx/xxx/x/xx/xx/xxxxx/web/nugget/temp/$imgfilename");
> >
> > #copy image file to the cookbook images directory
> >
> > open (IMAGEFILE,
> > ">>/xxx/xxx/x/xx/xx/xxxxx/web/nugget/cookbook/images/$imgfilename");
> >
>
> This cold be a red herring (and Im nerw to perl too ! ) but shouldn't
> the above FILEHANDLE be opened with ">" instead of ">>" ?
> > print IMAGEFILE "$temp_img";
> >
> > close (IMAGEFILE);
> >
> > }
> >
> > #Copy html to the appropriate folder in the cookbook directory
> >
> > open (PAGEFILE,
> > ">/xxx/xxx/x/xx/xx/xxxxx/web/nugget/cookbook/$catagory/$filename");
> > print PAGEFILE
qq(<html>\n<head>\n<title>$name</title>\n</head>\n<body>\n);
> > print PAGEFILE qq(<META NAME=description CONTENT=$description>\n);
> > print PAGEFILE qq(<META NAME=keywords CONTENT= $meta>\n);
> > print PAGEFILE qq(<body bgcolor="#e6e6fa" TOPMARGIN=5 LEFTMARGIN=2
> > MARGINHEIGHT=0 MARGINWIDTH=2>\n);
> > print PAGEFILE qq(<table width=600 align=center CELLPADDING=0 border=0
> > CELLSPACING=0>\n);
> >
> >
> Please let me know if thats the problem or I've pointed out a no-go .. :)
>
> Regards
> Abhinav
>
------------------------------
Date: Mon, 8 Mar 2004 17:40:09 +0800
From: "ckacka" <ckacka@163.com>
Subject: the 3 options(-base, -xbase, -target)'s meaning in start_html?
Message-Id: <c2hf1l$1ts58s$1@ID-224383.news.uni-berlin.de>
thanks
------------------------------
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 V10 Issue 6232
***************************************