[22530] in Perl-Users-Digest
Perl-Users Digest, Issue: 4751 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 24 00:06:11 2003
Date: Sun, 23 Mar 2003 21:05:05 -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 Sun, 23 Mar 2003 Volume: 10 Number: 4751
Today's topics:
Re: Changeing Scope of a Sub Reference <goldbb2@earthlink.net>
Re: Changeing Scope of a Sub Reference <aran@bluefeet.net>
Re: currency number to text conversion <Jodyman@hotmail.com>
Re: currency number to text conversion <mbudash@sonic.net>
Re: currency number to text conversion <bwalton@rochester.rr.com>
Re: doubts on \n ctcgag@hotmail.com
Re: doubts on \n <goldbb2@earthlink.net>
Re: grep and uninitialized value in concatenation <abigail@abigail.nl>
Re: grep and uninitialized value in concatenation <mbudash@sonic.net>
Re: grep and uninitialized value in concatenation <mstep@t-online.de>
Re: How stable is 'Magic'? <goldbb2@earthlink.net>
Re: nms formmail with file upload (Tad McClellan)
Re: Possible Storable 2.06 bug with CODE refs that use <goldbb2@earthlink.net>
Re: socket- and pseudo-tty-problem <troc@netrus.net>
Re: XML Parsing (PerlSAX): Improving error reporting (ivo welch)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 23 Mar 2003 21:44:19 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Changeing Scope of a Sub Reference
Message-Id: <3E7E7103.FEC2E2B3@earthlink.net>
Aran Deltac wrote:
>
> Hello beautiful Perl people.
>
> I have this big lengthy program written that needs this ability.
> Instead of posting a bunch of meaningless code, here's a sample
> (conceptually) of what I am trying to do:
>
> use strict;
> my $sub_ref = sub{ print $i; };
> sub run_ref { my $i = 'Hello!'; &{$sub_ref}; }
> run_ref();
use strict;
use PadWalker qw(peek_my); # from CPAN.
my $sub_ref = sub { print ${peek_my(1)->{'$i'}}; };
sub run_ref { my $i = 'Hello!'; &$sub_ref(); }
run_ref();
[untested]
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Mon, 24 Mar 2003 04:19:20 GMT
From: "Aran Deltac" <aran@bluefeet.net>
Subject: Re: Changeing Scope of a Sub Reference
Message-Id: <cHvfa.14101$xE1.692189@twister.southeast.rr.com>
"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
news:3E7E7103.FEC2E2B3@earthlink.net...
> Aran Deltac wrote:
> >
> > Hello beautiful Perl people.
> >
> > I have this big lengthy program written that needs this ability.
> > Instead of posting a bunch of meaningless code, here's a sample
> > (conceptually) of what I am trying to do:
> >
> > use strict;
> > my $sub_ref = sub{ print $i; };
> > sub run_ref { my $i = 'Hello!'; &{$sub_ref}; }
> > run_ref();
>
> use strict;
> use PadWalker qw(peek_my); # from CPAN.
> my $sub_ref = sub { print ${peek_my(1)->{'$i'}}; };
> sub run_ref { my $i = 'Hello!'; &$sub_ref(); }
> run_ref();
>
> [untested]
AWESOME! Thanks benjy! :)
I'll look in to using this, or perhaps using the underlying concept. In any
case this is what I want... I think.
Aran
> $a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
> );{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
> ]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Sun, 23 Mar 2003 23:31:11 GMT
From: "Jodyman" <Jodyman@hotmail.com>
Subject: Re: currency number to text conversion
Message-Id: <3trfa.16086$pK4.1449944@newsread1.prod.itd.earthlink.net>
"Mike" <earthtrip@gmx.net> wrote in message
news:b5l7d9$2aedu1$1@ID-161707.news.dfncis.de...
> Cameron wrote:
> > Hello All --
> >
> > Has anyone run across a module that handles the conversion of currency
> > amounts - number to text string and visa versa. For example $500.00 ->
> > FIVE HUNDRED DOLLARS or FIVE HUNDRED DOLLARS -> $500.00. I've located
> > Delphi and VB routines, but nothing in PERL. Any pointers are greatly
> > appreciated.
> >
> > Cheers,
> > Cameron
> I will have a look for what you are searching. Please post the routines
> you´ve found in VB... I´m looking for that for months...
Public Function NumToString(ByVal nNumber As Currency) As String
Dim bNegative As Boolean
Dim bHundred As Boolean
If nNumber < 0 Then
bNegative = True
End If
nNumber = Abs(Int(nNumber))
If nNumber < 1000 Then
If nNumber \ 100 > 0 Then
NumToString = NumToString & _
NumToString(nNumber \ 100) & " hundred"
bHundred = True
End If
nNumber = nNumber - ((nNumber \ 100) * 100)
Dim bNoFirstDigit As Boolean
bNoFirstDigit = False
Select Case nNumber \ 10
Case 0
Select Case nNumber Mod 10
Case 0
If Not bHundred Then
NumToString = NumToString & " zero"
End If
Case 1: NumToString = NumToString & " one"
Case 2: NumToString = NumToString & " two"
Case 3: NumToString = NumToString & " three"
Case 4: NumToString = NumToString & " four"
Case 5: NumToString = NumToString & " five"
Case 6: NumToString = NumToString & " six"
Case 7: NumToString = NumToString & " seven"
Case 8: NumToString = NumToString & " eight"
Case 9: NumToString = NumToString & " nine"
End Select
bNoFirstDigit = True
Case 1
Select Case nNumber Mod 10
Case 0: NumToString = NumToString & " ten"
Case 1: NumToString = NumToString & " eleven"
Case 2: NumToString = NumToString & " twelve"
Case 3: NumToString = NumToString & " thirteen"
Case 4: NumToString = NumToString & " fourteen"
Case 5: NumToString = NumToString & " fifteen"
Case 6: NumToString = NumToString & " sixteen"
Case 7: NumToString = NumToString & " seventeen"
Case 8: NumToString = NumToString & " eighteen"
Case 9: NumToString = NumToString & " nineteen"
End Select
bNoFirstDigit = True
Case 2: NumToString = NumToString & " twenty"
Case 3: NumToString = NumToString & " thirty"
Case 4: NumToString = NumToString & " forty"
Case 5: NumToString = NumToString & " fifty"
Case 6: NumToString = NumToString & " sixty"
Case 7: NumToString = NumToString & " seventy"
Case 8: NumToString = NumToString & " eighty"
Case 9: NumToString = NumToString & " ninety"
End Select
If Not bNoFirstDigit Then
If nNumber Mod 10 <> 0 Then
NumToString = NumToString & "-" & _
Mid(NumToString(nNumber Mod 10), 2)
End If
End If
Else
Dim nTemp As Currency
nTemp = 10 ^ 12 'trillion
Do While nTemp >= 1
If nNumber >= nTemp Then
NumToString = NumToString & _
NumToString(Int(nNumber / nTemp))
Select Case Int(Log(nTemp) / Log(10) + 0.5)
Case 12: NumToString = NumToString & " trillion"
Case 9: NumToString = NumToString & " billion"
Case 6: NumToString = NumToString & " million"
Case 3: NumToString = NumToString & " thousand"
End Select
nNumber = nNumber - (Int(nNumber / nTemp) * nTemp)
End If
nTemp = nTemp / 1000
Loop
End If
If bNegative Then
NumToString = " negative" & NumToString
End If
End Function
Public Function DollarToString(ByVal nAmount As Currency) As _
String
Dim nDollar As Currency
Dim nCent As Currency
nDollar = Int(nAmount)
nCent = (Abs(nAmount) * 100) Mod 100
DollarToString = NumToString(nDollar) & " dollar"
If Abs(nDollar) <> 1 Then
DollarToString = DollarToString & "s"
End If
DollarToString = DollarToString & " and" & _
NumToString(nCent) & " cent"
If Abs(nCent) <> 1 Then
DollarToString = DollarToString & "s"
End If
End Function
------------------------------
Date: Mon, 24 Mar 2003 02:19:12 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: currency number to text conversion
Message-Id: <mbudash-E637CC.18191123032003@typhoon.sonic.net>
In article <3trfa.16086$pK4.1449944@newsread1.prod.itd.earthlink.net>,
"Jodyman" <Jodyman@hotmail.com> wrote:
> "Mike" <earthtrip@gmx.net> wrote in message
> news:b5l7d9$2aedu1$1@ID-161707.news.dfncis.de...
> > Cameron wrote:
> > > Hello All --
> > >
> > > Has anyone run across a module that handles the conversion of currency
> > > amounts - number to text string and visa versa. For example $500.00 ->
> > > FIVE HUNDRED DOLLARS or FIVE HUNDRED DOLLARS -> $500.00. I've located
> > > Delphi and VB routines, but nothing in PERL. Any pointers are greatly
> > > appreciated.
> > >
> > > Cheers,
> > > Cameron
> > I will have a look for what you are searching. Please post the routines
> > you´ve found in VB... I´m looking for that for months...
>
> Public Function NumToString(ByVal nNumber As Currency) As String
>
> Dim bNegative As Boolean
> Dim bHundred As Boolean
>
> If nNumber < 0 Then
> bNegative = True
> End If
>
> nNumber = Abs(Int(nNumber))
>
> If nNumber < 1000 Then
> If nNumber \ 100 > 0 Then
> NumToString = NumToString & _
> NumToString(nNumber \ 100) & " hundred"
> bHundred = True
> End If
> nNumber = nNumber - ((nNumber \ 100) * 100)
> Dim bNoFirstDigit As Boolean
> bNoFirstDigit = False
> Select Case nNumber \ 10
> Case 0
> Select Case nNumber Mod 10
> Case 0
> If Not bHundred Then
> NumToString = NumToString & " zero"
> End If
> Case 1: NumToString = NumToString & " one"
> Case 2: NumToString = NumToString & " two"
> Case 3: NumToString = NumToString & " three"
> Case 4: NumToString = NumToString & " four"
> Case 5: NumToString = NumToString & " five"
> Case 6: NumToString = NumToString & " six"
> Case 7: NumToString = NumToString & " seven"
> Case 8: NumToString = NumToString & " eight"
> Case 9: NumToString = NumToString & " nine"
> End Select
> bNoFirstDigit = True
> Case 1
> Select Case nNumber Mod 10
> Case 0: NumToString = NumToString & " ten"
> Case 1: NumToString = NumToString & " eleven"
> Case 2: NumToString = NumToString & " twelve"
> Case 3: NumToString = NumToString & " thirteen"
> Case 4: NumToString = NumToString & " fourteen"
> Case 5: NumToString = NumToString & " fifteen"
> Case 6: NumToString = NumToString & " sixteen"
> Case 7: NumToString = NumToString & " seventeen"
> Case 8: NumToString = NumToString & " eighteen"
> Case 9: NumToString = NumToString & " nineteen"
> End Select
> bNoFirstDigit = True
> Case 2: NumToString = NumToString & " twenty"
> Case 3: NumToString = NumToString & " thirty"
> Case 4: NumToString = NumToString & " forty"
> Case 5: NumToString = NumToString & " fifty"
> Case 6: NumToString = NumToString & " sixty"
> Case 7: NumToString = NumToString & " seventy"
> Case 8: NumToString = NumToString & " eighty"
> Case 9: NumToString = NumToString & " ninety"
> End Select
> If Not bNoFirstDigit Then
> If nNumber Mod 10 <> 0 Then
> NumToString = NumToString & "-" & _
> Mid(NumToString(nNumber Mod 10), 2)
> End If
> End If
> Else
> Dim nTemp As Currency
> nTemp = 10 ^ 12 'trillion
> Do While nTemp >= 1
> If nNumber >= nTemp Then
> NumToString = NumToString & _
> NumToString(Int(nNumber / nTemp))
> Select Case Int(Log(nTemp) / Log(10) + 0.5)
> Case 12: NumToString = NumToString & " trillion"
> Case 9: NumToString = NumToString & " billion"
> Case 6: NumToString = NumToString & " million"
> Case 3: NumToString = NumToString & " thousand"
> End Select
>
> nNumber = nNumber - (Int(nNumber / nTemp) * nTemp)
> End If
> nTemp = nTemp / 1000
> Loop
> End If
>
> If bNegative Then
> NumToString = " negative" & NumToString
> End If
>
> End Function
>
> Public Function DollarToString(ByVal nAmount As Currency) As _
> String
>
> Dim nDollar As Currency
> Dim nCent As Currency
>
> nDollar = Int(nAmount)
> nCent = (Abs(nAmount) * 100) Mod 100
>
> DollarToString = NumToString(nDollar) & " dollar"
>
> If Abs(nDollar) <> 1 Then
> DollarToString = DollarToString & "s"
> End If
>
> DollarToString = DollarToString & " and" & _
> NumToString(nCent) & " cent"
>
> If Abs(nCent) <> 1 Then
> DollarToString = DollarToString & "s"
> End If
>
> End Function
>
>
i have unsuccessfully looked around for a perl version of the above VB
code. i think many of us would like a perl module of this kind. so, i've
performed an initial conversion of the VB code to perl, with some
attempts at "perl-ize"-ing, streamlining, and localization. i've gone
over it and tested it, but i'd respectfully like to ask you folks to
critically review this V.01 code, looking for bugs, poor practices, etc.
sub NumToString {
my $nNumber = shift;
my $NumToString;
my %zeros = (
3 => 'thousand',
6 => 'million',
9 => 'billion',
12 => 'trillion',
);
my %numbers = (
0 => 'zero',
1 => 'one',
2 => 'two',
3 => 'three',
4 => 'four',
5 => 'five',
6 => 'six',
7 => 'seven',
8 => 'eight',
9 => 'nine',
10 => 'ten',
11 => 'eleven',
12 => 'twelve',
13 => 'thirteen',
14 => 'fourteen',
15 => 'fifteen',
16 => 'sixteen',
17 => 'seventeen',
18 => 'eighteen',
19 => 'nineteen',
20 => 'twenty',
30 => 'thirty',
40 => 'fourty',
50 => 'fifty',
60 => 'sixty',
70 => 'seventy',
80 => 'eighty',
90 => 'ninety',
100 => 'hundred',
);
my $bNegative;
my $bHundred;
if ($nNumber < 0) {
$bNegative++;
}
$nNumber = abs(int($nNumber));
if ($nNumber < 1000) {
if (int($nNumber/100) > 0) {
$NumToString .= NumToString(int($nNumber/100)) .
' ' . $numbers{100};
$bHundred++;
}
$nNumber -= ((int($nNumber/100)) * 100);
my $bNoFirstDigit;
my $tenths = int($nNumber/10);
my $modtenths = $nNumber % 10;
if ($tenths == 0) {
unless ($modtenths == 0 && $bHundred) {
$NumToString .= " $numbers{$modtenths}";
}
$bNoFirstDigit++;
}
elsif ($tenths == 1) {
$NumToString .= " $numbers{$modtenths + 10}";
$bNoFirstDigit++;
}
else {
$NumToString .= " $numbers{$tenths * 10}";
}
unless ($bNoFirstDigit) {
if ($nNumber % 10 != 0) {
$NumToString .= '-' . substr(NumToString($nNumber % 10), 1)
}
}
}
else {
my $nTemp = 10 ** 12;
while ($nTemp >= 1) {
if ($nNumber >= $nTemp) {
$NumToString .= NumToString(int($nNumber / $nTemp));
my $zeros = int(log($nTemp) / log(10) + 0.5);
$NumToString .= " $zeros{$zeros}";
$nNumber -= int($nNumber / $nTemp) * $nTemp;
}
$nTemp = $nTemp / 1000;
}
}
if ($bNegative) {
$NumToString = " negative$NumToString";
}
return $NumToString;
}
#-------------------------------------------------------------
sub DollarToString {
my $nAmount = shift;
my $nDollar = int($nAmount);
my $nCent = (abs($nAmount) * 100) % 100;
my $DollarToString = NumToString($nDollar) . 'dollar';
if (abs($nDollar) != 1) {
$DollarToString .= 's';
}
$DollarToString .= ' and' . NumToString($nCent) . ' cent';
if (abs($nCent) != 1) {
$DollarToString .= 's';
}
$DollarToString =~ s/^\s+//;
return $DollarToString;
}
--
Michael Budash
------------------------------
Date: Mon, 24 Mar 2003 05:01:47 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: currency number to text conversion
Message-Id: <3E7E910D.9050309@rochester.rr.com>
Cameron wrote:
...
> Has anyone run across a module that handles the conversion of currency
> amounts - number to text string and visa versa. For example $500.00 ->
> FIVE HUNDRED DOLLARS or FIVE HUNDRED DOLLARS -> $500.00. I've located
> Delphi and VB routines, but nothing in PERL. Any pointers are greatly
> appreciated.
...
> Cameron
>
Maybe
use Lingua::EN::Numbers;
or
use Lingua::EN::Numbers::Easy;
would help in the number-to-text direction? It looks like they need
some fixing up, but they might be a starting point.
--
Bob Walton
------------------------------
Date: 24 Mar 2003 00:32:08 GMT
From: ctcgag@hotmail.com
Subject: Re: doubts on \n
Message-Id: <20030323193208.831$pe@newsreader.com>
Benjamin Goldberg <goldbb2@earthlink.net> wrote:
> ctcgag@hotmail.com wrote:
> >
> > helgi@decode.is (Helgi Briem) wrote:
> >
> > > For myself, I wish the linefeed were standardised as so
> > > many things have been standardised lately, but I suppose
> > > that's a pipedream for now.
> >
> > I have lower standards. I just wish chomp would remove any OSs'
> > notion of a line-ending off the end, not just the OS it is running
> > under.
>
> Chomp (if not set to undef, or "", or a reference to a number) will
> always remove the contents of $/ from the end of its argument(s).
>
> What you *really* want is a way of setting $/ to match any OSs' notion
> of a line-ending -- in which case chomp would presumably DTRT.
Right, I think that that is what I really want. If $/ were to do regex,
then I think /\015?\012/ would do the right thing for me (I run perl under
Linux, but process files that were created under both unix and windows.)
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service New Rate! $9.95/Month 50GB
------------------------------
Date: Sun, 23 Mar 2003 21:56:23 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: doubts on \n
Message-Id: <3E7E73D7.B6BEC15E@earthlink.net>
ctcgag@hotmail.com wrote:
> Benjamin Goldberg wrote:
> > ctcgag@hotmail.com wrote:
[snip]
> > > I have lower standards. I just wish chomp would remove any OSs'
> > > notion of a line-ending off the end, not just the OS it is running
> > > under.
> >
> > Chomp (if not set to undef, or "", or a reference to a number) will
> > always remove the contents of $/ from the end of its argument(s).
> >
>> What you *really* want is a way of setting $/ to match any OSs'
>> notion of a line-ending -- in which case chomp would presumably DTRT.
>
> Right, I think that that is what I really want. If $/ were to do
> regex, then I think /\015?\012/ would do the right thing for me (I run
> perl under Linux, but process files that were created under both unix
> and windows.)
What happens if you do:
binmode( INPUT_FH, ":crlf" );
And have "\n" in $/ ?
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: 23 Mar 2003 23:25:22 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: grep and uninitialized value in concatenation
Message-Id: <slrnb7sgj2.dvl.abigail@alexandra.abigail.nl>
Michael Budash (mbudash@sonic.net) wrote on MMMCDXCI September MCMXCIII
in <URL:news:mbudash-C4AD21.14083723032003@typhoon.sonic.net>:
-- In article <BAA3E52A.5F4D%mstep@t-online.de>,
-- Marek Stepanek <mstep@t-online.de> wrote:
--
-- > On 23.03.2003 22:08 Uhr, in article
-- > slrnb7s8iu.dvl.abigail@alexandra.abigail.nl, "Abigail" <abigail@abigail.nl>
-- > wrote:
-- >
-- > > Marek Stepanek (mstep@t-online.de) wrote on MMMCDXCI September MCMXCIII
-- > > in <URL:news:BAA3C877.5E14%mstep@t-online.de>:
-- > > :: Hello, happy Perl-Coders,
-- > > ::
-- > > ::
-- > > :: have some complaining of my Perl:
-- > > ::
-- > > :: Use of uninitialized value in concatenation (.) at etc ...
-- > > ::
-- > > :: Perl does not like my grep-pattern, with some
-- > > ::
-- > > :: (optional )?(captured patterns)?
-- > > ::
-- > > :: while (<GLOBALRESULT_BAK_HTM>){
-- > > :: s/(ohne|mit)( Limit)( von )?(\d+)?/<SPAN
-- > > :: CLASS=\"wichtig\">$1<\/SPAN>$2$3<SPAN CLASS=\"wichtig\">$4<\/SPAN>/g;
-- > > :: print GLOBALRESULT_HTM;
-- > > :: }
-- > >
-- > >
-- > > If you have a subpattern of the form '(PAT)?', and there's no (sub)match
-- > > for PAT, the corresponding $NUM variable will be undefined.
-- > >
-- > >
-- > >
-- > > Abigail
-- >
-- >
-- > thank you Abigail and Steve for your prompt answers. So the grep pattern
-- > itself is ok, if I understood well? So I will put in
-- >
-- > no warnings 'uninitialized';
-- >
-- > like Steve suggested.
-- >
-- > greetings marek
--
-- that kind of warnings disabling always makes me nervous... just me, i
-- guess... i'd do something like this:
--
-- s{(ohne|mit)( Limit)( von )?(\d+)?}
-- {qq|<SPAN CLASS="wichtig">$1</SPAN>$2| .
-- ($3 || '') .
-- '<SPAN CLASS="wichtig">' .
-- ($4 || '') .
-- '</SPAN>'}e;
--
-- no warnings, correct results.
No warnings, *INCORRECT* results:
use strict;
use warnings;
$_ = "ohne Limit von 0";
s{(ohne|mit)( Limit)( von )?(\d+)?}
{qq|<SPAN CLASS="wichtig">$1</SPAN>$2| .
($3 || '') .
'<SPAN CLASS="wichtig">' .
($4 || '') .
'</SPAN>'}e;
print "$_\n";
__END__
<SPAN CLASS="wichtig">ohne</SPAN> Limit von <SPAN CLASS="wichtig"></SPAN>
Ooops. You lost the '0'.
I strongly prefer turning off warnings over a complex code-around, which
turns out to be incorrect. Simplicity often wins.
Abigail
--
print 74.117.115.116.32, 97.110.111.116.104.101.114.32,
80.101.114.108.32, 72.97.99.107.101.114.10;
------------------------------
Date: Mon, 24 Mar 2003 00:20:49 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: grep and uninitialized value in concatenation
Message-Id: <mbudash-87292D.16204823032003@typhoon.sonic.net>
In article <slrnb7sgj2.dvl.abigail@alexandra.abigail.nl>,
Abigail <abigail@abigail.nl> wrote:
> Michael Budash (mbudash@sonic.net) wrote on MMMCDXCI September MCMXCIII
> in <URL:news:mbudash-C4AD21.14083723032003@typhoon.sonic.net>:
> -- In article <BAA3E52A.5F4D%mstep@t-online.de>,
> -- Marek Stepanek <mstep@t-online.de> wrote:
> --
> -- > On 23.03.2003 22:08 Uhr, in article
> -- > slrnb7s8iu.dvl.abigail@alexandra.abigail.nl, "Abigail"
> -- > <abigail@abigail.nl> wrote:
> -- >
> -- > > Marek Stepanek (mstep@t-online.de) wrote on MMMCDXCI September
> MCMXCIII
> -- > > in <URL:news:BAA3C877.5E14%mstep@t-online.de>:
> -- > > :: have some complaining of my Perl:
> -- > > ::
> -- > > :: Use of uninitialized value in concatenation (.) at etc ...
> -- > > ::
> -- > > :: Perl does not like my grep-pattern, with some
> -- > > ::
> -- > > :: (optional )?(captured patterns)?
> -- > > ::
> -- > > :: while (<GLOBALRESULT_BAK_HTM>){
> -- > > :: s/(ohne|mit)( Limit)( von )?(\d+)?/<SPAN
> -- > > :: CLASS=\"wichtig\">$1<\/SPAN>$2$3<SPAN CLASS=\"wichtig\">$4<\/SPAN>/g;
> -- > > :: print GLOBALRESULT_HTM;
> -- > > :: }
> -- > >
> -- > >
> -- > > If you have a subpattern of the form '(PAT)?', and there's no
> -- > > (sub)match for PAT, the corresponding $NUM variable will be undefined.
> -- >
> -- > thank you Abigail and Steve for your prompt answers. So the grep pattern
> -- > itself is ok, if I understood well? So I will put in
> -- >
> -- > no warnings 'uninitialized';
> -- >
> -- > like Steve suggested.
> --
> -- that kind of warnings disabling always makes me nervous... just me, i
> -- guess... i'd do something like this:
> --
> -- s{(ohne|mit)( Limit)( von )?(\d+)?}
> -- {qq|<SPAN CLASS="wichtig">$1</SPAN>$2| .
> -- ($3 || '') .
> -- '<SPAN CLASS="wichtig">' .
> -- ($4 || '') .
> -- '</SPAN>'}e;
> --
> -- no warnings, correct results.
>
>
> No warnings, *INCORRECT* results:
>
> use strict;
> use warnings;
>
> $_ = "ohne Limit von 0";
>
> s{(ohne|mit)( Limit)( von )?(\d+)?}
> {qq|<SPAN CLASS="wichtig">$1</SPAN>$2| .
> ($3 || '') .
> '<SPAN CLASS="wichtig">' .
> ($4 || '') .
> '</SPAN>'}e;
>
> print "$_\n";
> __END__
> <SPAN CLASS="wichtig">ohne</SPAN> Limit von <SPAN CLASS="wichtig"></SPAN>
>
>
> Ooops. You lost the '0'.
damn
> I strongly prefer turning off warnings over a complex code-around, which
> turns out to be incorrect. Simplicity often wins.
even if my code-around was changed to be correct, it would only be more
complex, therefore i now agree. warnings are, after all, just that:
warnings, not errors.
thanks for watching!
--
Michael Budash
------------------------------
Date: Mon, 24 Mar 2003 05:05:50 +0100
From: Marek Stepanek <mstep@t-online.de>
Subject: Re: grep and uninitialized value in concatenation
Message-Id: <BAA442AE.5F77%mstep@t-online.de>
On 24.03.2003 1:20 Uhr, in article
mbudash-87292D.16204823032003@typhoon.sonic.net, "Michael Budash"
<mbudash@sonic.net> wrote:
> In article <slrnb7sgj2.dvl.abigail@alexandra.abigail.nl>,
> Abigail <abigail@abigail.nl> wrote:
>
>> snip
thank you all for your excellent input ! Its like oxygen for my sparrow
brain.
marek
______________________________________________________________________
___PODIUM_INTERNATIONAL_//_the_embassy_for_talented_young_musicians___
_______Marek_Stepanek__mstep_[at]_PodiumInternational_[dot]_de________
__________________http://www.PodiumInternational.de___________________
______________________________________________________________________
------------------------------
Date: Sun, 23 Mar 2003 21:50:35 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: How stable is 'Magic'?
Message-Id: <3E7E727B.3A21C3E8@earthlink.net>
Abigail wrote:
[snip]
> Is there a garantee the API will never change? Nope. But I don't think
> it will ever be marked as "this is never going to change". If perl6
> goes to production, both the language and the API will have changed
> radically.
Perl6 won't be written in C, as perl5 is. To say "will have changed
radically" is a ridiculous understatement.
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Sun, 23 Mar 2003 20:16:21 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: nms formmail with file upload
Message-Id: <slrnb7sqjl.3a6.tadmc@magna.augustmail.com>
Neil C <neilc252@yahoo.com> wrote:
> Here is the file
[snip nearly 2000 lines of code]
*plonk*
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 23 Mar 2003 20:15:01 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Possible Storable 2.06 bug with CODE refs that use modules
Message-Id: <3E7E5C15.6EC679C5@earthlink.net>
Nix wrote:
[snip]
> | my $code = sub { use POSIX qw (getuid); getuid; };
Try instead:
my $code = sub { use POSIX (); POSIX::getuid; };
[untested]
> | my $frozen = nfreeze ($code);
> |
> | print \thaw ($frozen)->();
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Mon, 24 Mar 2003 02:11:04 -0000
From: Rocco Caputo <troc@netrus.net>
Subject: Re: socket- and pseudo-tty-problem
Message-Id: <slrnb7sq9k.g9.troc@eyrie.homenet>
On Fri, 21 Mar 2003 12:46:24 +0100, Michael Pradel wrote:
> Hi,
>
> i am writing a kind of remote shell. Therefore a pseudo-tty is created with IO::Pty on the remote machine. In it the bash is started.
> Its output should be sent to the local machine using a tcp-connection.
> In the other direction, the local STDIN should be sent to the remote machine, which gives it to the pseudo-tty.
>
> That's my approach (sorry for the length):
[...]
> For testing you first have to start server.pl and after that client.pl.
>
> As you can (hopefully) see, it doesn't work really good. E.g. you have to press enter to see the first output (like user@hostname:~$) and using the mc you also have to press enter a lot of times when it shouldn't be necessary.
>
> I am happy about any ideas how it could work correctly. Thank you.
I think your terminal is probably in canonical mode. This means input
is processed by line, not character, so getc() only begins to read
characters once EOL is received.
2) eyrie:~% perl -wle 'while (1) { print ord getc(STDIN) }'
input
105
110
112
117
116
10
^C
There are ways to turn off canonical mode. Read about stty(1) and the
POSIX module.
There are programs to do this already. I have written one, and it's
available at http://poe.perl.org/?POE_Cookbook/Job_Server
Finally, you're in for a world of hurt if you let anyone with a telnet
client run a shell on your machine. Seriously consider using sshd
instead.
-- Rocco Caputo - troc@pobox.com - http://poe.perl.org/
------------------------------
Date: 23 Mar 2003 16:36:41 -0800
From: ivo.welch@anderson.ucla.edu (ivo welch)
Subject: Re: XML Parsing (PerlSAX): Improving error reporting
Message-Id: <5159bba2.0303231636.5e261320@posting.google.com>
I also need to determine where the parser is, even if there is no
error. That is I need perl variables that contain "line 5511, column
2, byte 132312" that I can call at any time in PerlSAX.
help appreciated.
/iaw
------------------------------
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 4751
***************************************