[22758] in Perl-Users-Digest
Perl-Users Digest, Issue: 4979 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 13 14:06:07 2003
Date: Tue, 13 May 2003 11:05:14 -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 Tue, 13 May 2003 Volume: 10 Number: 4979
Today's topics:
-T and DBI <tmac@trransport.com>
Re: -T and DBI <usenet@dwall.fastmail.fm>
Re: @Array - making it null <dont-reply@this.address>
Re: A perl parsing question... <barryk2@SPAM-KILLER.mts.net>
Re: accept() troubles Jens.Toerring@physik.fu-berlin.de
Re: Bloody Java Proselytisers!!! <p.lord@russet.org.uk>
Re: changing the date <member17678@dbforums.com>
Re: Convert array into hash element <nobull@mail.com>
Re: DBD Oracle - how to read results of stored procedur <revjack@revjack.net>
Re: egrep exclude (James E Keenan)
Re: egrep exclude <abigail@abigail.nl>
Re: High CPU usage and mem leak problem in a perl routi <abigail@abigail.nl>
Re: how to set INC globally <grazz@pobox.com>
How to Store and Print this Array? (Hunter)
Re: How to Store and Print this Array? <dover@nortelnetworks.com>
Re: MYSQL images <clemenr@tiger.wmin.ac.uk>
Re: Need help testing a gzip file for corruption (Bryan Castillo)
Re: Negating phrases <allanon@hotmail.com>
Re: Negating phrases <nobody@dev.null>
Re: Negating phrases <nobull@mail.com>
Re: novice programmer (Helgi Briem)
Re: novice programmer <josef.moellers@fujitsu-siemens.com>
Re: one liner in command line <graham.drabble@lineone.net>
removing spaces in a string (Kevin)
Re: removing spaces in a string <goedicke@goedsole.com>
Re: retrieve actuate report from the web (Bryan Castillo)
Re: Try to find a hash element but no luck (Sara)
Re: what's the scope of global variable in cgi ? <nobull@mail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 13 May 2003 09:32:11 -0700
From: "Tim McIntyre" <tmac@trransport.com>
Subject: -T and DBI
Message-Id: <pan.2003.02.13.17.28.51.168879@trransport.com>
It seems strange to me that I can write a program useing taint checks
and then insert data into a mysql table without untainting it.
Why is that??? What am I missing???
Thanks much,
Tim McIntyre
------------------------------
Date: Tue, 13 May 2003 16:54:57 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: -T and DBI
Message-Id: <Xns937A836371A0Fdkwwashere@216.168.3.30>
Tim McIntyre <tmac@trransport.com> wrote:
> It seems strange to me that I can write a program useing taint checks
> and then insert data into a mysql table without untainting it.
>
> Why is that??? What am I missing???
perlsec states that in taint mode "You may not use data derived from
outside your program to affect something else outside your program".
You're not really affecting the OS or the database software in any way,
you're just storing the data. Even if the data said "rm -rf /",
there's still no harm in storing that string in a database. If you
tried to pass that string to system() or something similar, *then* the
taint checks would be triggered.
That's my take on it, anyway. Corrections and additions are welcome.
--
David Wall
------------------------------
Date: Tue, 13 May 2003 09:55:24 -0700
From: Balaji Venkataraman <dont-reply@this.address>
Subject: Re: @Array - making it null
Message-Id: <Pine.GSO.4.44.0305130946500.10521-100000@leith>
> On Tue, 13 May 2003 03:14:07 GMT,
> Uri Guttman <uri@stemsystems.com> wrote:
>
>
> >>>>>> "BV" == Balaji Venkataraman <dont-reply@this.address> writes:
> >
> > BV> So now that the experts say that undef is not a good thing to do, I
> > BV> have a question.
> >
> > BV> I've see people do this to read the whole file in one fell swoop:
> >
> > BV> Code 1
> > BV> ------
> > BV> local $/ = undef;
> >
> >the undef is redundant. local $/ will set it to undef.
> >
Thanks everybody! That helps.
As an aside - I wonder how the prominent posters on this group (or any
other for that matter), use your real email addresses? Don't you get
spammed? I'm still repenting a couple of earlier posts to some
newsgroups! Any advice is welcome. Sorry for posting this
question here. Couldn't think of a better place.
Thanks!
--
Balaji Venkataraman
------------------------------
Date: Tue, 13 May 2003 08:37:59 -0500
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: A perl parsing question...
Message-Id: <MPG.192ab134623437fe9897c9@news.mts.net>
[This followup was posted to comp.lang.perl.misc]
In article <9c2a26b6.0305121120.7916ace3@posting.google.com>, Jim Carter
(carterave@yahoo.com) says...
> Hi all,
>
>
> I have an input file in which each line has two colons and some other
> text. I want to discard all the text after the second colon (including
> this second colon) in each line.
>
> -----------------------------
> The output should be:
>
> TESTKEY1.1: This is the Testone
> TESTKEY101: This is test numbertwo
> TESTKEY3: Is this test
> -----------------------------------
>
>
> I have the below script:
>
> ************************
>
> #! C:/perl/bin/perl
> @array = <DATA>;
> foreach (@array)
> {
> $_ =~ s/\w:\s+//g;
> print $_;
> }
>
> __DATA__
> TESTKEY1.1: This is the Testone: I am new to perl programming
> TESTKEY101: This is test numbertwo: The reg eps are a bit confusing.
> TESTKEY3: Is this test: Which is the good book for reg exps. This need
> a lot of practice.
>
> *****************************
>
>
> How can get my desired output?
>
> Thanks,
> Jim.
>
#!/usr/bin/perl -w
@array = <DATA>;
foreach $buffer (@array)
{
$buffer =~ m/^(.*?:.*?):.*$/;
$buffer = "$1\n";
print $buffer;
}
__DATA__
TESTKEY1.1: This is the Testone: I am new to perl programming
TESTKEY101: This is test numbertwo: The reg eps are a bit confusing.
TESTKEY3: Is this test: Which is the good book for reg exps. This need a
lot of practice.
--
---------
Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com
------------------------------
Date: 13 May 2003 14:15:19 GMT
From: Jens.Toerring@physik.fu-berlin.de
Subject: Re: accept() troubles
Message-Id: <b9quln$m426m$1@fu-berlin.de>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> I don't know what's going on, but you should realize that if serve()
> ever returns to the child, the child(!) will continue to run another
> copy of the accept() loop. I don't believe that is intentional, so
> put an exit() after serve().
Thank you, but unfortunately this can't be the problem because the
serve() function definitely has no chance at all of ever returning.
But, of course, adding an exit() is an good idea in case I made some
stupid mistakes...
Regards, Jens
--
_ _____ _____
| ||_ _||_ _| Jens.Toerring@physik.fu-berlin.de
_ | | | | | |
| |_| | | | | | http://www.physik.fu-berlin.de/~toerring
\___/ens|_|homs|_|oerring
------------------------------
Date: 13 May 2003 14:23:56 +0100
From: Phillip Lord <p.lord@russet.org.uk>
Subject: Re: Bloody Java Proselytisers!!!
Message-Id: <vfissf3rpv.fsf@rpc71.cs.man.ac.uk>
>>>>> "Charlton" == Charlton Wilbur <cwilbur@mithril.chromatico.net> writes:
Charlton> Phillip Lord <p.lord@russet.org.uk> writes:
>> Any language needs to steer a course between expressivity, and
>> simplicity. [...] Now, of course, if you make a languages overly
>> simple, then it's hell to use, and the programmer ends up doing
>> things in an extremely complex way.
Charlton> That's the crux of the problem.
>> Java does force the programmer to prefer one paradigm (object
>> orientation) over another. But, nowadays, OO is well known,
>> fairly well understood. A good programmer would, I would argue,
>> not feel overly limited by this (in the way that they would by
>> lack of recursion). And it makes it easier for less good
>> programmers, who can operate with one thing that they are
>> familiar with.
Charlton> Exactly.
Charlton> The issue down at the bottom of it all is that this
Charlton> tradeoff -- expressivity versus simplicity -- comes out
Charlton> differently at different skill levels. The toolset that's
Charlton> appropriate for an expert is not appropriate for a
Charlton> beginner, and vice versa. But as an expert (or at least
Charlton> an aspiring expert), I want the richest and most diverse
Charlton> set of tools I can have: I don't want to be limited to OO,
Charlton> or indeed to any approach. This is one thing that Perl
Charlton> gets right -- but then, I don't think Perl is a good
Charlton> language for the mediocre to average programmer, and I'm
Charlton> still finding corners of the language that I haven't yet
Charlton> explored.
I would agree with most of this, but again, I think that "skill
levels" is not the only criterion. The nature of my work means that I
have to use different languages. And the complexity of what I am
trying to do comes out not in the way that the code is written but the
functionality that the code is trying to provide. For me, I want the
simplest language that I can have, while still having the expressivity
I need. This makes the language easier to learn, and code written in
it easier to maintain.
I would not agree, therefore, that perl is good for experts, and Java
good for beginners. Perl is good for somethings, and Java for
others. If I have a choice I will tend toward using Java, because the
simplicity of the language means that I can cope on the complexities
of the domain. I will use perl though, when its the best thing. For me
this is the result of one of two things, which is a) there is a lot of
text processing to be done, and b) where there is a library in perl,
that I can not get in Java.
Phil
------------------------------
Date: Tue, 13 May 2003 16:58:12 +0000
From: Mario542 <member17678@dbforums.com>
Subject: Re: changing the date
Message-Id: <2874007.1052845092@dbforums.com>
Originally posted by Steffen Beyer
> "Mario542" wrote:
>
> > Steffen,
> > after I change the date using
> > use Date::Calc qw(:all);
> >
> > my(@date) = (2003,4,17);
> >
> > my(@tomorrow) = Add_Delta_Days(@date, +1);
> > it looks like (2003 4 18) which works fine. Do you know if there
> is a
> > way to add periods to the date like 2003.4.18 so that it can be
> used in
> > a database query?? Thanks for all the help
>
> You should definitely read a book about Perl programming,
> or browse the Perl documentation that comes with your Perl
> installation. The payoff will make it worth your while!
> Start with "perldoc perl" for an index of available Perl
> manual pages.
>
> You want string concatenation, string interpolation, sprintf(),
> or join():
> (Remember the Perl motto: "There is more than one way to do it")
>
> $string = $date[0].'.'.$date[1].'.'.$date[2];
> $string = "$date[0].$date[1].$date[2]";
> $string = sprintf("%d.%d.%d", @date);
> $string = sprintf("%d.%02d.%02d", @date); # always 2 digits for month
> and day (zero-padded)
> $string = join('.', @date);
>
> Good luck!
> Steffen
Steffen,
thanks for the advise and for all your help on this script. This script
finally does exactly what I need it to do.
Thanks,
mario-
--
Posted via http://dbforums.com
------------------------------
Date: 13 May 2003 17:52:51 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Convert array into hash element
Message-Id: <u9k7culrfg.fsf@wcl-l.bham.ac.uk>
Lechu <kopetnik@s-pam-nie.yahoo.com> writes:
> Given is an array with unknown number of elements, ie:
> @a = ('a','b','c','d','e');
>
> I want to convert it into hash like:
> $h={};
> $h->{'a'}{'b'}{'c'}{'d'}{'e'} = 1
I find myself doing this a lot. I usually use:
my $v = \$h;
$v=\$$v->{$_} for @q;
$$v=1;
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 13 May 2003 14:45:48 GMT
From: revjack <revjack@revjack.net>
Subject: Re: DBD Oracle - how to read results of stored procedure?
Message-Id: <b9r0es$kcr$3@news1.radix.net>
Keywords: Hexapodia as the key insight
Andy Hassall <andy@andyh.co.uk> wrote:
: On 12 May 2003 22:24:27 GMT, revjack <revjack@revjack.net> wrote:
:>The following script returns the results of a SELECT
:>statement correctly. How would I modify it to perform the
:>two SQL*PLUS steps above?
: It looks like that procedure will be outputting through dbms_output, if it
: produces any output; it's not returning a result set in any way (at least not
: if executed as per the instructions above).
Yes, you are correct; turning the output on certainly helps
in getting it to output!
: while (my $line = $dbh->func('dbms_output_get')) {
: print "$line\n";
: }
func('dbms_output_get') works perfectly, thank you. I'm off
to read more about func(). Do you have a PayPal account? Can
I buy you a beer or three? :)
Thanks Andy
--
___________________
revjack@revjack.net
------------------------------
Date: 13 May 2003 07:48:47 -0700
From: jkeen@concentric.net (James E Keenan)
Subject: Re: egrep exclude
Message-Id: <b955da04.0305130648.555df936@posting.google.com>
Abigail <abigail@abigail.nl> wrote in message news:<slrnbbvvg8.f7.abigail@alexandra.abigail.nl>...
> James E Keenan (jkeen@concentric.net) wrote on MMMDXLI September MCMXCIII
> in <URL:news:b955da04.0305120829.1885e1fd@posting.google.com>:
>
> ^^ Sitting at a Windows terminal, I don't have the opportunity to test
> ^^ out your shell command or look up the man pages. So I can't write and
> ^^ test the Perl script that would be the answer to your needs.
>
> That seems a poor reason to me to not shell out.
>
>
> Abigail
When reply to a message on this newsgroup, I try to thoroughly test my
code before posting. To do so in this case I would have needed access
to Linux/Unix as well as Windows -- which I normally do. However, I'm
not at my regular terminal; I currently only have access to Windows.
Hence, I did not attempt to write a complete Perl script that would
have done what the OP wanted, as I had no way to run the OP's shell
commands, against which to test the Perl script. So I just made
suggestions as to the types of Perl features OP would use if he wished
to write entirely in Perl. This had nothing to do with the
merits/demerits of shelling out.
The OP indicated he was a novice, or at least a novice to Perl. It
seems reasonable to suggest to a novice that he at least consider
writing a script entirely in Perl rather than a mixture of shell and
Perl.
------------------------------
Date: 13 May 2003 15:10:33 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: egrep exclude
Message-Id: <slrnbc22n9.2dr.abigail@alexandra.abigail.nl>
James E Keenan (jkeen@concentric.net) wrote on MMMDXLII September
MCMXCIII in <URL:news:b955da04.0305130648.555df936@posting.google.com>:
:)
:) The OP indicated he was a novice, or at least a novice to Perl. It
:) seems reasonable to suggest to a novice that he at least consider
:) writing a script entirely in Perl rather than a mixture of shell and
:) Perl.
Why? If (s)he is more familiar with the shell? Perl is a *glue*
language, and Larry has always said it's ok to talk baby-Perl.
Being able to graduale getting used to Perl seems a merit to me.
Abigail
--
package Z;use overload'""'=>sub{$b++?Hacker:Another};
sub TIESCALAR{bless\my$y=>Z}sub FETCH{$a++?Perl:Just}
$,=$";my$x=tie+my$y=>Z;print$y,$x,$y,$x,"\n";#Abigail
------------------------------
Date: 13 May 2003 13:50:21 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: High CPU usage and mem leak problem in a perl routine
Message-Id: <slrnbc1u0s.2dr.abigail@alexandra.abigail.nl>
Tony (anthony@no_spam.movielink.net.au) wrote on MMMDXLII September
MCMXCIII in <URL:news:pan.2003.05.13.08.20.15.969025@no_spam.movielink.net.au>:
()
()
() Hi Guys,
()
() I have a specific memory usage problem with high CPU
() usage to.
()
() The following construct:
()
() my $file = "/some/path/file";
()
() START: open (FILE, $file) or die "Could not open: $file $!\n";
() while (my $lines = <FILE>) {
() chomp ($lines);
() ...processing the data...
() {...more processing...
() fork_sub($some_data);
() }
() }
() goto START;
()
() sub fork_sub
() {
() ...processing data...
() ...forking...
() }
()
() All works perfectly except for a CPU usage of 98%
() and the memory usage climbing to 100% within an hour or so.
()
() I think the problem lies with opening the file handle in the
() loop as shown. Every time the file has been scanned, the program
() will go to reopen the file handle. (When perl opens an open
() handle it closes the open one first).
()
() Is it not better to read the file in to a @list or @array and
() then read it from there?
()
() The program needs to continuesly scan the input file.
And that's what it is doing. What is the problem? You want to continuously
do something, the CPU usuage goes to almost 100%, and you're still
complaining.
() Any suggestions on this little problem?
Little? What exactly are you doing? What's the purpose of the program?
After all, if you keep reading in the file, something else is probably
modifying it. But you aren't locking. Whatever the problem is you are
trying to solve, your solution seems very strange to me.
() Will the memory and CPU usage problem persist if all
() is read into an @array?
About the memory, I cannot judge, you give too little of your program.
But reading it in in an array doesn't seem logical to me. Then you
won't notice if the file gets modified.
Abigail
--
perl -we'$;=$";$;{Just=>another=>Perl=>Hacker=>}=$/;print%;'
------------------------------
Date: Tue, 13 May 2003 15:28:28 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: how to set INC globally
Message-Id: <wa8wa.9231$kH.2174945@twister.nyc.rr.com>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> spanda <spanda@cisco.com> wrote in comp.lang.perl.misc:
>>
>> How can we set path in @INC, so that it will be available globally.
>>
>> I use
>> BEGIN {
>> push ($INC, $PATH);
>> }
>
> Better written as
>
> use lib $PATH;
>
> That works without BEGIN because "use" already happens at compile time.
>
>> But this is only at perl script level.
>
> perldoc perlrun, look for the environment variable PERL5LIB.
The various options are also listed in the FAQ
$ perldoc -q 'include path'
And to add directories to @INC 'permanently', OP would need to rebuild
perl with:
$ sh Configure -Dotherlibdirs=$PATH -de
--
Steve
------------------------------
Date: 13 May 2003 07:26:33 -0700
From: dave_h4@yahoo.com (Hunter)
Subject: How to Store and Print this Array?
Message-Id: <27ad91d2.0305130626.4325f4be@posting.google.com>
Hi - I need to query a database and print the rows returned. I would
like to count the number of people from each country. Of course - I
only want to query and print the country's that are populated - not
the entire list of countries.
My query is as such:
"select count(country), country from customers GROUP BY country"
returns:
count | country
-------+---------
1 | AE
1 | DE
2 | DZ
2 | FR
3 | ZA
5 | US
84 | CA
(7 rows)
HOW can I store this query into a hash so I can print it to the
browser using cgi ?
Thank you!
dh
------------------------------
Date: Tue, 13 May 2003 10:06:13 -0500
From: "Bob Dover" <dover@nortelnetworks.com>
Subject: Re: How to Store and Print this Array?
Message-Id: <b9r1k7$h08$1@zcars0v6.ca.nortel.com>
"Hunter" wrote...
> Hi - I need to query a database and print the rows returned.
Homework Alert -- How's the weather up in Oregon, btw?
------------------------------
Date: 13 May 2003 14:56:50 +0100
From: Ross Clement <clemenr@tiger.wmin.ac.uk>
Subject: Re: MYSQL images
Message-Id: <3ec0f9a2@isls-news.wmin.ac.uk>
Music Man <musicman@hotmail.com> wrote:
: I am aware this is not the right group for my question, but there is no
: mysql related group, so since I need this from a Perl language I am
: asking here.
: Does anyone have an experience with Mysql & Perl regarding Web images. I
: need to make a script, which will pull pics (I know mysql has such field
: type) from a database, and put it out on a web page using CGI library.
I've done this, but only with Java/JDBC. It's a doddle (in Java at least).
You just need to write the image as a BLOB (Binary Large Object).
There's code for doing this with a microsoft word document at
http://tlowery.hypermart.net/perl_dbi_dbd_faq.html#ReadWriteBLOB
Cheers,
Ross-c
------------------------------
Date: 13 May 2003 09:09:11 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Need help testing a gzip file for corruption
Message-Id: <1bff1830.0305130809.6359c357@posting.google.com>
Henry <urael@zrgebcbyvf.arg.nh> wrote in message news:<urael-68C35A.14253813052003@nswpull.telstra.net>...
> In article <a4q0cv4ftkebe848ntbd728lo885p1v2nr@4ax.com>,
> ">>--Archer--->" <not@home.net> wrote:
>
> > I'm using a script to download about 50 .gz archives and then expand
> > the contents. The problem is that 2-3 of the larger files are usually
> > corrupted after the download, which causes the script to fail.
> >
> > How can I test the archives validity so that I can then retry the
> > download?
>
> Compare file lengths. This will let you know if any truncation has
> occured.
>
> If you have access to the other box, you could generate CRC checksums on
> the remote machine, then transfer them along with the files and generate
> another batch of checksums on the local machine. If the two sets of
> checksums don't match, something went wrong. The MD5 module, et al, can
> be used to do this.
>
A gzipped file already has a CRC32 checksum in its trailer along with
the uncompressed size of the compressed data. If you are using an
external gunzip program it should already tell you if it is corrupted
with its return code.
> Henry.
------------------------------
Date: Tue, 13 May 2003 14:01:24 +0100
From: "Allanon" <allanon@hotmail.com>
Subject: Re: Negating phrases
Message-Id: <b9qqb5$mn2@newton.cc.rl.ac.uk>
"Thomas Haselberger" <thomas.haselberger@ucpmorgen.com> wrote in message
news:uof27rs9e.fsf@ucpmorgen.com...
> "Allanon" <allanon@hotmail.com> writes:
>
> > Hi
> >
> > If I have code like this:
> >
> > @array = ("Name is Billy","Name is Fred","Name is Freda","Name is
Steve");
> >
> > foreach(@array)
> > {
> > print "$_\n" if /Name is [^Billy|^Fred]/;
> ^^^^^^^^^^^^^^
> This is a char class, matching one of the given chars.
>
> [^B] means match a char that is not B
>
> btw, I don't know what the second occurencs of ^ does.
>
> > }
> >
> > What I want it to do is print out all lines, except those where the name
is
> > Billy or Fred. The above doesn't work, as it doesn't print out the Freda
> > line.
>
> negative lookahead could do the job:
>
> print "$_\n" if /Name is (?!Billy|Freda)/;
Thanks.. that works with a slight modification.. ie: I originally wrote
Fred, not Freda, as the second exclusion.. Fred excludes both Fred & Freda,
so I'd need to write the line as:
print "$_\n" if /Name is (?!Billy$|Freda$)/;
to make sure I get the desired results for any names that might be there.
Allanon
------------------------------
Date: Tue, 13 May 2003 13:41:27 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: Negating phrases
Message-Id: <3EC0F5A2.3090106@dev.null>
Allanon wrote:
> Hi
>
> If I have code like this:
>
> @array = ("Name is Billy","Name is Fred","Name is Freda","Name is Steve");
>
> foreach(@array)
> {
> print "$_\n" if /Name is [^Billy|^Fred]/;
> }
>
> What I want it to do is print out all lines, except those where the name is
> Billy or Fred. The above doesn't work, as it doesn't print out the Freda
> line.
>
> Could you tell me what I'm doing wrong?
>
> Thanks
>
> Allanon
>
>
Wouldn't it be easier to use grep?
@array = ("Name is Billy","Name is Fred","Name is Freda","Name is Steve");
print join "\n", grep not (/Billy$/ or /Fred$/), @array;
------------------------------
Date: 13 May 2003 17:58:13 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Negating phrases
Message-Id: <u9el32lr6i.fsf@wcl-l.bham.ac.uk>
"Allanon" <allanon@hotmail.com> writes:
> Could you tell me what I'm doing wrong?
Starting a new thead with question substancially the same as was
discussed in the thread "dont match this pattern" less than a week
ago.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 13 May 2003 13:11:47 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: novice programmer
Message-Id: <3ec0edb5.2844911907@news.cis.dfn.de>
On Tue, 13 May 2003 11:51:30 GMT, "Anthony"
<anthony_r_au@yahoo.com.au> wrote:
>I am newie to perl, I need help creating a script . My objective is to
>rename a file named ABCDEFF.TXT to
> nnddmmyh.hmm
rename 'ABCDEFF.TXT', 'nnddmmyh.hmm'
or die cannot rename ABCDEFF.TXT nnddmmyh.hmm:$!\n";
>nn= number 0-9
>dd= day
>mm= month
>y=year
>h.h=hour
>mm= minutes
Oh, you wanted variables in there.
Have a look at the core module Date::Calc.
>The application runs under dos
What? Can you get Perl to run under DOS?
>without long file names.
Does this still exist? The mind boggles.
>So the formating as you can see is 8.3 format.......
I can't imagine the platform where you are still
restricted to this. Are you telling the truth?
>Where do i start , what commands to i use.
perldoc Date::Calc
perldoc rename
perldoc die
perldoc perlvar (specifically $!)
>will someone help me start my script, or give an eample...
--
Regards, Helgi Briem
helgi DOT briem AT decode DOT is
------------------------------
Date: Tue, 13 May 2003 15:33:35 +0200
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: novice programmer
Message-Id: <3EC0F42F.90BFD0E2@fujitsu-siemens.com>
Anthony wrote:
> =
> hi
> =
> I am newie to perl, I need help creating a script . My objective is to
> rename a file named ABCDEFF.TXT to
> nnddmmyh.hmm
> =
> nn=3D number 0-9
> dd=3D day
> mm=3D month
> y=3Dyear
> h.h=3Dhour
> mm=3D minutes
> =
> The application runs under dos without long file names. So the formatin=
g as
> you can see is 8.3 format....... Where do i start , what commands to i =
use.
> will someone help me start my script, or give an eample...
You need to look at the localtime function:
perldoc -f localtime
e.g.
(undef,$min,$hour,$mday,$mon,$year,undef, undef, undef) =3D
localtime(time);
The biggest problem will be in determining the value for nn. The
following will NOT work (i.e. it will fail when you depend on it, not
when you test it):
$nn =3D 0;
$base =3D "whatever";
while (1) {
$pathname =3D sprintf("%02d", $nn) . $base;
last unless -e $pathname;
$n++;
}
rename "$ABCDEF.TXT", $pathname;
-- =
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Tue, 13 May 2003 16:33:59 +0100
From: Graham Drabble <graham.drabble@lineone.net>
Subject: Re: one liner in command line
Message-Id: <Xns937AA885FA8DFgrahamdrabblelineone@ID-77355.user.dfncis.de>
On 04 May 2003 Michael Eric Battle <you.gotta.be@kidding.com> wrote
in news:3EB46B2F.6780FC05@kidding.com:
> Graham Drabble wrote:
>> I think this is a Windows/Unix thing.
>
> Maybe.
> Maybe you're better off with the single quotes.
>
> The double quotes interpolate (at the shell level)
> for shell escape characters like \ and $ so you have
> to do:
I don't think that the windows command line is that clever. I found
this in the ActiveState docs
====
Why doesn't 'perl -e' work?
It does - it's just that some command shells (for example
COMMAND.COM, CMD.EXE and 4DOS) don't accept single quotes wrapped
around command arguments.
The safest way to do perl one-liners is to wrap the parameters within
"" (double-quotes) the use q() and qq() inside the parameters. q()
and qq() with put whatever is inside them between single-quotes or
double-quotes, respectively.
For example:
perl -e "use LWP::Simple; while(@c = head <>) { $c = join qq(\n
\t), @c; print qq(Header info:\n\t$c\n); }"
(this was all one line)
Run this from the command line and type in the URL to your favorite
website, like http://www.perl.com/...
The perlwin32 and perlrun POD pages have more information on using
the command line.
====
--
Graham Drabble
If you're interested in what goes on in other groups or want to find
an interesting group to read then check news.groups.reviews for what
others have to say or contribute a review for others to read.
------------------------------
Date: 13 May 2003 10:32:11 -0700
From: kgiles@optonline.net (Kevin)
Subject: removing spaces in a string
Message-Id: <337213e2.0305130932.730d10ac@posting.google.com>
how do you remove spaces in a string varaible?
thanks
kg
------------------------------
Date: Tue, 13 May 2003 17:43:03 GMT
From: William Goedicke <goedicke@goedsole.com>
Subject: Re: removing spaces in a string
Message-Id: <m3of26eo9u.fsf@mail.goedsole.com>
Dear Kevin -
kgiles@optonline.net (Kevin) writes:
> how do you remove spaces in a string varaible?
$string =~ s/ //g;
Yours - Billy
============================================================
William Goedicke goedicke@goedsole.com
http://www.goedsole.com:8080
============================================================
Lest we forget:
Common things are common. In fact, very unusual examples
of common things are much more common than rare things.
- William S. Craig M.D.
------------------------------
Date: 13 May 2003 10:03:46 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: retrieve actuate report from the web
Message-Id: <1bff1830.0305130903.73ff7cef@posting.google.com>
prokurator@aol.com (Samara) wrote in message news:<d45e82a2.0305121226.4419a854@posting.google.com>...
> I know it but for some reason I am getting all the time response:
> 'Can't connect to www.site_name.com:443 (Timeout)'
>
> Thanks.
Are you trying to go to port 443 on your original request?
Perhaps you are being redirected from http to https and you don't have
SSL setup for LWP?
I also noticed that you were saying you had to enter username and
password, do you know what type of authentication is being used,
challenge-response, or the server is using session data (in which case
you should have a cookie jar)?
------------------------------
Date: 13 May 2003 07:04:57 -0700
From: genericax@hotmail.com (Sara)
Subject: Re: Try to find a hash element but no luck
Message-Id: <776e0325.0305130604.6abac109@posting.google.com>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<b9o6di$qm6$1@mamenchi.zrz.TU-Berlin.DE>...
> Sara <genericax@hotmail.com> wrote in comp.lang.perl.misc:
> > "David G" <DavidG997@yahoo.com> wrote in message
> > news:<b9m3i8$kq6ut$1@ID-82947.news.dfncis.de>...
> > > I have a defined hash loaded as follows:
> > >
> > .
> > .
> >
> > >
> > > if (exists $database{$inphost})
> > > {
> > > print "\nfound hash element\n";
> > > }
> > > else
> > > {
> > > print "\nHash element not found\n";
> > > }
> > > Will using the large C and not the small c casue this ?
> > > If not how to do I find it ?
> > >
> > > TIA
> >
> >
> > I always use
> >
> > if defined $h{element}
> >
> > Which seem to work as I'd expect in every case. When I first learned
> > Perl I used "exists" but abandoned it when I discovered that it seemed
> > to be a subset of "defined".
> >
> > Why does "exists" exist?
>
> It distinguishes the case that a key exists in a hash, but its value
> happens to be undefined. This may look like a marginal difference,
> but it is essential in some cases.
>
> Exists can also be applied to arrays and even subroutines to make
> similar subtle distinctions. "perldoc -f exists" for the full story,
> but you knew that...
>
> Anno
Thanks Anno et all- I understand the distinction now.
Cheers,
Gx
------------------------------
Date: 13 May 2003 17:47:44 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: what's the scope of global variable in cgi ?
Message-Id: <u9r872lrnz.fsf@wcl-l.bham.ac.uk>
"j" <perseus_medusa@hotmail.com> writes:
> i am changing a run alone perl script to a module which consist of many
> global variable. I am going to use that module in cgi. So I want to ask will
> the module's global variable be shared by all cgi perl script using it ?
I shall assume that by "module's global variable" you mean "module's
package variables and file-scoped lexical variables".
Do not rely on them being shared.
Do not rely on them being not shared.
Under CGI variables will not be shared unless they are tied to some
sort of persistant resource because each CGI script runs as a
standalone process at the OS level. This, really, has nothing to do
with Perl.
However somone may later want to run your Perl CGI scripts under
mod_perl rather than CGI. Then your module's global variables would
be shared by those scripts that happen to run in the same server
thread.
Each server thread is only servicing a single request at a time so the
variables will never be shared by more than one request at the same
time.
You can take advantage of the variables sometimes being shared (by
using them as caches) so long as you don't rely on them always being
shared.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
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 4979
***************************************