[29202] in Perl-Users-Digest
Perl-Users Digest, Issue: 446 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 19 00:09:45 2007
Date: Fri, 18 May 2007 21:09:04 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 18 May 2007 Volume: 11 Number: 446
Today's topics:
Re: [newbie] Year in two digits; Time with leading zero <hjp-usenet2@hjp.at>
Re: [newbie] Year in two digits; Time with leading zero <stoupa@practisoft.cz>
Re: CGI.pm filefield return is inconsistent between I.E <waveright@gmail.com>
Re: Checking the syntax of Perl code <uri@stemsystems.com>
Re: Checking the syntax of Perl code <knipknap@gmail.com>
Re: Checking the syntax of Perl code (Randal L. Schwartz)
Re: Checking the syntax of Perl code xhoster@gmail.com
data table using <george.titus@gmail.com>
Re: data table using usenet@DavidFilmer.com
Re: data table using <george.titus@gmail.com>
Re: display datestamp in HTML <joe@inwap.com>
Re: encoding problem on Tk entry widget <ch.l.ngre@online.de>
Escaping backslashes in 'HERE documents'? <jaford@watford53.freeserve.co.uk>
Re: Escaping backslashes in 'HERE documents'? <devliegendehollander@attempt-at-not-applicable-domain-name.com>
Re: Escaping backslashes in 'HERE documents'? <jaford@watford53.freeserve.co.uk>
Re: Escaping backslashes in 'HERE documents'? <gypark@gmail.com>
Re: Parsing a text file line-by-line: skipping badly-fo <hjp-usenet2@hjp.at>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 18 May 2007 21:13:17 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: [newbie] Year in two digits; Time with leading zero
Message-Id: <slrnf4rumd.9f1.hjp-usenet2@zeno.hjp.at>
On 2007-05-18 14:13, Petr Vileta <stoupa@practisoft.cz> wrote:
> "Gilles Ganault" <nospam@nospam.com> píse v diskusním príspevku
> news:0mnq431eosb3upimj6g4g7jht6tp752ccs@4ax.com...
>> I just need to get the current year in two digits,
>
> This is simple:
>
> ($min, $hrs, $day, $month, $year) = (localtime) [1,2,3,4,5];
> $currentdate = sprintf("%02d/%02d/%02d", $day, $month+1,
> substr($year,-2,2));
^^^^^^^^^^^^^^^^^^
That's just plain ugly. What's wrong with ($year % 100)?
hp
--
_ | Peter J. Holzer | I know I'd be respectful of a pirate
|_|_) | Sysadmin WSR | with an emu on his shoulder.
| | | hjp@hjp.at |
__/ | http://www.hjp.at/ | -- Sam in "Freefall"
------------------------------
Date: Sat, 19 May 2007 03:41:52 +0200
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: [newbie] Year in two digits; Time with leading zero
Message-Id: <f2lltt$253b$1@ns.felk.cvut.cz>
"Peter J. Holzer" <hjp-usenet2@hjp.at> píše v diskusním příspěvku
news:slrnf4rumd.9f1.hjp-usenet2@zeno.hjp.at...
> On 2007-05-18 14:13, Petr Vileta <stoupa@practisoft.cz> wrote:
>> "Gilles Ganault" <nospam@nospam.com> píse v diskusním príspevku
>> news:0mnq431eosb3upimj6g4g7jht6tp752ccs@4ax.com...
>>> I just need to get the current year in two digits,
>>
>> This is simple:
>>
>> ($min, $hrs, $day, $month, $year) = (localtime) [1,2,3,4,5];
>> $currentdate = sprintf("%02d/%02d/%02d", $day, $month+1,
>> substr($year,-2,2));
> ^^^^^^^^^^^^^^^^^^
> That's just plain ugly. What's wrong with ($year % 100)?
>
This is my groove only ;-) Yes in this case are both the same, but you can
write it like this:
($min, $hrs, $day, $month, $year) = (localtime) [1,2,3,4,5];
$currentdate = sprintf("%02d/%02d/%s", $day, $month+1, substr($year,-2,2));
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
------------------------------
Date: 18 May 2007 11:27:38 -0700
From: trwww <waveright@gmail.com>
Subject: Re: CGI.pm filefield return is inconsistent between I.E and Opera/Firefox
Message-Id: <1179512858.594103.62360@k79g2000hse.googlegroups.com>
On May 18, 1:04 pm, "evil...@gmail.com" <evil...@gmail.com> wrote:
> Hi
>
> If I have the following line:
>
> my $url = $q->filefield('url','ignored','30');
>
> in my cgi code, a file selector widget is created. I then choose a
> file from somewhere on my network. The form is sent to my next cgi
> script which displays the value of
>
> $q->param("url")
>
> The problem is that Internet Explorer displays the full relative path
> of the file and the filename, e.g.
>
> C:\pcb_data_dump\eco5_01GR_issue3.emp
>
> however the same code run through Opera or Firefox will simply display
> the filename with no path e.g.
>
> eco5_01GR_issue3.emp
>
> I really need the full relative path - how can I get hold of it with
> Opera or Firefox?
>
> Thanks for any help
> Len
Your question is OT (not that you knew that) because the browsers were
simply programmed to behave differently. I dont have the CGI spec in
front of me, but I'm guessing that the part about the upload fields
didnt specify exactly how that should work, so you get different
implementations on different browsers.
You could use javascript to set a hidden field by extracting the value
of the file field like I've done on this page:
http://www.waveright.com/filefield.html
Here I've used a text field instead of a hidden field so you can see
the behavior.
But then your users have to have JS turned on unless you come up with
a workaround.
Hope this helps, and please find a more suitable newsgroup to send
followup questions to.
Todd W.
------------------------------
Date: Fri, 18 May 2007 18:24:23 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Checking the syntax of Perl code
Message-Id: <x7ps4yq9bc.fsf@mail.sysarch.com>
>>>>> "S" == Samuel <knipknap@gmail.com> writes:
>> why do you think you
>> need code gen for your problem?
S> We are using a highly specialized template language for controlling
S> appliances, which we compile into Perl code. There are probably other
S> ways to do this, but none that were similarly easy and straight
S> forward to do.
that is definitely not the best (nor easiest) way to do
templating. there are (too) many templating modules already out there. i
am sure one of them does what you want and it will likely be faster and
better.
and what you may call a highly specialized template language, someone
else may call a trivial feature already implemented. so post some of
this template language and i bet you will be able to save a lot of
coding when you get answers to your real problem (not the eval
question).
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 18 May 2007 11:55:04 -0700
From: Samuel <knipknap@gmail.com>
Subject: Re: Checking the syntax of Perl code
Message-Id: <1179514504.169583.126260@n59g2000hsh.googlegroups.com>
On May 18, 8:24 pm, Uri Guttman <u...@stemsystems.com> wrote:
> that is definitely not the best (nor easiest) way to do
> templating. there are (too) many templating modules already out there.
Alright, I'll bite. The template looks like any other template
language:
{if device.vendor() is "cisco"}
show conf {extract /^interface (\S+)\.(\d+)/ as interfaces, units}
{loop interfaces as interface}
show interfaces {$interface} controller
{end}
{end}
I'm not in the office, but this is a simplified version of the
compiled template:
if ($device->vendor() eq "cisco") {
my @response = $stream->send("show conf");
my @interfaces;
my @units;
for (@response) {
next unless /^interface (\S+)\.(\d+)/;
push(@interfaces, $1);
push(@units, $2);
}
for my $interface (@interfaces) {
my @response = $stream->send("show interfaces $interface
controller");
}
}
(I skipped the included error handling, locking for parallelization
via threads, and some more.) This took less than a day to fully
implement.
Yes, some template languages are somewhat flexible and allow you to
register your own functions, but that's really not good enough. Also,
I believe that parsers and lexers do not really gain you a lot when
parsing this. The code isn't open sourced yet (it will be soon), but I
bet it will be hard to implement this with significantly less LOC
(approx. 350 currently), even by introducing new dependencies. Either
way, the time it took to write this is probably even less than the
time it would take to research any other template language.
-Samuel
------------------------------
Date: Fri, 18 May 2007 13:20:23 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: Samuel <knipknap@gmail.com>
Subject: Re: Checking the syntax of Perl code
Message-Id: <86646panp4.fsf@blue.stonehenge.com>
>>>>> "Samuel" == Samuel <knipknap@gmail.com> writes:
Samuel> Well, maybe I made an incorrect assumption there - is there a way to
Samuel> use eval for checking the syntax *without executing the code* that I
Samuel> am not aware of?
Not absolutely.
There are definitely Perl constructs that cannot be parsed (even by
/usr/bin/perl) without having executed *some* Perl in the process.
Parsing Perl as a static document is impossible in the general case.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: 18 May 2007 20:30:00 GMT
From: xhoster@gmail.com
Subject: Re: Checking the syntax of Perl code
Message-Id: <20070518163002.956$gF@newsreader.com>
Samuel <knipknap@gmail.com> wrote:
> On May 18, 4:16 pm, Tim Southerwood <t...@dionic.net> wrote:
> > Is there a problem with using eval()?
>
> Well, maybe I made an incorrect assumption there - is there a way to
> use eval for checking the syntax *without executing the code* that I
> am not aware of?
If the code doesn't use BEGIN or END blocks of its own, or their moral
equivalents, then you could do something like this:
eval $whatever . q{;BEGIN {die "reached end\n"}};
unless ($@ eq "reached end\n") {
Something_is_wrong_with($whatever, $@);
};
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 18 May 2007 15:28:24 -0700
From: geot <george.titus@gmail.com>
Subject: data table using
Message-Id: <1179527304.037891.262930@k79g2000hse.googlegroups.com>
please help
i am new to perl ,using CGI and DBI,
iam asked to create a html table reading data from database table
and i should be able to edit or delete that values .
how to edit or delete value in a html table using perl
------------------------------
Date: 18 May 2007 17:13:52 -0700
From: usenet@DavidFilmer.com
Subject: Re: data table using
Message-Id: <1179533632.602955.153150@q23g2000hsg.googlegroups.com>
On May 18, 3:28 pm, geot <george.ti...@gmail.com> wrote:
> please help
>
> i am new to perl ,using CGI and DBI,
> iam asked to create a html table reading data from database table
> and i should be able to edit or delete that values .
> how to edit or delete value in a html table using perl
This has already been writtten for you (but in php, not Perl); check
out the amazing (and free, open-source) phpMyAdmin:
http://www.phpmyadmin.net
--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)
------------------------------
Date: 18 May 2007 17:59:24 -0700
From: geot <george.titus@gmail.com>
Subject: Re: data table using
Message-Id: <1179536364.060205.299410@h2g2000hsg.googlegroups.com>
On May 18, 8:13 pm, use...@DavidFilmer.com wrote:
> On May 18, 3:28 pm, geot <george.ti...@gmail.com> wrote:
>
> > please help
>
> > i am new to perl ,using CGI and DBI,
> > iam asked to create a html table reading data from database table
> > and i should be able to edit or delete that values .
> > how to edit or delete value in a html table using perl
>
> This has already been writtten for you (but in php, not Perl); check
> out the amazing (and free, open-source) phpMyAdmin:
>
> http://www.phpmyadmin.net
>
> --
> The best way to get a good answer is to ask a good question.
> David Filmer (http://DavidFilmer.com)
pls
my question is somethiming like this
Report View
SL.NO|Company name|Ticket No|Ticket Type|Ticket Desc|Approximate Time|
Status|Priority|Issue Description|SLA|Follow Ups|Edit/Delete
1|MULTACOM|3631|Campaigns| 4 Inkjets 20 min Edit/Delete
<======= how ?
------------------------------
Date: Fri, 18 May 2007 11:13:05 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: display datestamp in HTML
Message-Id: <uIWdnYlFn5YhcdDbnZ2dnUVZ_hudnZ2d@comcast.com>
Phil M wrote:
> However, I had to rename the file with a .shtml to work. Is there any
> way to keep the .html extension?
You'll have to ask the person who controls the configuration file for
the web server. If they don't allow individual .htaccess files, the
answer is "no".
-Joe
------------------------------
Date: Sat, 19 May 2007 00:37:47 +0200
From: Ch Lamprecht <ch.l.ngre@online.de>
Subject: Re: encoding problem on Tk entry widget
Message-Id: <f2l9rm$4n0$2@online.de>
filippo wrote:
> On 17 Mag, 10:45, Ch Lamprecht <ch.l.n...@online.de> wrote:
>>
>> $dh->do("SET client_encoding TO 'UTF8'");
>
>
>
> thanks today I will try it.
>
> I understand that could be a encoding problem between db (latin9) and
> windows (utf8).
>
> I know it's of topic here, but do you know how can I convert my
> database from LATIN9 to UTF8 to avoid such problems?
>
> Thanks,
>
> Filippo
>
Hi,
you won't have problems if you set your client_encoding to something your client
can handle. However, if you want to convert your database encoding, you will
have to dump the database (using pg_dump), recreate it with encoding set to UTF8
(CREATE DATABASE your_database_name WITH ENCODING = 'UTF8') and restore from
your backup file (using psql).
HTH, Christoph
--
use Tk;use Tk::GraphItems;$c=tkinit->Canvas->pack;push@i,Tk::GraphItems->
TextBox(text=>$_,canvas=>$c,x=>$x+=70,y=>100)for(Just=>another=>Perl=>Hacker);
Tk::GraphItems->Connector(source=>$i[$_],target=>$i[$_+1])for(0..2);
$c->repeat(30,sub{$_->move(0,4*cos($d+=3.16))for(@i)});MainLoop
------------------------------
Date: Fri, 18 May 2007 20:03:37 GMT
From: Jim Ford <jaford@watford53.freeserve.co.uk>
Subject: Escaping backslashes in 'HERE documents'?
Message-Id: <tEn3i.129$k32.3@newsfe4-gui.ntli.net>
Is there a way of avoiding having to escape a backslash character with
another backslash in a 'HERE document'?
When creating Latex documents with a perl script, it's convenient to use
'HERE documents'. This enables Latex code to be written without the
clutter of 'print', double quotes, newline characters and semicolons -
producing almost 'clean' Latex coding. The only thing preventing 'pure'
Latex code being written is the necessity of escaping the ubiquitous
backslash character with another backslash - which ends up with this
sort of thing being created:
print <<"WEEKS";
\\begin{tabular}{|c||r|c|c|c|c|c|c|c|c|c|c|}
\\hline
& & {\\textbf{\\ 1\\ \\ }} &{\\textbf{\\ 2\\ \\ }} .... and so on
Jim Ford
------------------------------
Date: Fri, 18 May 2007 22:20:27 +0200
From: De Vliegende Hollander <devliegendehollander@attempt-at-not-applicable-domain-name.com>
Subject: Re: Escaping backslashes in 'HERE documents'?
Message-Id: <464e0a8b$0$30904$e4fe514c@dreader26.news.xs4all.nl>
The sentient life form Jim Ford posted the following:
> print <<"WEEKS";
Try print <<'WEEKS';
which should prevent interpolation.
------------------------------
Date: Fri, 18 May 2007 21:50:15 GMT
From: Jim Ford <jaford@watford53.freeserve.co.uk>
Subject: Re: Escaping backslashes in 'HERE documents'?
Message-Id: <rcp3i.410$M22.226@newsfe1-win.ntli.net>
De Vliegende Hollander wrote:
> The sentient life form Jim Ford posted the following:
>
>> print <<"WEEKS";
>
>
> Try print <<'WEEKS';
>
> which should prevent interpolation.
Thanks, but I need interpolation because I've got perl scalars in the
'Here document' e.g.:
\\textbf{$day} & \\textbf{Thursday} & & & & & & & & & & \\\\
Jim Ford
------------------------------
Date: 18 May 2007 16:30:37 -0700
From: Raymundo <gypark@gmail.com>
Subject: Re: Escaping backslashes in 'HERE documents'?
Message-Id: <1179531037.233267.208290@y80g2000hsf.googlegroups.com>
On 5=BF=F919=C0=CF, =BF=C0=C0=FC6=BD=C350=BA=D0, Jim Ford <jaf...@watford53=
.freeserve.co.uk> wrote:
> De Vliegende Hollander wrote:
> > The sentient life form Jim Ford posted the following:
>
> >> print <<"WEEKS";
>
> > Try print <<'WEEKS';
>
> > which should prevent interpolation.
>
> Thanks, but I need interpolation because I've got perl scalars in the
> 'Here document' e.g.:
>
> \\textbf{$day} & \\textbf{Thursday} & & & & & & & & & & \\\\
>
> Jim Ford
Hello,
I tried the following... It seems to work as what you want. But there
might be another problem. :-)
#!/usr/bin/perl
$day =3D "2007.5.19";
# At first, use single quote and nothing is interpolated
$str=3D<<'EOF';
\textbf{$day} & \textbf{Thursday} & & & & & & & & & & \\
EOF
# Now replace single backslash with double backslashes
$str =3D~ s/\\/\\\\/g;
# Perform interpolation
eval '$str=3D"'.$str.'";';
# Print
print $str;
------------------------------
Date: Fri, 18 May 2007 21:07:14 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Parsing a text file line-by-line: skipping badly-formed lines?
Message-Id: <slrnf4rub2.9f1.hjp-usenet2@zeno.hjp.at>
On 2007-05-18 13:28, denis.papathanasiou@gmail.com <denis.papathanasiou@gmail.com> wrote:
> $ wc qte20070430
> wc: qte20070430: Input/output error
[...]
>
> $ cat qte20070430 >/dev/null || echo "disk file error"
> cat: qte20070430: Input/output error
If you get I/O errors, you don't have "badly-formed lines", you have a
hardware problem. Buy a new hard disk and restore your last working
backup (You do have a backup, right?)
You may be able to use dd_rescue to salvage parts of the file, but a 14
GB file with some random parts replaced with zeros probably isn't that
useful.
hp
--
_ | Peter J. Holzer | I know I'd be respectful of a pirate
|_|_) | Sysadmin WSR | with an emu on his shoulder.
| | | hjp@hjp.at |
__/ | http://www.hjp.at/ | -- Sam in "Freefall"
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 446
**************************************