[15732] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3145 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 24 11:05:46 2000

Date: Wed, 24 May 2000 08:05:15 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <959180715-v9-i3145@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 24 May 2000     Volume: 9 Number: 3145

Today's topics:
    Re: &#037; translating ascii to unicode? (Bart Lateur)
    Re: &#037; translating ascii to unicode? <flavell@mail.cern.ch>
    Re: &#037; translating ascii to unicode? (Bart Lateur)
    Re: &#037; translating ascii to unicode? <bill.kemp@wire2.com>
    Re: &#037; translating ascii to unicode? <spam-abuse@uk2.net>
    Re: @lets = split(/\_/, $value); ? (Neil Kandalgaonkar)
    Re: @lets = split(/\_/, $value); ? (Gwyn Judd)
    Re: alias mail and script perl ghorghor@my-deja.com
    Re: Basic scripting question <red_orc@my-deja.com>
    Re: Basic scripting question (Gwyn Judd)
    Re: comparing dates <danielxx@bart.nl>
    Re: Converting special chars... <flavell@mail.cern.ch>
    Re: Copy A File? <nospam@nospam.com>
    Re: Copy A File? <billy@arnis-bsl.com>
    Re: Copy A File? (Gwyn Judd)
    Re: Could not create socket: Bad file number paul_kostal@hotmail.com
    Re: creating graphs with perl..? <tbornholtz@cso.com>
    Re: cut off text after a <br> <fatlezzers@hotmail.com>
        email poser <dfleet@avaterra.com>
    Re: How do I extract 2nd and 3rd characters from a stri (Gwyn Judd)
    Re: How do I extract 2nd and 3rd characters from a stri <sariq@texas.net>
    Re: How to run a perl program as Win32 Service? <carvdawg@patriot.net>
    Re: How to split this ? <billy@arnis-bsl.com>
    Re: How to split this ? <moltimer@yahoo.com>
    Re: How to split this ? (Gwyn Judd)
    Re: How to split this ? <aqumsieh@hyperchip.com>
        how to stop strict from whining... <peter_icaza@uhc.com>
    Re: how to stop strict from whining... <dave@dave.org.uk>
    Re: join " ", do {$x++}, do {$x++}, do {$x++}; (Gwyn Judd)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 24 May 2000 11:46:38 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: &#037; translating ascii to unicode?
Message-Id: <392cbf6b.3275287@news.skynet.be>

W Kemp wrote:

>>ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-1.TXT

>Yes I have been led astray by the dark empire.
>Thank-you for leading me back towards the light.
>(The only trouble is- customers think its part of latin-1)

If you want the real table for the Dark Empire, look at the table for
Code Page 1252. The characters between 0x80 and 0x9F (incl) all point
somewhere else.

ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT


And don't mind the empty lines, probably somebody uploaded the file in
binary mode from Windows. But be careful if editing the file with
notepad, which considers CR+CR+LF as a soft wrap.

-- 
	Bart.


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

Date: Wed, 24 May 2000 14:19:41 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: &#037; translating ascii to unicode?
Message-Id: <Pine.GHP.4.21.0005241356390.5170-100000@hpplus01.cern.ch>

On Wed, 24 May 2000, W Kemp wrote:

> (The only trouble is- customers think its part of latin-1)

There are at least three character _codes_ that include the Latin-1
character _repertoire_, in addition to the standard code iso-8859-1:
there's DOS CP-850, there's Windows-1252, and there's EBCDIC CECP-1047
- defined by IBM at the insistence of the SHARE user group, but not
widely known it seems (a web search for cecp-1047 produces only a tiny
handful of resources).  It's documented in A.Pirard's 1992 writeup,
see e.g
ftp://watsun.cc.columbia.edu/kermit/charsets/iso8859.networking

Of course the actual character code values used in MS-DOS and in
EBCDIC are very different from iso-8859-1: but the term "latin-1"
strictly defines a repertoire of characters, not a particular ordering
of them in a character code, and all of these codes at least _contain_
the latin-1 repertoire (and some with extra displayable characters).

The confusing thing about Windows-1252 is that it contains all the
printable characters from iso-8859-1 in exactly the same places, but
adds some more printable characters in the range 128-159 decimal. And
MS seem happy to propagate the confusion by having software that
actually sends windows-1252 code (with clever-quotes, em dashes and
such) but labels it as iso-8859-1.  On top of that, MS have a neat
habit of calling the proprietary Windows codings "ANSI", which some
people even transmogrify into "8-bit ASCII", something which really
doesn't exist.  I believe that ANSI were at one time intending to
develop a US-national 8-bit code, but they perceptively realised that
it made more sense to adopt an ISO coding rather than trying to dig
their own national furrow.

I really have gone far beyond what I had intended to cover in this
thread, sorry.



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

Date: Wed, 24 May 2000 13:40:30 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: &#037; translating ascii to unicode?
Message-Id: <392ddb8e.10477987@news.skynet.be>

Alan J. Flavell wrote:

>And MS seem happy to propagate the confusion by having software that
>actually sends windows-1252 code (with clever-quotes, em dashes and
>such) but labels it as iso-8859-1.

This is a typical example of why people, and not just competitors, love
to hate MS.

-- 
	Bart.


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

Date: Wed, 24 May 2000 15:04:26 +0100
From: "W Kemp" <bill.kemp@wire2.com>
Subject: Re: &#037; translating ascii to unicode?
Message-Id: <959177160.16788.0.nnrp-01.c3ad6973@news.demon.co.uk>


Alan J. Flavell wrote in message ...

>I really have gone far beyond what I had intended to cover in this
>thread, sorry.


perhaps sorry to the original poster.
But its all good stuff for me.





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

Date: Wed, 24 May 2000 15:09:46 +0100
From: Nadja Herkova <spam-abuse@uk2.net>
Subject: Re: &#037; translating ascii to unicode?
Message-Id: <392BE2A4.1E856574@uk2.net>

A big thankyou to all for help with this

Bart Lateur wrote:

> Alan J. Flavell wrote:
>
> >And MS seem happy to propagate the confusion by having software that
> >actually sends windows-1252 code (with clever-quotes, em dashes and
> >such) but labels it as iso-8859-1.
>
> This is a typical example of why people, and not just competitors, love
> to hate MS.

so, a CGI form posted from a machine running Windows would allow the user
to send MS extended characters to the script ? including those blasted
clever quotes..  i feel another revision of my code coming on :-|




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

Date: 24 May 2000 10:40:21 GMT
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Re: @lets = split(/\_/, $value); ?
Message-Id: <8ggbil$35c$1@newsflash.concordia.ca>

>Moltimer wrote:
>> 
>> I split a value by "_"
>> The odinary value should have only two of "_" like "A_B_C".
>> 
>> If there are many "_"s in middle word like "A_B-1_B-2_B-3_C,
>> How can I get value like "A", "B-1_B-2_B-3" and "C"
>> instead of "A", "B-1" and "B-2" ?
>> 
>> @lets = split(/\_/, $value);
>> $lets[0] should be "A"
>> $lets[0] should be "B-1_B-2_B-3"
>> $lets[0] should be "C"
>

Well, they can't ALL be $lets[0].

This might do the trick.


my @lets;

while ($value =~ /
                   (               # begin storing $1
                     ([A-Z])       # store a letter in $2
                     (-\d+         # optionally followed by dash number
                       (           # and then zero or more of...
                         _\2-\d+   # underscore, same letter, dash num. 
                       )*
                     )?
                   )
                 /gx               # globally
      ) 
{ 
   push @lets, $1; 
}


-- 
Neil Kandalgaonkar
neil@brevity.org


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

Date: Wed, 24 May 2000 13:54:24 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: @lets = split(/\_/, $value); ?
Message-Id: <slrn8iqc8i.be8.tjla@thislove.dyndns.org>

I was shocked! How could Jeff Zucker <jeff@vpservices.com>
say such a terrible thing:
>Moltimer wrote:
>> 
>> I split a value by "_"
>> The odinary value should have only two of "_" like "A_B_C".
>> 
>> If there are many "_"s in middle word like "A_B-1_B-2_B-3_C,
>> How can I get value like "A", "B-1_B-2_B-3" and "C"
>> instead of "A", "B-1" and "B-2" ?

<snip>

>Easiest is a regex instead of split I think:
>
>my $value = 'A_B-1_B-2_B-3_C';
>my @lets = $value =~ /^([^_]*)_(.*)_([^_]*)$/;

well the first and last "*"'s should be "+"'s and I think we can make it
a wee bit simpler since greediness will do some of the work for us:

my $value = 'A_B-1_B-2_B-3_C';
my @lets = $value =~ /^([^_]+)_(.*)_(.+)$/;

-- 
Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
It is often easier to ask for forgiveness than to ask for permission.
		-- Grace Murray Hopper


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

Date: Wed, 24 May 2000 14:19:13 GMT
From: ghorghor@my-deja.com
Subject: Re: alias mail and script perl
Message-Id: <8ggocf$bt1$1@nnrp1.deja.com>

i send a mail from an other computer on Windows

i recieve an mail error like this :

The following addresses had permanent fatal errors -----
"|/usr/local/.../Mliste.pl"
(expanded from: <test_mailing@jeuxvideo.com>) ----- Transcript of
session follows -----sh: /usr/local/.../Mliste.pl: not found554

"|/usr/local/.../Mliste.pl"... unknown mailer error 1


the script is chmod 777 and is in the right directory

In article <%FNW4.804$6T1.133153@news.dircon.co.uk>,
  Jonathan Stowe <gellyfish@gellyfish.com> wrote:
> On Wed, 24 May 2000 08:11:31 GMT, ghorghor@my-deja.com Wrote:
> > hello
> >
> > i m working on an unix system.
> >
> > I ve created an alias in the file aliases like this :
> >
> > test_mailing : "|/usr/local/.../script.pl"
> >
> > the script should recieve the mail through stdin but it doesn t work
> >
>
> In what way doesnt it work ?  Any number of things could be wrong and
> only a few of them might have anything to do with Perl.
>
> /J\
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 24 May 2000 13:00:48 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: Basic scripting question
Message-Id: <8ggjpn$8c5$1@nnrp1.deja.com>

In article <brian-ya02408000R2205002245010001@news.panix.com>,
  brian@smithrenaud.com (brian d foy) wrote:
>
>
> of course, all of this is much more simply written as
>
>    while( <LINES> )
>       {
>       print unless ++$line_counter % 3;

eh, don't you mean
        print if ++$line_counter % 3;
?

>       }
>
> --
> brian d foy
> CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
> Perl Mongers <URL:http://www.perl.org/>
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 24 May 2000 13:24:29 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Basic scripting question
Message-Id: <slrn8iqaei.be8.tjla@thislove.dyndns.org>

I was shocked! How could Gwyn Judd <tjla@guvfybir.qlaqaf.bet>
say such a terrible thing:
>let me point them out for you since your monitor resolution seems to be
>set wrong:

<mangled ascii art snipped>

-- 
Gwyn "damn" Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
Slowly and surely the unix crept up on the Nintendo user ...


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

Date: Wed, 24 May 2000 13:12:58 GMT
From: "Daniel van den Oord" <danielxx@bart.nl>
Subject: Re: comparing dates
Message-Id: <uzQW4.2826$Kk2.43099@Typhoon.bART.nl>

That's easy use the join function to join them like this
yyyymmdd
20000809        = 09-aug-2000
do that with 2 different dates and substract them !!!




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

Date: Wed, 24 May 2000 12:02:52 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Converting special chars...
Message-Id: <Pine.GHP.4.21.0005241153010.5170-100000@hpplus01.cern.ch>

On Wed, 24 May 2000, Bert IJff quoted the entire posting including
sig, always a warning sign:

> "David A. Pegram" wrote:

> > For example, I'd like to convert "ö" to "o".

> It greatly depends on the underlying character set (i.e. where does
> your inout text come from)

The hon. Usenaut's original posting contained this header:

Content-Type: text/plain; charset=iso-8859-1

So the character in question was unambiguously o-umlaut.

If they intended anything different (which I doubt), they would have
been wrong; if you saw anything different, then you were wrong.  
There is an objective standard of correctness.

> For example (character set looked up in some old book) this ö
> (copy/pasted from your text)
> 
> is char(154) in MC Text ,

Irrelevant.  If your news software fails to display o-umlaut, then it
doesn't properly support MIME.  This is still technically permissible
on usenet, but it effectively disqualifies one from participating
meaningfully in debates that involve 8-bit characters.

Copy/pasting into other applications is a local issue, and either
works or doesn't work.  If it creates meaningless garbage, then it
isn't useful.

This is a difficult enough topic even without the addition of FUD.

all the best



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

Date: Wed, 24 May 2000 12:53:51 +0100
From: "NoSpam" <nospam@nospam.com>
Subject: Re: Copy A File?
Message-Id: <TlPW4.819$6T1.136297@news.dircon.co.uk>

Does this allow variables?

e.g.

system 'cp $sourcefile $destfile';

cheers

Paul.

Marco Natoni wrote in message <392BA385.2D2EAE0F@nospam.com>...
>NoSpam,
>
>NoSpam wrote:
>> What is the Perl command to copy a file from a folder to another?
>
>  A number of ways is available but the simplest I see is:
>
> system 'YOUR_OS_CP_COMMAND path1 path2';
>
>
> Best regards,
> Marco




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

Date: Wed, 24 May 2000 11:47:01 GMT
From: Ilja <billy@arnis-bsl.com>
Subject: Re: Copy A File?
Message-Id: <8ggffh$5cu$1@nnrp1.deja.com>

In article <DsMW4.802$6T1.133053@news.dircon.co.uk>,
  "NoSpam" <nospam@nospam.com> wrote:
> What is the Perl command to copy a file from a folder to another?
>
>

Use File::Copy module.

Consult your local 'perldoc File::Copy' or
http://www.cpan.org/doc/manual/html/lib/File/Copy.html.

Ilja.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 24 May 2000 14:34:50 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Copy A File?
Message-Id: <slrn8iqekd.be8.tjla@thislove.dyndns.org>

I was shocked! How could NoSpam <nospam@nospam.com>
say such a terrible thing:
>Does this allow variables?
>
>e.g.
>
>system 'cp $sourcefile $destfile';

no you'll need double quotes for that. Oh and you should always check
the return value:

system "cp $sourcefile $destfile" || die "could not copy: $!";

-- 
Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
BOFH excuse #169:

broadcast packets on wrong frequency


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

Date: Wed, 24 May 2000 10:02:05 GMT
From: paul_kostal@hotmail.com
Subject: Re: Could not create socket: Bad file number
Message-Id: <8gg9an$1a6$1@nnrp1.deja.com>

In article <8gebv6$mpe$1@nnrp1.deja.com>,
  Rodney Engdahl <red_orc@my-deja.com> wrote:
> In article <8geaep$lg0$1@nnrp1.deja.com>,
>   paul_kostal@hotmail.com wrote:
> > Creating a socket in perl gives the error "Could not create socket:
> Bad
> > file number".
> >
> > $main_socket = IO::Socket::INET->new ( LocalAddr => $my_host,
> > 				       LocalPort => $my_port,
> > 				       Listen    => 5,
> > 				       Proto     => 'tcp',
> > 				       Reuse     => 1);
> > die "Could not create socket: $! \n" unless $main_socket;
> >
> > I am currently using Perl 5.005 on Solaris 2.6.
> > Can anybody help me ?
> >
>
> substituting the correct ipaddr for the local machine for $my_host,
and
> substituting '9000' for $my_port, this code works on my system running
> 5.00504 and Solaris 7.
>
> What are your values for $my_port and $my_host?
>
Trying to use another port works fine. This is because the port i used
was already occupied by inetd (see services).
Now i am wondering, why my code is running fine on one machine (Solaris
2.6) and not running on another (Solaris 2.5) where both having already
inetd using this port. Seems there is a problem with Solaris 2.5.
Thanks for your help.
Paul

P.S.: I have no known relationship to Irvin Kostal, maybe there is some
long ago ???


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 24 May 2000 09:40:35 -0500
From: "Tim Bornholtz" <tbornholtz@cso.com>
Subject: Re: creating graphs with perl..?
Message-Id: <6BCD5E5D52D79F9A.5C0904E3E2280561.EDE3446F487300CF@lp.airnews.net>


<suot@iobox.com> wrote in message news:8gg4is$u4f$1@nnrp1.deja.com...
> Hey, my purpose was to create simple scientific graphs with Perl via
> HTML-pages. We are running
>  NT-server.
>  I've found only couple of UNIX-modules for Perl to create those graphs
> but none for NT. Could anyone give
>  a hand..?

I'm using the GD and Chart::* modules.  Both are available for Win32 via ppm
or via CPAN.


hth,
Tim Bornholtz
tbornholtz@cso.com




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

Date: Wed, 24 May 2000 07:19:04 +0100
From: "Phil Latio" <fatlezzers@hotmail.com>
Subject: Re: cut off text after a <br>
Message-Id: <8gfsdf$99f$1@neptunium.btinternet.com>

Brilliant !!!

It's working superbly.

Many thanks.






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

Date: Wed, 24 May 2000 12:25:25 +0100
From: "David Fleet" <dfleet@avaterra.com>
Subject: email poser
Message-Id: <392bbac3.0@nnrp1.news.uk.psi.net>

Hello.

Anyone know why only 300 or so emails get through when I do a mass email to
myself?

The code is as below:--


#initialise variables
$mailprog = '/usr/lib/sendmail';
$recipient1 = "d.fleet\@mydomain.net;
$recipient = "d.fleet\@mydomain.net";
$date_command = "/usr/sbin/date";


print "Content-type: text/html\n\n";


for($a=1;$a<1001;$a++){

$time="";
  # Get the current time and format the hour, minutes and seconds.  Add    #
    # 1900 to the year to get the full 4 digit year.
#
    ($sec,$min,$hour,$mday,$mon,$year,$wday) =
(localtime(time))[0,1,2,3,4,5,6];
    $time = sprintf("%02d minute %02d seconds",$min,$sec);

#start mail
open(MAIL, "|$mailprog $recipient1") || &emailerror;
print MAIL "Subject: $a Email test\n";
print MAIL "From: $recipient\n";
print MAIL "To: $recipient1\n\n";
print MAIL "$a\n\n
$time
\n\n";
close (MAIL);

print "$a <BR>";
}

exit;




It prints out 1- 1000 on the screen, so the loop works o.k.
Is there some sort of default within the email server?

Thanx.

Han.





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

Date: Wed, 24 May 2000 13:30:23 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: How do I extract 2nd and 3rd characters from a string
Message-Id: <slrn8iqari.be8.tjla@thislove.dyndns.org>

I was shocked! How could Tom Phoenix <rootbeer@redcat.com>
say such a terrible thing:
>On Tue, 23 May 2000, Gwyn Judd wrote:
>
>> Subject: Re: How do I extract 2nd and 3rd characters from a string
>
>> ($Extract23) = ($String =~ /.(..)/);
>
>What you get there may or may not be the second and third characters from
>the string. For example, $String may actually be "A\nstring\nof
>multiple\nlines\n". Cheers!

umm but doesn't '.' normally match any character except newline? In
which case it would match "st" in your given string. If you wanted it to
match the newline you would give it the /s modifier and it would give
you "\ns". I like mine better but hey

-- 
Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
All Finagle Laws may be bypassed by learning the simple art of doing
without thinking.


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

Date: Wed, 24 May 2000 09:36:47 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: How do I extract 2nd and 3rd characters from a string
Message-Id: <392BE8FF.2F31F194@texas.net>

Gwyn Judd wrote:
> 
> I was shocked! How could Tom Phoenix <rootbeer@redcat.com>
> say such a terrible thing:
> >On Tue, 23 May 2000, Gwyn Judd wrote:
> >
> >> Subject: Re: How do I extract 2nd and 3rd characters from a string
> >
> >> ($Extract23) = ($String =~ /.(..)/);
> >
> >What you get there may or may not be the second and third characters from
> >the string. For example, $String may actually be "A\nstring\nof
> >multiple\nlines\n". Cheers!
> 
> umm but doesn't '.' normally match any character except newline? In
> which case it would match "st" in your given string.

No, it won't.  *Always* test before posting.

> If you wanted it to
> match the newline you would give it the /s modifier and it would give
> you "\ns".

That part you got right.

> I like mine better but hey

I'd prefer one that works... :)

- Tom


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

Date: Wed, 24 May 2000 06:15:25 -0400
From: H C <carvdawg@patriot.net>
Subject: Re: How to run a perl program as Win32 Service?
Message-Id: <392BABBD.98BB570E@patriot.net>

You can look at doing this by hand with Win32::Lanman, or try Dave Roth's
(http://www.roth.net)
module, Win32::Daemon...

Nathan Dye wrote:

> Want to install a Service (daemon?) on WinNT 4.0 (SP3 or SP5).  We've
> installed ActiveState Perl 5.22.
>
> Anyone know of a skeleton or example?
>
> TIA,
>     Nathan



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

Date: Wed, 24 May 2000 10:30:37 GMT
From: Ilja <billy@arnis-bsl.com>
Subject: Re: How to split this ?
Message-Id: <8ggb0e$2cr$1@nnrp1.deja.com>

In article <8gflpr$mot$2@news2.kornet.net>,
  "Moltimer" <moltimer@yahoo.com> wrote:
> I split a value by "_"
> The odinary value should have only two of "_" like "A_B_C".
>
> If there are many "_"s in middle word like "A_B-1_B-2_B-3_much_more_C,
> How can I get value like "A", "B-1_B-2_B-3_much_more" and "C"
> instead of "A", "B-1" and "B-2" ?
>
> @lets = split(/\_/, $value);
> $lets[0] should be "A"
> $lets[0] should be "B-1_B-2_B-3_much_more"
> $lets[0] should be "C"
>

#!/usr/bin/perl -w

use strict;

my $str = 'A___Z';

my @lets;

if ( $str =~ /^([^_]+?)_(.+)_([^_]+?)$/ )
{
     @lets = ($1, $2, $3);
}
else
{
     die "string doesn't confirm to your specs: $str\n";
}

# that's all

Hope this helps.
Ilja.




Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 24 May 2000 22:11:20 +0900
From: "Moltimer" <moltimer@yahoo.com>
Subject: Re: How to split this ?
Message-Id: <8ggk54$1ht$1@news2.kornet.net>

>#!/usr/bin/perl -w
>
>use strict;
>
>my $str = 'A___Z';
>
>my @lets;
>
>if ( $str =~ /^([^_]+?)_(.+)_([^_]+?)$/ )
>{
>     @lets = ($1, $2, $3);
>}
>else
>{
>     die "string doesn't confirm to your specs: $str\n";
>}
>
># that's all
>
>Hope this helps.
>Ilja.
>

Thanks llja.
It woks good.

However, I couldn't understand this.
$str =~ /^([^_]+?)_(.+)_([^_]+?)$/

Where can I learn like that ?

If you give me one more example
for getting two values of lets[0] and lets[1] with
"A-1_A-2_A-3_much_more_B",
I will be happy to learn this.

 $lets[0] should be "A-1_A-2_A-3_much_more"
 $lets[1] should be "B"

Thanks in advance.





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

Date: Wed, 24 May 2000 14:41:42 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: How to split this ?
Message-Id: <slrn8iqf18.be8.tjla@thislove.dyndns.org>

I was shocked! How could Moltimer <moltimer@yahoo.com>
say such a terrible thing:
>Thanks llja.
>It woks good.
>
>However, I couldn't understand this.
>$str =~ /^([^_]+?)_(.+)_([^_]+?)$/
>
>Where can I learn like that ?

That thingy is known as a "regular expression". If you are on a unix
machine type "perldoc perlre" for an introduction.

-- 
Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
One seldom sees a monument to a committee.


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

Date: Wed, 24 May 2000 14:52:09 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: How to split this ?
Message-Id: <7a66s4xap7.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>


"Moltimer" <moltimer@yahoo.com> writes:

> I split a value by "_"
> The odinary value should have only two of "_" like "A_B_C".
> 
> If there are many "_"s in middle word like "A_B-1_B-2_B-3_much_more_C,
> How can I get value like "A", "B-1_B-2_B-3_much_more" and "C"
> instead of "A", "B-1" and "B-2" ?
> 
> @lets = split(/\_/, $value);
> $lets[0] should be "A"
> $lets[0] should be "B-1_B-2_B-3_much_more"
> $lets[0] should be "C"

	% perl -wl
	$_ = 'A_B-1_B-2_B-3_much_more_C';
	@lets = /(.+?)_(.+)_(.+)/;
	print join ' | ', @lets;
	__END__
	A | B-1_B-2_B-3_much_more | C


HTH,
--Ala


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

Date: Wed, 24 May 2000 09:29:52 -0400
From: "peter" <peter_icaza@uhc.com>
Subject: how to stop strict from whining...
Message-Id: <8ggleg$7fni$1@pike.uhc.com>

hi,
how can i stop "use strict" from whining about bad code in a module?  while
the following example uses DBI/DBD the topic is generic.  i tried putting
the offending code in a block with "no strict;" but it didnt work.  any
suggestions?  please cc me as well.  the news feed i have is not always
reliable.
thanks,
peter

-------- here is the whining code----------------------------------------
use DBI;
use DBD::DB2::Constants;
use DBD::DB2;
$ENV{DB2INSTANCE} = "my_inst";

my $dbh = DBI->connect("dbi:DB2:GSML1A", "my_user", "my_passwd",
                       {RaiseError => 0, AutoCommit => 1 });
if (not defined($dbh))
    {
    die ("---$0: cant connect to db2: $DBI::errstr");
    }
$dbh->disconnect or die "---$0: cant disconnect from db2: $DBI::errstr";

---- here is the whine -------------------------------------------------
Argument "HASH" isn't numeric in eq at
        /usr/complex/perl/lib/site_perl/5.005/aix/DBD/DB2.pm line 145 (#1)

    (W) The indicated string was fed as an argument to an operator that
    expected a numeric value instead.  If you're fortunate the message
    will identify which operator was so unfortunate.

Argument "" isn't numeric in eq at
        /usr/complex/perl/lib/site_perl/5.005/aix/DBD/DB2.pm line 149 (#1)

Use of uninitialized value at
        /usr/complex/perl/lib/site_perl/5.005/aix/DBD/DB2.pm line 149 (#2)

    (W) An undefined value was used as if it were already defined.  It was
    interpreted as a "" or a 0, but maybe it was a mistake.  To suppress
this
    warning assign an initial value to your variables.

------ here is the offending
code ----------------------------------------------------
---clearly the "==" should be "eq"
code from /usr/complex/perl/lib/site_perl/5.005/aix/DBD/DB2.pm:
 ...
        if( ref($attr) == "HASH" )
        {
          my %a = %$attr;

          if( $a{LongReadLen} == '' )
 ...




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

Date: Wed, 24 May 2000 14:56:00 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: how to stop strict from whining...
Message-Id: <kpnnis4d8jeq6etsvtnjp6t20dlvj384qm@4ax.com>

On Wed, 24 May 2000 09:29:52 -0400, "peter" <peter_icaza@uhc.com>
wrote:

>hi,
>how can i stop "use strict" from whining about bad code in a module?  while
>the following example uses DBI/DBD the topic is generic.  i tried putting
>the offending code in a block with "no strict;" but it didnt work.  any
>suggestions?  please cc me as well.  the news feed i have is not always
>reliable.
>thanks,
>peter
>
>-------- here is the whining code----------------------------------------
>use DBI;
>use DBD::DB2::Constants;
>use DBD::DB2;
>$ENV{DB2INSTANCE} = "my_inst";
>
>my $dbh = DBI->connect("dbi:DB2:GSML1A", "my_user", "my_passwd",
>                       {RaiseError => 0, AutoCommit => 1 });
>if (not defined($dbh))
>    {
>    die ("---$0: cant connect to db2: $DBI::errstr");
>    }
>$dbh->disconnect or die "---$0: cant disconnect from db2: $DBI::errstr";
>
>---- here is the whine -------------------------------------------------
>Argument "HASH" isn't numeric in eq at
>        /usr/complex/perl/lib/site_perl/5.005/aix/DBD/DB2.pm line 145 (#1)
>
>    (W) The indicated string was fed as an argument to an operator that
>    expected a numeric value instead.  If you're fortunate the message
>    will identify which operator was so unfortunate.
>
>Argument "" isn't numeric in eq at
>        /usr/complex/perl/lib/site_perl/5.005/aix/DBD/DB2.pm line 149 (#1)
>
>Use of uninitialized value at
>        /usr/complex/perl/lib/site_perl/5.005/aix/DBD/DB2.pm line 149 (#2)
>
>    (W) An undefined value was used as if it were already defined.  It was
>    interpreted as a "" or a 0, but maybe it was a mistake.  To suppress
>this
>    warning assign an initial value to your variables.
>
>------ here is the offending
>code ----------------------------------------------------
>---clearly the "==" should be "eq"
>code from /usr/complex/perl/lib/site_perl/5.005/aix/DBD/DB2.pm:
>...
>        if( ref($attr) == "HASH" )
>        {
>          my %a = %$attr;
>
>          if( $a{LongReadLen} == '' )
>...

Your best bet would be to correct he code in your copy of the module
and send a patch to the module's author.

That's how Open Source works :-)

Dave...

-- 
<http://www.dave.org.uk>  SMS: sms@dave.org.uk
yapc::Europe - London, 22 - 24 Sep <http://www.yapc.org/Europe/>

"There ain't half been some clever bastards" - Ian Dury [RIP]


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

Date: Wed, 24 May 2000 13:21:30 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: join " ", do {$x++}, do {$x++}, do {$x++};
Message-Id: <slrn8iqaas.be8.tjla@thislove.dyndns.org>

I was shocked! How could Intergalactic Denizen of Mystery <Tbone@pimpdaddy.com>
say such a terrible thing:
>tjla@guvfybir.qlaqaf.bet writes:
>>True...I realised afterwards I'd been talking about the wrong thing
>>probably.
>
>I was shocked! How could you say such a terrible thing?

The internet made me do it :)

-- 
Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
Workers of the world, arise!  You have nothing to lose but your
chairs.


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 3145
**************************************


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