[22115] in Perl-Users-Digest
Perl-Users Digest, Issue: 4337 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 3 11:05:52 2003
Date: Fri, 3 Jan 2003 08:05:08 -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 Fri, 3 Jan 2003 Volume: 10 Number: 4337
Today's topics:
Re: AWK vs PERL - splitting fields <bart.lateur@pandora.be>
Re: AWK vs PERL - splitting fields <mgjv@tradingpost.com.au>
Re: AWK vs PERL - splitting fields (Christopher Hamel)
Can't use string as an ARRAY ref while "strict refs" in (Ricardo)
Re: Can't use string as an ARRAY ref while "strict refs (Anno Siegel)
core dump in a regex.... (Francois Menard)
Re: core dump in a regex.... (Anno Siegel)
help with FormParser.pm, multiple forms on the page (mx)
Re: Learn about natural male enhancement (qk07 <kasp@NO_SPAMepatra.com>
Re: Learn about natural male enhancement (qk07 <usenet@dwall.fastmail.fm>
Re: Loop with Array or Loop and Read File? <kasp@NO_SPAMepatra.com>
Re: Need help with split (Kevin Cline)
Re: Need help with split (Kevin Cline)
Re: Need help with split (Helgi Briem)
Re: Prototype declaration with built-in function (Jeff Mott)
Re: RecDescent and variables (Peter H.J. v.d. Kamp)
Removing xml string from header - CGI.pm (samir)
Re: Removing xml string from header - CGI.pm <nobull@mail.com>
Re: Removing xml string from header - CGI.pm <wsegrave@mindspring.com>
Re: Sorting hash tree from Xml::simple. (stew dean)
Re: stdin binary or text ? (Villy Kruse)
Re: system command and $_ variable <bongie@gmx.net>
Re: What is wrong in my SYSTEM commad <jurgenex@hotmail.com>
Re: What is wrong in my SYSTEM commad <kasp@NO_SPAMepatra.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 03 Jan 2003 09:38:45 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: AWK vs PERL - splitting fields
Message-Id: <nema1vo7efhham3co9hj839r6772g2sv4g@4ax.com>
Martien Verbruggen wrote:
>awk is much more a programming language than cat. it is probably not
>a general purpose programming language, but it has most of the
>constructs needed for it to be a programming language. It's got
>conditionals, loops, variables, boolean operators, mathematical
>operators and functions, and loads more. It may be a spacialised
>programming language,but I'm pretty sure it is one :)
The SE's knock dead argument: is it Turing complete? I don't know that
much about the Turing engine, but Awk does sound more powerful.
--
Bart.
------------------------------
Date: Fri, 3 Jan 2003 22:48:34 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: AWK vs PERL - splitting fields
Message-Id: <slrnb1au4i.4tt.mgjv@martien.heliotrope.home>
On Fri, 03 Jan 2003 09:38:45 GMT,
Bart Lateur <bart.lateur@pandora.be> wrote:
> Martien Verbruggen wrote:
>
>>awk is much more a programming language than cat. it is probably not
>>a general purpose programming language, but it has most of the
>>constructs needed for it to be a programming language. It's got
>>conditionals, loops, variables, boolean operators, mathematical
>>operators and functions, and loads more. It may be a spacialised
>>programming language,but I'm pretty sure it is one :)
>
> The SE's knock dead argument: is it Turing complete? I don't know that
> much about the Turing engine, but Awk does sound more powerful.
I was thinking about putting that in, but I'm not certain whether it is.
I even did a quick google search, but couldn't quickly turn up anything
authoritative. Then I had to go to a meeting, so I just posted it :)
I know that vi's commands provide a turing-complete language, so I'm
pretty confident that sed and awk are as well.
I just looked for a turing machine in awk, and found some of those (they
all seem to be in japanese though...), which proves that awk is turing
complete. Ubfortunately, turing-completeness is a sufficiently low
requirement for it not to make it a comfortable language :)
Martien
--
|
Martien Verbruggen | prepBut nI vrbLike adjHungarian! qWhat's
| artThe adjBig nProblem? -- Alec Flett
|
------------------------------
Date: 3 Jan 2003 08:01:35 -0800
From: hamelcd@hotmail.com (Christopher Hamel)
Subject: Re: AWK vs PERL - splitting fields
Message-Id: <4f60d5b3.0301030801.7ceb93d8@posting.google.com>
> Christopher Hamel wrote:
> >
> > On that note, 'cut' is likely faster than AWK if the only goal is
> > splitting fields, but neither AWK nor cut nor <insert favorite OS tool
> > here> is really a programming language. AWK is a nice tool, and I
> > like it a lot, but it's no more a programming lanugage than 'cat.'
Various people replied:
> I'm sure Alfred Aho, Brian Kernighan, and Peter Weinberger would
> disagree with you. :-)
>
> http://cm.bell-labs.com/cm/cs/awkbook/
- - - - -
> I disagree on that (although I rarely use awk anymore).
> awk has conditionals, loops and other control structures, arrays,
> functions etc., and I knew people who wrote awk programs that filled
> pages ... well, most of them use Perl now. :)
- - - - -
> I disagree.
> awk is much more a programming language than cat. it is probably not
> a general purpose programming language, but it has most of the
> constructs needed for it to be a programming language. It's got
> conditionals, loops, variables, boolean operators, mathematical
> operators and functions, and loads more. It may be a spacialised
> programming language,but I'm pretty sure it is one :)
- - - - -
UNCLE!
To be clear, I meant no disrespect to Mr. A, W, K nor to the tool
itself. I use it frequently and even prefer it over Perl in limited
circumstances. When I think of AWK, however, I think of a stream of
data goes in, something happens to it, and a [modified stream] of data
goes out. To me, that's a tool (sed, grep, tail). Yes, it has
properties of a programming language, but a whale has properties of a
fish; that doesn't make it a fish.
Nonetheless, I did a quick google search only to find I am alone in my
viewpoint. Therefore, I will concede. AWK is a programming language.
Chris is wrong.
Apologies for the off-topic drift.
------------------------------
Date: 3 Jan 2003 04:22:15 -0800
From: dpw@clara.co.uk (Ricardo)
Subject: Can't use string as an ARRAY ref while "strict refs" in use (again)
Message-Id: <2911a09c.0301030422.29cd2e46@posting.google.com>
I know we have done this countless times before, but bear with me.
No need to put the whole script here, but I am reading the column
names of an SQL db into an array @db_cols. The first 4 (of a great
many) entries are: CB_Pax CB_CD4 HL_p53 HL_BOB1
Next I need to create a new array for each of the 2-letter codes
preceding the underscore, ie @CB, @HL, etc. As there are many db
columns, and I may change the data structure frequently, I don't want
to have to change my script everytime, so thought I could generate the
arrays by using the @db_cols entries:
foreach (@db_cols) {
my @entry = split(/_/);
push @{$entry[0]}, $entry[1];
}
but of course this isn't allowed under 'use strict': Can't use string
("CB") as an ARRAY ref while "strict refs" in use at....
I have read many Q's & A's in c.l.p.m about this error message, but
have either not understood the answer, or the solution hasn't quite
fitted the scenario. For example, I tried using 'push
@{$table{$entry[0]}}, $entry[1]', where %table consisted of keys =
entries from the @db_cols array, and values = aliases, but Perl was
not fooled!
Can anyone enlighten me with the correct way to do this?
------------------------------
Date: 3 Jan 2003 13:07:38 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Can't use string as an ARRAY ref while "strict refs" in use (again)
Message-Id: <av41uq$oqr$1@mamenchi.zrz.TU-Berlin.DE>
Ricardo <dpw@clara.co.uk> wrote in comp.lang.perl.misc:
> I know we have done this countless times before, but bear with me.
>
> No need to put the whole script here, but I am reading the column
> names of an SQL db into an array @db_cols. The first 4 (of a great
> many) entries are: CB_Pax CB_CD4 HL_p53 HL_BOB1
>
> Next I need to create a new array for each of the 2-letter codes
> preceding the underscore, ie @CB, @HL, etc. As there are many db
> columns, and I may change the data structure frequently, I don't want
> to have to change my script everytime, so thought I could generate the
> arrays by using the @db_cols entries:
>
> foreach (@db_cols) {
> my @entry = split(/_/);
> push @{$entry[0]}, $entry[1];
> }
>
> but of course this isn't allowed under 'use strict': Can't use string
> ("CB") as an ARRAY ref while "strict refs" in use at....
>
> I have read many Q's & A's in c.l.p.m about this error message, but
> have either not understood the answer, or the solution hasn't quite
> fitted the scenario. For example, I tried using 'push
> @{$table{$entry[0]}}, $entry[1]',
That's fine so far. The standard way to avoid nasty symrefs is
using a hash whose keys are what would otherwise be variable names
and whose values hold what would be the values of the variables.
> where %table consisted of keys =
> entries from the @db_cols array, and values = aliases, but Perl was
> not fooled!
This sounds as if you tried to initialize the hash in some way before
use. Don't. "push @{$table{$entry[0]}}, $entry[1]" works fine when
$table{ $entry[ 0]} is undefined when the action occurs. The keyword
is "autovivification", to be found in perlref. Of course, it also
works when "$table{ $entry[ 0]}" is already an arrayref. It doesn't
work (under strict) when the hash entry already exists and is a string,
which seems to be the case here.
Anno
------------------------------
Date: 3 Jan 2003 02:39:55 -0800
From: fxmenard@free.fr (Francois Menard)
Subject: core dump in a regex....
Message-Id: <84d2585d.0301030239.2bbadb9d@posting.google.com>
dear mongers
I've had a problem with a perl regex for months and I'm stuck... I
wrote the code hereunder so I can get rid of comments and strings in
C++ files. I have to group everything in the same expression because
of comment-like things in strings, and string-like things in comments.
However, the particular sample I am providing dumps a core... By the
way, vim has lots of difficulty displaying foo.cpp with syntax
highlighting. Maybe it's linked to my problem.
Any idea ?
Francois.
> perl foo.pl foo.c
---------- foo.pl
#!/bin/perl -w
#
use strict;
undef $/;
my $file = <>;
$/ = "\n";
# get rid of comments, multiline comments and strings
$file =~ s{ //.* # single line
comments
| /\* ((?:.|\n)*?) \*/ # multiline comments
# string is hard... $2 doesn't get expanded, \2 doesn't
# seem to like character enumeration
| (["']) ( \\. | (?!\2|\\). )* (\n|\2)
}
{ defined $1 ? "" : defined $2 ? "$2$4" : "" }gex;
print $file;
---------- foo.c
/* a sample that dumps a core with perl 5.6.1 and others */
xmlString = "<elem value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\" value=\"1\" value=\"1\"
value=\"1\" value=\"1\" value=\"1\">";
------------------------------
Date: 3 Jan 2003 11:31:14 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: core dump in a regex....
Message-Id: <av3sa2$l0g$1@mamenchi.zrz.TU-Berlin.DE>
[bogus newsgroup comp.lang.perl removed]
Francois Menard <fxmenard@free.fr> wrote in comp.lang.perl.misc:
> dear mongers
>
> I've had a problem with a perl regex for months and I'm stuck... I
> wrote the code hereunder so I can get rid of comments and strings in
> C++ files. I have to group everything in the same expression because
> of comment-like things in strings, and string-like things in comments.
> However, the particular sample I am providing dumps a core... By the
[snip]
It doesn't for me, neither 5.6.1 nor 5.8.0.
However, you should take a look at "perldoc -q comment" where the
problem of finding and eliminating C++ comments is treated. It seems
to me that your code doesn't cover some of the cases that the faq
discusses.
Anno
------------------------------
Date: 3 Jan 2003 05:52:58 -0800
From: mx@is23dt.com (mx)
Subject: help with FormParser.pm, multiple forms on the page
Message-Id: <b40f7d83.0301030552.60ccb6ac@posting.google.com>
Dear All,
i am trying to extract fields from the one particular form on the web
page using FormParser.pm . Forms have different names and/or different
Action srings, but the same Input fields. Anybody has an idea how
could i do that with the FormParser module? I hope it can be done
without reversing to HTML::Parser or bare regular expressions.
thank you
Max
------------------------------
Date: Fri, 3 Jan 2003 14:16:05 +0530
From: "Kasp" <kasp@NO_SPAMepatra.com>
Subject: Re: Learn about natural male enhancement (qk07dqj9y4)
Message-Id: <av3irc$i7d$1@newsreader.mailgate.org>
[snip begin]
> while( $dick < $max_dick_size ) {
>
> $dick++ ;
> $wallet-- ;
> $dick-- ;
> }
[snip ends]
A better version....
while( $htkds_dick < $max_dick_size ) {
$my_wallet-- ;
}
:-)
--
Perl is designed to give you several ways to do anything, so
consider picking the most readable one.
-- Larry Wall in the perl man page
------------------------------
Date: Fri, 03 Jan 2003 15:05:21 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Learn about natural male enhancement (qk07dqj9y4)
Message-Id: <Xns92F866A215EF1dkwwashere@216.168.3.30>
Kasp <kasp@NO_SPAMepatra.com> wrote on 03 Jan 2003:
: [Uri Guttman wrote:]
>> while( $dick < $max_dick_size ) {
>>
>> $dick++ ;
>> $wallet-- ;
>> $dick-- ;
>> }
> A better version....
>
> while( $htkds_dick < $max_dick_size ) {
> $my_wallet-- ;
> }
It seem to me Uri's point was that one of the spammer's customer's
would *think* his dick was going to get bigger, but in reality the
only thing happening is that his wallet is getting smaller, hence
incrementing and then decrementing $dick. (Perhaps a placebo effect)
A Real Sucker would never exit the loop. To be more realistic there
would have to be a $lifespan variable that causes the loop to end
when it reaches zero; presumably dead people don't give much
consideration to penis size, and they're not known for paying bills
in a timely manner.
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: Fri, 3 Jan 2003 14:24:48 +0530
From: "Kasp" <kasp@NO_SPAMepatra.com>
Subject: Re: Loop with Array or Loop and Read File?
Message-Id: <av3j9r$iho$1@newsreader.mailgate.org>
I feel it's more of an algorithm and performance question rather than Perl.
But go for first method as that should be faster.
--
Perl is designed to give you several ways to do anything, so
consider picking the most readable one.
-- Larry Wall in the perl man page
------------------------------
Date: 3 Jan 2003 02:02:30 -0800
From: kcline17@hotmail.com (Kevin Cline)
Subject: Re: Need help with split
Message-Id: <ba162549.0301030202.44313343@posting.google.com>
"Jodyman" <Jodyman@hotmail.com> wrote in message news:<XH7R9.9359$134.1043839@newsread1.prod.itd.earthlink.net>...
> "Jim Janovich" <bigpun@mindspring.com> wrote in message
> news:aupjv7$pe7$1@slb9.atl.mindspring.net...
> > I have a string that looks like:
> >
> > c:\folder1\folder2\folder3\blah.jpg
> >
> > But the folders can be any number of folders. All I need is the last
> piece
> > (blah.jpg). Can someone help? I was going to split on \ but since there
> > can be any nuber of them I cannot figure it out. Any help would be
> > appreciated.
>
> TMTOW with Perl, You don't even need split, try this too:
>
> #!c:\perl\bin\perl -w
> use strict;
>
> my $filename1 = 'c:\windows\system32\test.jpg';
> my $filename2 = '/home/jodyman/pics/test.jpg';
>
> my ($results1) = $filename1 =~ /\\(\w+\.\w+)$/;
This won't work if the file name is 'Fred and Barney.jpg'
or just plain 'Fred'. Use File::Basename.
------------------------------
Date: 3 Jan 2003 02:08:48 -0800
From: kcline17@hotmail.com (Kevin Cline)
Subject: Re: Need help with split
Message-Id: <ba162549.0301030208.33fed485@posting.google.com>
helgi@decode.is (Helgi Briem) wrote in message news:<3e1054d2.278473734@news.cis.dfn.de>...
> On Mon, 30 Dec 2002 09:09:45 -0500, "Jim Janovich"
> <bigpun@mindspring.com> wrote:
>
> >I have a string that looks like:
> >c:\folder1\folder2\folder3\blah.jpg
> >
> >But the folders can be any number of folders. All I need is the last piece
> >(blah.jpg). Can someone help? I was going to split on \ but since there
> >can be any nuber of them I cannot figure it out. Any help would be
> >appreciated.
>
> #!/perl
> use strict;
> use warnings;
> use File::Basename;
>
> my $fullpath = 'c:\folder1\folder2\folder3\blah.jpg';
>
> $fullpath =~ s:\\:\/:g; # correct the backslashes
I think there's anything wrong with the backslashes.
On Windows, File::Basename will understand Windows paths.
>
> my $basename = basename($fullpath);
>
> print "$basename\n";
> __END__
------------------------------
Date: Fri, 03 Jan 2003 11:08:42 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Need help with split
Message-Id: <3e156ec9.612828030@news.cis.dfn.de>
On 3 Jan 2003 02:08:48 -0800, kcline17@hotmail.com (Kevin
Cline) wrote:
>> $fullpath =~ s:\\:\/:g; # correct the backslashes
>
>I think there's anything wrong with the backslashes.
"don't think", I think you mean.
>On Windows, File::Basename will understand Windows
>paths.
Yes, I know. In Perl it's best not to use
them, though. I put that correction in as
a bit of a joke. Always using forward slashes,
even under Windows, has saved me a lot
of heartache and unnecessary typing.
--
Regards, Helgi Briem
helgi AT decode DOT is
------------------------------
Date: 3 Jan 2003 01:34:19 -0800
From: jeffmott@twcny.rr.com (Jeff Mott)
Subject: Re: Prototype declaration with built-in function
Message-Id: <f9c0ce19.0301030134.7f59193b@posting.google.com>
Also a thought, should use subs be used to declare all routines? Since
Perl internal functions are otherwise invoked, a future version of
perl with a new function under the same name as one of your own would
break a program.
------------------------------
Date: 3 Jan 2003 11:28:20 GMT
From: kamp@inl.nl_nospam (Peter H.J. v.d. Kamp)
Subject: Re: RecDescent and variables
Message-Id: <av3s4k$57v$1@highway.leidenuniv.nl>
>
> "Coping with Scoping":
>
> http://perl.plover.com/FAQs/Namespaces.html
Thanks so far. I think you're right that it is a scoping problem.
As soon as the site is reachable I will have a look at Coping with
Scoping.
Peter
------------------------------
Date: 3 Jan 2003 03:50:32 -0800
From: samirks@operamail.com (samir)
Subject: Removing xml string from header - CGI.pm
Message-Id: <23c07a0d.0301030350.55940f42@posting.google.com>
Hi,
I am trying to generate an HTML file using CGI.pm. From CGI.pm
start_html method is being invoked, which is adding
'<?xml version="1.0" encoding="utf-8"?>'
string at the top of html page.
Please let me know how to avoid this line while using start_html from
CGI.pm. Basically, this line is causing problem when the same html
file is opened in Excel.
Any help would be appreciated.
thanks and regards,
samir
------------------------------
Date: 03 Jan 2003 12:03:51 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Removing xml string from header - CGI.pm
Message-Id: <u93coaa194.fsf@wcl-l.bham.ac.uk>
samirks@operamail.com (samir) writes:
> I am trying to generate an HTML file using CGI.pm. From CGI.pm
> start_html method is being invoked, which is adding
>
> '<?xml version="1.0" encoding="utf-8"?>'
>
> string at the top of html page.
>
> Please let me know how to avoid this line while using start_html from
> CGI.pm.
I've never had cause to try it but the manual implies you use
-no_xhtml in the use statement.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 3 Jan 2003 09:08:08 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Removing xml string from header - CGI.pm
Message-Id: <av49d4$jn$1@slb9.atl.mindspring.net>
"samir" <samirks@operamail.com> wrote in message
news:23c07a0d.0301030350.55940f42@posting.google.com...
> Hi,
>
> I am trying to generate an HTML file using CGI.pm. From CGI.pm
> start_html method is being invoked, which is adding
>
> '<?xml version="1.0" encoding="utf-8"?>'
>
> string at the top of html page.
>
> Please let me know how to avoid this line while using start_html from
> CGI.pm. Basically, this line is causing problem when the same html
> file is opened in Excel.
You should use the -no_xhtml pragma to turn off the default behaviour of
CGI.pm, which behaviour has been in effect for a while.
When you're having trouble with something in CGI.pm not behaving as
expected, you might check the documentation at Lincoln Stein's web site.
#!perl -w
use strict;
use CGI qw(-no_xhtml :standard);
print header, start_html;
#
# more code here#
#
print end_html;
Cheers.
Bill Segraves
------------------------------
Date: 3 Jan 2003 01:01:35 -0800
From: stewart@webslave.dircon.co.uk (stew dean)
Subject: Re: Sorting hash tree from Xml::simple.
Message-Id: <2b68957a.0301030101.7293be0c@posting.google.com>
Benjamin Goldberg <goldbb2@earthlink.net> wrote in message news:<3E14CE87.F5912D27@earthlink.net>...
> stew dean wrote:
> > Tad McClellan wrote:
> > > stew dean wrote:
> > > > Let me start by saying I'm newish to the perl stuff
> > >
> > > You should check out the Posting Guidelines that are posted
> > > here weekly. You've already hurt your chances of getting
> > > help with future Perl problems.
> >
> > Bit of a catch 22 that - if you arnt a regular you wouldnt know. And
> > if you are a regular you would know more about perl that I do :) It's
> > what I call a 'beware of a leopard' problem - see 'the hitchhikers
> > guide of the galaxy' to see what I mean :) It's a bit like RTFM -
> > often with internet material it's 'what manual?' or the manual is so
> > badly written it's only of use to the original author.
>
> The posting guidelines are automatically posted here once a week.
>
> Unlike walking through a jungle with a leopard hunting you, while you
> search for the "beware of a leopard" sign, it's completely harmless for
> you to read the newsgroup without posting anything (aka lurking) for a
> week or two, with the intent of learning the proper etiquette for asking
> questions.
Oh the luxury of a week or two :) The reference I hope some got (its
about how some 'vital' stuff is often very hard to find and not
obvious to the very people it should be to). Not going to get into a
usability argument here.
Long lead times and multi month project times are what other people
do.
I appreciate the help but you must appreciate I would not ask if I had
the time to pour over lots of files and books to find the few nuggets
I need.
Stew Dean
------------------------------
Date: 03 Jan 2003 15:39:18 GMT
From: vek@station02.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: stdin binary or text ?
Message-Id: <slrnb1bbl6.ps.vek@station02.ohout.pharmapartners.nl>
On Thu, 19 Dec 2002 02:25:09 -0500,
Benjamin Goldberg <goldbb2@earthlink.net> wrote:
>cedric wrote:
>>
>> Hi !
>> I would like to know if in perl stdin is opened in binary or text
>> mode?
>
>In the absence of -Mopen=..., perl's stdin is opened in text mode.
>
>This means, if you're on dos/windows, any CRLF that's read from stdin in
>will appear in the string as just "\n".
>
>And if you're on the newest versions of RedHat (or something else which
>sets $ENV{LANG}), and if you're using perl5.8, then text mode means that
>stdin is UTF8.
>
The LANG environment variable should contain the text utf8 or similar
for this to take effect, shouldn't it?
Villy
------------------------------
Date: Fri, 03 Jan 2003 15:30:52 +0100
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: system command and $_ variable
Message-Id: <1679851.yHXZVln1kV@nyoga.dubu.de>
juha wrote:
> Benjamin Goldberg <goldbb2@earthlink.net> wrote in message
> news:<3E136CA5.70B49B42@earthlink.net>...
>> system(qw(ffmpeg -i), "/tmp/$_", qw(-b 1300 -s 352*288),
>> "/tmp/ready/$_")
>>
>
> This is close !! However, there is new line which make this no good.
> When I echo this command it gives me two separate lines:
>
> [root@testsrv videohuolto]# ./convertfile
>
> ffmpeg -i /home/TVtampere/LidlTre2.mpg
> -b 1300 -s 352*288 /home/intravideot/LidlTre2.mpg
>
> What I need to do to make keep those lines as one commnad line ?
Just chomp() your $_ before you use it. And this is independant from
Benjamin's code.
perldoc -f chomp
Ciao,
Harald
--
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>How do you say "mafia", in Italian ?
Sotto voce.
-- from alt.usage.english
------------------------------
Date: Fri, 03 Jan 2003 08:06:31 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: What is wrong in my SYSTEM commad
Message-Id: <bwbR9.23343$Ab.4254@nwrddc03.gnilink.net>
juha wrote:
[...]
> well yet. It print the system command to two separate line insted one
> line. Here is the command:
>
> system(qw(echo ffmpeg -i), "/tmp/$_", qw(-b 1300 -s 352*288),
> "/tmp/ready/$_");
>
> and the result it gives me:
> ffmpeg -i /tmp/testfile.mpg
> -b 1300 -s 352*288 /tmp/ready/testfile.mpg
>
> So after " /tmp/testfile.mpg " appears a new line. How I can keep all
> in the same line ???????
Without seeing more of your script or data it appears as if the text in the
variable $_ contains a linebreak at the end. Just don't put that line break
in there.
Or if that's a line read from a file then maybe you forgot to chomp that
line (details see perldoc -f chomp)?
jue
------------------------------
Date: Fri, 3 Jan 2003 14:19:46 +0530
From: "Kasp" <kasp@NO_SPAMepatra.com>
Subject: Re: What is wrong in my SYSTEM commad
Message-Id: <av3iuc$i9d$1@newsreader.mailgate.org>
> system(qw(echo ffmpeg -i), "/tmp/$_", qw(-b 1300 -s 352*288),
> "/tmp/ready/$_");
$_ contains a newline at end. chomp it like this:
chomp;
system(qw(echo ffmpeg -i), "/tmp/$_", qw(-b 1300 -s
352*288),"/tmp/ready/$_");
If you need a new line at the end of your command just change to :
chomp;
system(qw(echo ffmpeg -i), "/tmp/$_", qw(-b 1300 -s 352*288),"/tmp/ready/$_
\n");
--
Perl is designed to give you several ways to do anything, so
consider picking the most readable one.
-- Larry Wall in the perl man page
------------------------------
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 4337
***************************************