[29866] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1109 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 12 21:09:45 2007

Date: Wed, 12 Dec 2007 18:09:10 -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           Wed, 12 Dec 2007     Volume: 11 Number: 1109

Today's topics:
    Re: (1)[0] ok but not 1[0] <sensorflo@gmail.com>
    Re: (1)[0] ok but not 1[0] <ben@morrow.me.uk>
    Re: (1)[0] ok but not 1[0] <joost@zeekat.nl>
    Re: (1)[0] ok but not 1[0] <nospam-abuse@ilyaz.org>
        announcing a new performance monitoring tool for linux <Mark.Seger@hp.com>
    Re: auto/Tk/getEncoding.al file is missing <ben@morrow.me.uk>
    Re: Get values from hash "in order" <wheeledBobNOSPAM@yahoo.com>
    Re: Get values from hash "in order" <joost@zeekat.nl>
    Re: Get values from hash "in order" <jurgenex@hotmail.com>
    Re: How can I name my scalar with a for loop? vorticitywolfe@gmail.com
    Re: How can I name my scalar with a for loop? <jurgenex@hotmail.com>
    Re: How can I name my scalar with a for loop? <m@rtij.nl.invlalid>
    Re: How can I name my scalar with a for loop? <john@castleamber.com>
    Re: How can I name my scalar with a for loop? (Randal L. Schwartz)
    Re: How can I name my scalar with a for loop? (Darren Dunham)
        Newbie help with telephone number and date formatting <some@body.com>
    Re: Newbie help with telephone number and date formatti <joost@zeekat.nl>
    Re: Newbie help with telephone number and date formatti <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: split is not convinient <jurgenex@hotmail.com>
    Re: split is not convinient <ben@morrow.me.uk>
    Re: split is not convinient <joost@zeekat.nl>
    Re: split is not convinient <joost@zeekat.nl>
    Re: split is not convinient <Mark.Seger@hp.com>
        Using the DBI to connect to an Oracle server w/o connec <google@hoodfamily.org>
    Re: Using the DBI to connect to an Oracle server w/o co <ben@morrow.me.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 12 Dec 2007 13:38:24 -0800 (PST)
From: Florian Kaufmann <sensorflo@gmail.com>
Subject: Re: (1)[0] ok but not 1[0]
Message-Id: <7fbc6e35-b0b4-4081-9cbd-3fee9df86487@v4g2000hsf.googlegroups.com>

> precedence".  IMO, it is an indication of the sad state of affair with
> Perl documentation that there is no place in perl docs which lists all
> of them...

Thats what I think too, although I wouldn't go as far as to label it
sad. I would like to have a book for Perl what the book "The C++
Programming Language" is for C++. Something very clear, very concise,
clearly naming things and give things clear semantics. "Programming
Perl" is a good book, but in my opinion by far not as concise as "The C
++ Programming Language". To be fair I am a Perl novice, and it might
be to early to make such a statement.

I am writing a documentation for Perl for myself. I hope it turns out
more concise, at least in my view, as the documentation about Perl I
have currently in my hands. I am writing it to learn Perl, to order my
thoughts, my understanding of Perl. It has a lot of positive side
effects though
- I learn Perl pretty well
- I learn LaTeX a bit (i decided to write the document in latex)
- I learn how to efficiently edit LaTex files in Emacs
- I learn more about meta syntax notations. I am using an own syntax
notation which I created on this occasion (also to describe bash
scripts), since I find EBNF and the like quite cumbersome. It's more
for the fun of it, to have something I personally like better, not to
have something which is better by objective means.

Flo


------------------------------

Date: Wed, 12 Dec 2007 22:37:51 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: (1)[0] ok but not 1[0]
Message-Id: <ve4635-53n1.ln1@osiris.mauzo.dyndns.org>


Quoth Michele Dondi <bik.mido@tiscalinet.it>:
> On Wed, 12 Dec 2007 19:50:08 +0000 (UTC), Ilya Zakharevich
> <nospam-abuse@ilyaz.org> wrote:
> 
> >So there ARE several situations where parentheses mean more than "just
> >precedence".  IMO, it is an indication of the sad state of affair with
> >Perl documentation that there is no place in perl docs which lists all
> >of them...
> 
> Anyway, while the OP is confused by the fact e.g. 3[0] doesn't do what
> he thinks it should, the current syntax for the wanted semantics seems
> intuitive and dwimmy to me. I, for one, would find 3[0] to be
> syntactically valid and semantically valid, to imply that 3 is an
> autoboxed object (which in Perl 5 generally isn't unless using the
> autobox module) and doing the role of an array.

This isn't possible within the syntax and semantics of Perl 5, as you'd
lose the distinction between $ary[0] and @ary[0], which is vital to get
the proper RHS context in assignments.

> Perhaps this would have some sense if the semantics were that
> [0..2](0),

Huh? Perl never uses () for subscripting... did you mean (0..2)[0] ?
Still doesn't make a lot of sense...

> but then it
> would be very inconsistent with $n[0] being the first element of @n.
> If sigils were invariant as they are in Perl 6, then this
> inconsistency would not exist, but there wouldn't be much need to give
> 3[0] a meaning, either.

IIUC 3[0] is valid Perl 6, and means 3.[0], which may or may not make
sense depending on what object '3' evaluates to... but it's possible I'm
wrong, as I haven't tried using Perl 6 in anger yet.

Ben



------------------------------

Date: 12 Dec 2007 22:56:36 GMT
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: (1)[0] ok but not 1[0]
Message-Id: <47606724$0$16792$e4fe514c@dreader27.news.xs4all.nl>

On Wed, 12 Dec 2007 13:38:24 -0800, Florian Kaufmann wrote:

 [...]

> I would like to have a book for Perl what the book "The C++
> Programming Language" is for C++. Something very clear, very concise,
> clearly naming things and give things clear semantics. "Programming
> Perl" is a good book, but in my opinion by far not as concise as "The C
> ++ Programming Language". To be fair I am a Perl novice, and it might be
> to early to make such a statement.

Well, I'm not much of a C++ programmer, but I've read the Soustrup book, 
and you're right that "Programming perl" isn't as concise (TCPPPL is very 
terse, and it's got about the same number of pages as PP with a much 
smaller font). But IMO, the PP book is much easier to read, understand, 
and useful to get a grip on the language even if it leaves some of the 
details unspecified. I wouldn't recommend someone'd try to learn C++ from 
TCPPPL, but I do recomment PP for perl newbies.

On the other hand, a really *complete* reference book for perl may fill a 
need.

Currently though, I would have to say that the best way to really lean 
perl is to read the PP book (which is IMO the best book to learn perl), 
read the man pages and write a lot of code/experiment to find out the 
details you're missing. PP gives you a very good idea of the mind-set of 
the perl, plus a good overview of all that's in it, but it's not a 
complete reference manual for the language and in some places perl's man 
pages are more complete and/or up to date than PP, though even the man 
pages fall short of being complete.

> I am writing a documentation for Perl for myself. I hope it turns out
> more concise, at least in my view, as the documentation about Perl I
> have currently in my hands. I am writing it to learn Perl, to order my
> thoughts, my understanding of Perl. It has a lot of positive side
> effects though
> - I learn Perl pretty well
> - I learn LaTeX a bit (i decided to write the document in latex) - I
> learn how to efficiently edit LaTex files in Emacs - I learn more about
> meta syntax notations. I am using an own syntax notation which I created
> on this occasion (also to describe bash scripts), since I find EBNF and
> the like quite cumbersome. It's more for the fun of it, to have
> something I personally like better, not to have something which is
> better by objective means.

What are your plans for this documentation? I'm sure people are 
interested.

Cheers,
Joost.


------------------------------

Date: Thu, 13 Dec 2007 01:33:30 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: (1)[0] ok but not 1[0]
Message-Id: <fjq25a$avk$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Florian Kaufmann 
<sensorflo@gmail.com>], who wrote in article <7fbc6e35-b0b4-4081-9cbd-3fee9df86487@v4g2000hsf.googlegroups.com>:
> I am writing a documentation for Perl for myself. I hope it turns out
> more concise, at least in my view, as the documentation about Perl I
> have currently in my hands. I am writing it to learn Perl, to order my
> thoughts, my understanding of Perl. It has a lot of positive side
> effects though
> - I learn Perl pretty well
> - I learn LaTeX a bit (i decided to write the document in latex)

IMO LaTeX is the most unsuitable tool for source code of the docs.  As
the minimum, it should be convertable to 1 man doc (for easy
grepping), and/or 1-doc or multi-doc HTML.

If I were on your place, I would look at an extension to POD which can
easily be dumbed down to POD, AND can be translated to LaTeX.
E.g., something like Y<for POD|for LaTeX> comes to mind - in the RARE
cases when something cannot be deduced from normal POD markup...

Hope this helps,
Ilya


------------------------------

Date: Wed, 12 Dec 2007 19:40:25 -0500
From: Mark Seger <Mark.Seger@hp.com>
Subject: announcing a new performance monitoring tool for linux
Message-Id: <fjpv1u$l3s$1@usenet01.boi.hp.com>

I don't know if anyone on this list is interested or not, but since it's 
  written in perl I thought perhaps someone might be.  Collectl, 
available at http://collectl.sourceforge.net/ is a performance 
monitoring tool I wrote about 4 years ago and have since released as 
Open Source this past summer.

It basically replaces the functionality of virtually all the existing 
'stat' utilities (eg vmstat, nfsstat, memstat, iostat, etc), sar and 
then some.  It even includes statistics for Infiniband and Lustre file 
systems.  Like many tools collectl can run interactively or log data to 
a rolling set of files and later play them back, but rather than have to 
  have a bunch of windows open each running a different tool, collectl 
does it all and reports its output in several different but consistent 
formats.  One format, which I call 'plot format', is actually space 
separated data that can be consumed by gnuplot or even read by excel.
Another format can be consumed by rrdtool if you're of that persuasion.

It can even run at subsecond monitoring intervals and if you think 
that's not important consider that most linux kernels do NOT correctly 
report network statistics if monitored once a second but rather you need 
to monitor at 0.9765 seconds (see the website for a detailed explanation).

The best thing is it uses less than 0.1% cpu when collecting samples 
every 10 seconds as well as process and slab statistics every 60 seconds.

Anyhow, if you're a linux person take it for a spin.

-mark


------------------------------

Date: Wed, 12 Dec 2007 21:51:22 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: auto/Tk/getEncoding.al file is missing
Message-Id: <qn1635-etm1.ln1@osiris.mauzo.dyndns.org>


Quoth mariakvelasco@gmail.com:
> Hello everyone,
> 
> We installed perl-Tk-804.026 on a Solaris 10 machine and everything
> seem to have been installed properly.  We were then able to build our
> executable on the same Solaris 10 machine using perl2exe with no
> problem it seems; however, when we try to run the actual exe on the
> same machine.  We got some errors like below:
> 
> PLEASE SEE THE PERL2EXE USER MANUAL UNDER "Can't locate somemodule.pm
> in @INC"

Have you done so?

> FOR AN EXPLANATION OF THE FOLLOWING MESSAGE:
> Can't locate auto/Tk/getEncoding.al in @INC (@INC contains:
> PERL2EXE_STORAGE /vol/tools6/clearcase/sol_output /tmp/p2xtmp-17237)
> at PERL2EXE_STORAGE/Tk/MainWindow.pm line 55
> 
> So we went to check if there was even a file in auto/Tk/getEncoding.al
> and found that there was no such file in that directory.  Is this file
> something that comes with perl-Tk-804.026 or is it a file that gets
> created when installing perl-Tk.  If there is anyone out there that
> has more information about this file, we would really appreciate the
> help.

This file is part of perl/Tk; on my system it lives in
/usr/local/lib/perl5/site_perl/5.8.8/mach/auto/Tk/getEncoding.al.
Programs like perl2exe that try to package up Perl modules often have
difficulty with modules that load things at runtime; I'm sure perl2exe
has a workaround for it.

Ben



------------------------------

Date: Wed, 12 Dec 2007 23:32:08 GMT
From: still just me <wheeledBobNOSPAM@yahoo.com>
Subject: Re: Get values from hash "in order"
Message-Id: <ekr0m35uja6jjb48dqhocucbc74gl4ev4k@4ax.com>

On Wed, 12 Dec 2007 10:24:47 -0800 (PST), smallpond
<smallpond@juno.com> wrote:

>
>foreach $key (key1, key2, key3, key4, ... ) {
>   $tempValue = $outputFileHeadings{$key};
>   $outputMessage = $outputMessage .  $tempValue;
>}


Thanks all. I will try out some of the suggestions. 

Is there some advantage to Perl in them storing in random order?
Perhaps some internal storage efficiency? 



------------------------------

Date: 12 Dec 2007 23:37:08 GMT
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: Get values from hash "in order"
Message-Id: <476070a4$0$16792$e4fe514c@dreader27.news.xs4all.nl>

On Wed, 12 Dec 2007 23:32:08 +0000, still just me wrote:

> On Wed, 12 Dec 2007 10:24:47 -0800 (PST), smallpond <smallpond@juno.com>
> wrote:
> 
> 
>>foreach $key (key1, key2, key3, key4, ... ) {
>>   $tempValue = $outputFileHeadings{$key}; $outputMessage =
>>   $outputMessage .  $tempValue;
>>}
> 
> 
> Thanks all. I will try out some of the suggestions.
> 
> Is there some advantage to Perl in them storing in random order? Perhaps
> some internal storage efficiency?

It's mainly lookup effiency. IOW it makes it really fast to find or 
insert an entry in a hash.

See http://en.wikipedia.org/wiki/Hash_table or any good programming /
datastructures book.

Joost.


------------------------------

Date: Thu, 13 Dec 2007 00:35:43 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Get values from hash "in order"
Message-Id: <z7%7j.22413$Bg7.21535@trndny07>

still just me wrote:
[about hashes]
> Is there some advantage to Perl in them storing in random order?
> Perhaps some internal storage efficiency?

Actually the order in which e.g. each() or keys() cycles through the items 
of a hash is not random at all but it is well defined and guaranteed to be 
the same for every access to that hash. It is just that this sequence 
doesn't make any sense to the programmer because this sequence is -as you 
suspected- based on the internal implementation and not on some human 
expectation about useful order.

However, on an abstract level, hashes are a generalization of arrays. Arrays 
are mappings from natural numbers (assuming you didn't mess with $[) into 
scalars while hashes are mappings from arbitrary strings into scalars.
Natural numbers have an inherent sequence, there is a natural next and 
previous. Therefore you can specify a concrete point in the array and from 
there access the next and the previous element.
There is no such obvious sequence for strings. Alphabetical sorting is not 
compact, i.e. between any two given strings there is always another string. 
And incremental strings as produced by the ++ operator are not what people 
would expect from a sorted hash.

And because there is no such obvious order on the domain elements of hashes 
as is are the natural numbers for arrays it doesn't make sense to speak of a 
sequence of the elements of hashes. Sequence of order is foreign to hashes.

jue 




------------------------------

Date: Wed, 12 Dec 2007 13:19:16 -0800 (PST)
From: vorticitywolfe@gmail.com
Subject: Re: How can I name my scalar with a for loop?
Message-Id: <1f658a31-c61b-48de-90de-808de4de4821@e4g2000hsg.googlegroups.com>

On Dec 12, 8:59 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> vorticitywo...@gmail.com wrote:
>
> > @stn=('A','B','C');
>
> > $count=0;
> > foreach($stn(@stn){
>
> > $Q.$count=$stn;
>
> > }
>
> > desired output:
>
> > Q1=A
> > Q2=B
> > Q3=C
>
>      use strict;
>      use warnings;
>      my @stn = ('A','B','C');
>      my $count = 0;
>      foreach my $stn ( @stn ) {
>          print 'Q' . ++$count . "=$stn\n";
>      }
>
> --
> Gunnar Hjalmarsson
> Email:http://www.gunnar.cc/cgi-bin/contact.pl

Thanks Gunnar,

Close to what I asked for, didn't quite work for my use, since I'm
trying to define the variable as $Q1 not just print Q1.

My goal is to define a bunch of identical labels in a perl tk gui
rather than repeating thousands of lines of code.
that is the final result will be like this:

$Q1=$side->Label(-text=>$stn1)->pack();

where $Q1 is defined by the for loop.

I appreciate the help though, I'll keep on fiddling and see if I can
get it to work.

Jonathan



------------------------------

Date: Wed, 12 Dec 2007 21:41:31 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How can I name my scalar with a for loop?
Message-Id: <fAY7j.3500$W27.2122@trndny09>

vorticitywolfe@gmail.com wrote:
> Close to what I asked for, didn't quite work for my use, since I'm
> trying to define the variable as $Q1 not just print Q1.

Are you trying to use a variable's content as a variable name? Bad idea(TM).
See "perldoc -q 'variable name'" and gazillions of previous discussions 
about symbolic references for explanations about why this is a particulary 
bad idea and what to do instead.

jue





------------------------------

Date: Wed, 12 Dec 2007 22:48:20 +0100
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: How can I name my scalar with a for loop?
Message-Id: <pan.2007.12.12.21.48.20@rtij.nl.invlalid>

On Wed, 12 Dec 2007 13:19:16 -0800, vorticitywolfe wrote:

> My goal is to define a bunch of identical labels in a perl tk gui rather
> than repeating thousands of lines of code. that is the final result will
> be like this:
> 
> $Q1=$side->Label(-text=>$stn1)->pack();
> 
> where $Q1 is defined by the for loop.
> 
> I appreciate the help though, I'll keep on fiddling and see if I can get
> it to work.

Do you need something like this?

my $n=0;
for my $stn (@stn) {
  $Q[$n++]=$side->Label(-text=>$stn)->pack();
}

Read up on arrays.

HTH,
M4


------------------------------

Date: 12 Dec 2007 21:48:51 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: How can I name my scalar with a for loop?
Message-Id: <Xns9A04A0DEF179Bcastleamber@130.133.1.4>

vorticitywolfe@gmail.com wrote:

> How can I name/define my scalar with a for loop?
> 
> @stn=('A','B','C');
> 
> $count=0;
> foreach($stn(@stn){
> 
> $Q.$count=$stn;
> 
> }
> 
> desired output:
> 
> Q1=A
> Q2=B
> Q3=C


use strict;
use warnings;

my @stn = ( 'A' .. 'B' );
my %vars;
my $count = 1;

for my $name ( @stn ) {

    	$vars{ "Q$count" } = $name;
    	$count++;
}

print "$vars{ Q2 }\n";

Untested, should print B


-- 
John

Arachnids near Coyolillo - part 1
http://johnbokma.com/mexit/2006/05/04/arachnids-coyolillo-1.html


------------------------------

Date: Wed, 12 Dec 2007 14:24:13 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: vorticitywolfe@gmail.com
Subject: Re: How can I name my scalar with a for loop?
Message-Id: <861w9rmu0i.fsf@blue.stonehenge.com>

>>>>> "vorticitywolfe" == vorticitywolfe  <vorticitywolfe@gmail.com> writes:

vorticitywolfe> Q1=A
vorticitywolfe> Q2=B
vorticitywolfe> Q3=C

If you ever find yourself naming a variable with a sequential distinguisher,
like "1" "2" "3" or "A" "B" "C", that's a sure sign that you're heading down
the wrong path, as those variables probably belong in some sort of larger data
structure.

Others have already given the details, but I wanted to make sure you
understood this.

print "Just another Perl hacker,"; # the original

-- 
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!


------------------------------

Date: Wed, 12 Dec 2007 23:20:40 GMT
From: ddunham@taos.com (Darren Dunham)
Subject: Re: How can I name my scalar with a for loop?
Message-Id: <c1_7j.5700$fl7.3224@newssvr22.news.prodigy.net>

vorticitywolfe@gmail.com wrote:
> Close to what I asked for, didn't quite work for my use, since I'm
> trying to define the variable as $Q1 not just print Q1.
> 
> My goal is to define a bunch of identical labels in a perl tk gui
> rather than repeating thousands of lines of code.
> that is the final result will be like this:
> 
> $Q1=$side->Label(-text=>$stn1)->pack();
> 
> where $Q1 is defined by the for loop.

But the name 'Q1' isn't special, right?  Don't use individually named
scalars, stick the references in an array.

my @label_refs;
foreach my $stn (@stn)
{
  push @label_refs, $side->Label(-text=>$stn)->pack();
}

Depending on what you're doing, it might be easier to store in a hash so
you can pull them by name:

my %label_refs;
foreach my $stn (@stn)
{
   $label_refs{$stn}=$side->Label(-text=>$stn)->pack();
}

-- 
Darren Dunham                                           ddunham@taos.com
Senior Technical Consultant         TAOS            http://www.taos.com/
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >


------------------------------

Date: Wed, 12 Dec 2007 18:10:36 -0500
From: somebody <some@body.com>
Subject: Newbie help with telephone number and date formatting
Message-Id: <nLKdnSdu17rx9_3anZ2dnUVZ_uyinZ2d@comcast.com>

Hello...

Can someone please tell me how to change a phone number from 
say 8005551212 to xxx-xxx-1212?  I've been reading about the tr command,
but still don't see how to accomplish this.


Also, if I wanted to format a date from say 20070413 to 04/13/2007, how
can I do this with one of the date modules?  I was looking at Date::Manip,
and it doesn't seem to do this.


Thank you




------------------------------

Date: 12 Dec 2007 23:33:47 GMT
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: Newbie help with telephone number and date formatting
Message-Id: <47606fdb$0$16792$e4fe514c@dreader27.news.xs4all.nl>

On Wed, 12 Dec 2007 18:10:36 -0500, somebody wrote:

> Hello...
> 
> Can someone please tell me how to change a phone number from say
> 8005551212 to xxx-xxx-1212?  I've been reading about the tr command, but
> still don't see how to accomplish this.

tr only translates single characters, so you can't use it to replace 
partial strings. You can use regular expressions for that.

$phone_number =~ s/(\d{3})(\d{3})(\d+)/$1-$2-$3/;

see the perl regular expression docs in perlre and perlretut.

> Also, if I wanted to format a date from say 20070413 to 04/13/2007, how
> can I do this with one of the date modules?  I was looking at
> Date::Manip, and it doesn't seem to do this.

You can also use regexes, but as far as I can see from the docs 
ParseDateString + UnixDate in Data::Manip should also work.

Joost.


------------------------------

Date: Wed, 12 Dec 2007 15:39:42 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Newbie help with telephone number and date formatting
Message-Id: <u28635xjjv.ln2@goaway.wombat.san-francisco.ca.us>

On 2007-12-12, somebody <some@body.com> wrote:
>
> Can someone please tell me how to change a phone number from 
> say 8005551212 to xxx-xxx-1212?  I've been reading about the tr command,
> but still don't see how to accomplish this.

You would certainly not use tr/// for this.  Try s///.

> Also, if I wanted to format a date from say 20070413 to 04/13/2007, how
> can I do this with one of the date modules?  I was looking at Date::Manip,
> and it doesn't seem to do this.

If you're absolutely certain that your dates will always be yyyymmdd,
then s/// can convert it to mm/dd/yyyy.  For help on s///, start with
perldoc perlretut.

--keith

-- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information



------------------------------

Date: Wed, 12 Dec 2007 21:47:49 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: split is not convinient
Message-Id: <9GY7j.4653$xd.412@trndny03>

Ben Morrow wrote:
> Quoth "Jürgen Exner" <jurgenex@hotmail.com>:
>>
>> One argument not being mentioned by others so far is that when a Perl
>> function allows omitting of an argument and thus substituting a
>> default argument it will be $_. Thisis the typical and expected Perl
>> behaviour. Interpreting a single argument as the text string rather
>> than the search pattern would be unexpected and contradictory to the
>> typical behaviour of all other Perl functions.
>
> Uh huh... like shift,

Is not defined on scalars. When argument is omitted it shifts @_ which is as 
close as possible to $_

> or readline,

The only argument is mandatory, you cannot omit it and thus cannot default 
to $_.

> or the return value of split in scalar context?

Doesn't apply. We are talking about optional function/operator _arguments_ 
which when omitted will default to $_. Return values are not arguments.

jue 




------------------------------

Date: Wed, 12 Dec 2007 23:00:28 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: split is not convinient
Message-Id: <cp5635-53n1.ln1@osiris.mauzo.dyndns.org>


Quoth "Jürgen Exner" <jurgenex@hotmail.com>:
> Ben Morrow wrote:
> 
> > or readline,
> 
> The only argument is mandatory, you cannot omit it and thus cannot default 
> to $_.

Yes. Sorry, that was a thinko; I meant <> and thought that readline had
the same default behaviour. To that list we can add -t, 1-arg open,
close (indeed, lots of the IO functions, including the mess that is
eof), substr, caller, bless, die/warn, exit, localtime, ... 

I'm not saying any of these defaults are not sensible and useful, just
that they're far from consistent.

Ben



------------------------------

Date: 12 Dec 2007 23:23:37 GMT
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: split is not convinient
Message-Id: <47606d79$0$16792$e4fe514c@dreader27.news.xs4all.nl>

On Wed, 12 Dec 2007 23:00:28 +0000, Ben Morrow wrote:

> Quoth "Jürgen Exner" <jurgenex@hotmail.com>:
>> Ben Morrow wrote:
>> 
>> > or readline,
>> 
>> The only argument is mandatory, you cannot omit it and thus cannot
>> default to $_.
> 
> Yes. Sorry, that was a thinko; I meant <> and thought that readline had
> the same default behaviour.

Don't forget while(<>) { ... }  :-)

> To that list we can add -t

which for /more-or-less/ obvious reasons defaults to _

> 1-arg open, close (indeed, lots of the IO functions, including the mess 
that is
> eof), substr, caller, bless, die/warn, exit, localtime, ...
> 
> I'm not saying any of these defaults are not sensible and useful, just
> that they're far from consistent.

You're definitely right there.

Joost.


------------------------------

Date: 12 Dec 2007 23:27:55 GMT
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: split is not convinient
Message-Id: <47606e7b$0$16792$e4fe514c@dreader27.news.xs4all.nl>

On Wed, 12 Dec 2007 23:23:37 +0000, Joost Diepenmaat wrote:

> which for /more-or-less/ obvious reasons defaults to _

Arg. no it doesn't. For other obvious reasons.

Joost.


------------------------------

Date: Wed, 12 Dec 2007 19:56:28 -0500
From: Mark Seger <Mark.Seger@hp.com>
To: Todd <xueweizhong@gmail.com>
Subject: Re: split is not convinient
Message-Id: <4760833C.7040204@hp.com>

Todd wrote:
> Hi,
> 
> 
> When I use split, there are serveral case frequently occured:
> 
> case1:
> 
>     split # default to split ' ', $_
> 
> case2:
> 
>     split /xxx/ # default to split /xxx/, $_
> 
> case3:
> 
>     split ' ', expr # ????
> 
> 
> I do think case3 is most frequently used, but why i've to type ' '
> every time, why there are no simpler syntax to use in this case?

Maybe I've just been programming for too many years and looked at too 
much code written by people who like to take shortcuts, but I think your 
cases 1/2 should never be used!  In fact I avoid any syntax that has a 
default such as "while (<>)" which is why I always use "while 
($var=<>)".  After all, you never know when someone is going to insert a 
line of code that blows away your default with a different one.  In 
other words it's all about supportability!

It's also common for someone to pick up a piece of code in a language 
they're not familiar with and try to figure out what it does with 
minimal effort and having something that is not obvious is a real pain. 
  Are people that lazy that typing a few extra characters to make what 
they're doing more explicit too much of a burden?  How is this any 
different from commenting code?  Or don't people do that any more either?

-mark


------------------------------

Date: Wed, 12 Dec 2007 14:00:46 -0800 (PST)
From: Tim <google@hoodfamily.org>
Subject: Using the DBI to connect to an Oracle server w/o connecting to a  database
Message-Id: <945b76e6-cad4-4a57-9526-9d9382c57ebc@x69g2000hsx.googlegroups.com>

I've searched for the answer to this problem and have not seen it
(which suggests what the answer might be ;-) ). Is it possible to use
DBI (and DBD::Oracle) to connect to an Oracle server without
connecting to a database? This would be the DBI equivalent of:

sqlplus /nolog
SQL> connect user/passwd@database;

or, more similarly:

sqlplus /nolog @my.sql

where my.sql might be:

connect user/passwd@database;
select ...
etc.

I'm thinking this is not possible, but I hope it is. Thanks.


------------------------------

Date: Wed, 12 Dec 2007 23:01:53 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Using the DBI to connect to an Oracle server w/o connecting to a  database
Message-Id: <1s5635-53n1.ln1@osiris.mauzo.dyndns.org>


Quoth Tim <google@hoodfamily.org>:
> I've searched for the answer to this problem and have not seen it
> (which suggests what the answer might be ;-) ). Is it possible to use
> DBI (and DBD::Oracle) to connect to an Oracle server without
> connecting to a database? This would be the DBI equivalent of:
> 
> sqlplus /nolog
> SQL> connect user/passwd@database;

Is this not connecting to a database? I think you will have to explain a
bit more about what you are actually trying to acheive.

Ben



------------------------------

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 1109
***************************************


home help back first fref pref prev next nref lref last post