[23114] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5335 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 8 14:10:38 2003

Date: Fri, 8 Aug 2003 11:10:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 8 Aug 2003     Volume: 10 Number: 5335

Today's topics:
        Print - format /  presentation question <cvidal@att.com>
    Re: Print - format /  presentation question <mothra@nowhereatall.com>
    Re: Print - format /  presentation question <jwillmore@cyberia.com>
    Re: Print - format /  presentation question <graham@cs.man.ac.uk>
    Re: Return value of chomp, with alternate value in $/ <pinyaj@rpi.edu>
    Re: Return value of chomp, with alternate value in $/ <bigj@kamelfreund.de>
    Re: Return value of chomp, with alternate value in $/ <spamblock@junkmail.com>
        rpm filename parsing regex help (John)
    Re: rpm filename parsing regex help <simon@unisolve.com.au>
        undo the (?i) <jvandervloet@hotmail.com>
    Re: undo the (?i) <tassilo.parseval@rwth-aachen.de>
    Re: undo the (?i) <jvandervloet@hotmail.com>
    Re: undo the (?i) <tassilo.parseval@rwth-aachen.de>
    Re: undo the (?i) <jvandervloet@hotmail.com>
    Re: undo the (?i) <nobull@mail.com>
        Useless use of private variable in void context ... ? <grg@umn.edu>
        Win32-OLE excel cell reference. <spikey-wan@bigfoot.com>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 8 Aug 2003 09:18:20 -0400
From: "Chris Vidal" <cvidal@att.com>
Subject: Print - format /  presentation question
Message-Id: <bh07rm$f2g1@kcweb01.netnews.att.com>


This works fine

print "*" x 10;
print "\n";

But is there a way to print *'s then a newline in one line

print "*" x 10"\n"; doesnt work.

Tks


begin 666 cvidal.vcf
M0D5'24XZ5D-!4D0-"E9%4E-)3TXZ,BXQ#0I..CMC=FED86P-"D9..F-V:61A
M; T*14U!24P[4%)%1CM)3E1%4DY%5#IC=FED86Q 871T+F-O;0T*4D56.C(P
;,#,P.# X5#$S,3@R,%H-"D5.1#I60T%21 T*
`
end



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

Date: Fri, 8 Aug 2003 07:43:05 -0700
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: Print - format /  presentation question
Message-Id: <3f326806$1@usenet.ugs.com>

[snipped]
> print "*" x 10"\n"; doesnt work.
>
print "*" x10 . "\n";

Mothra




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

Date: Fri, 08 Aug 2003 14:43:55 GMT
From: James Willmore <jwillmore@cyberia.com>
Subject: Re: Print - format /  presentation question
Message-Id: <20030808104554.5c7da748.jwillmore@cyberia.com>

> This works fine
> 
> print "*" x 10;
> print "\n";
> 
> But is there a way to print *'s then a newline in one line
> 
> print "*" x 10"\n"; doesnt work.

Try:

print "*" x 10, "\n";

HTH

Jim


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

Date: 08 Aug 2003 15:10:43 +0100
From: Graham Gough <graham@cs.man.ac.uk>
Subject: Re: Print - format /  presentation question
Message-Id: <ttlptjgw87w.fsf@sphere.cs.man.ac.uk>

>>>>> "Chris" == Chris Vidal <cvidal@att.com> writes:

    Chris> print "*" x 10"\n"; doesnt work.

print "*" x 10, "\n"; 




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

Date: Fri, 8 Aug 2003 11:10:06 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: Return value of chomp, with alternate value in $/
Message-Id: <Pine.SGI.3.96.1030808110649.536528B-100000@vcmr-64.server.rpi.edu>

On Fri, 8 Aug 2003, David Oswald wrote:

>print chomp ( $test_string ) , "\n" ;
>
>I have used parenthesis to ensure that chomp is in scalar mode, not list
>mode.

I just need to clarify that no amount of parentheses you use will make a
function be called in scalar context.  (In fact, parentheses on the
left-hand side of an assignment cause the right-hand side to be in list
context, unless otherwise changed.)

The print() function expects to receive a list.  In your case, to make
chomp() get called in scalar context, you'd have needed to use the
concatenation operator instead of a comma to add the "\n", or else
explicitly used scalar():

  print chomp($test_string) . "\n";
  print scalar(chomp $test_string), "\n";

-- 
Jeff Pinyan            RPI Acacia Brother #734            2003 Rush Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: Fri, 08 Aug 2003 17:29:06 +0200
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: Return value of chomp, with alternate value in $/
Message-Id: <pan.2003.08.08.15.29.04.917294@kamelfreund.de>

Tassilo v. Parseval wrote at Fri, 08 Aug 2003 08:48:00 +0000:

> Ah, right, yes, when passed a list. I wonder whether I am the only one
> who finds chomp's return value rather useless. The only good thing about
> is that it can be used as a boolean.

Don't forget that it might be also very useful for an obfuscation coding
contest :D


Cheerio,
Janek


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

Date: Fri, 8 Aug 2003 09:46:11 -0700
From: "David Oswald" <spamblock@junkmail.com>
Subject: Re: Return value of chomp, with alternate value in $/
Message-Id: <vj7lage2b57n9a@corp.supernews.com>


"Jeff 'japhy' Pinyan" <pinyaj@rpi.edu> wrote in message
news:Pine.SGI.3.96.1030808110649.536528B-100000@vcmr-64.server.rpi.edu...
> On Fri, 8 Aug 2003, David Oswald wrote:
>
> >print chomp ( $test_string ) , "\n" ;
> >
> >I have used parenthesis to ensure that chomp is in scalar mode, not list
> >mode.
>
> I just need to clarify that no amount of parentheses you use will make a
> function be called in scalar context.  (In fact, parentheses on the
> left-hand side of an assignment cause the right-hand side to be in list
> context, unless otherwise changed.)

The Perldocs, if I recall, specify that if the paramater side of the chomp
call looks like a list, it will be processed as a list, and to use
parenthesis to clarify.  That's what I meant when I said "I haveused
parnthesis....."

In my own use of language, I mean the left side of the equation when I say
"list context" or "scalar context", and the paramater list when I say "list
mode" or "scalar mode".  I could have said, "I used parenthesis to ensure
that chomp didn't think that a list was being passed to it."

Dave


>
> The print() function expects to receive a list.  In your case, to make
> chomp() get called in scalar context, you'd have needed to use the
> concatenation operator instead of a comma to add the "\n", or else
> explicitly used scalar():
>
>   print chomp($test_string) . "\n";
>   print scalar(chomp $test_string), "\n";
>
> --
> Jeff Pinyan            RPI Acacia Brother #734            2003 Rush
Chairman
> "And I vos head of Gestapo for ten     | Michael Palin (as Heinrich
Bimmler)
>  years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead
Bye-Election
>  Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
>




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

Date: 8 Aug 2003 04:45:05 -0700
From: jgking@packetstorm.org (John)
Subject: rpm filename parsing regex help
Message-Id: <6d9df2eb.0308080345.2bf7dba3@posting.google.com>

I am trying to write a tool to help me synchronize newer redhat rpms
so i can burn updated cds instead of doing it manually.

The current pattern I use matches the majority from which i dump it
into a hashtable. The lhs would be the filename and the rhs would be
the version number.

/^([a-zA-Z\-\_]+)([0-9a-zA-Z\.\-]+)\.[a-z0-9|a-z]+\.rpm/ )

Although this matches the filename patterns for the rpms, there is one
case I have not been able to figure out

ko2-fonts-0.3.9b-16.9 for example.

The issue is that the pattern splits up ko2-fonts to ko
2-fonts-0.3.9b-16.9

Is there a solution for parsing rpm filenames somewhere or would
someone better at regexs help me with this?

thanks

Greg


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

Date: Sat, 09 Aug 2003 00:41:09 +1000
From: Simon Taylor <simon@unisolve.com.au>
Subject: Re: rpm filename parsing regex help
Message-Id: <3F33B685.9080602@unisolve.com.au>

Hello John, or Greg, or whoever you are ;-)

> Is there a solution for parsing rpm filenames somewhere or would
> someone better at regexs help me with this?

This may turn out to be a non-trivial exercise. I just ran through
the rpm package names on my Red Hat machine and I noticed many
packages that contained revision-like numbers in the name portion,
and some even that contained whole words in the 'revision' part of
the name.

Consider filtering the output of the rpm "-i" flag, (eg: rpm -qai)
and look for lines starting with "Name" "Version" and "Release".
That way, the rpm system itself can tell you the name and revision
unambiguously.

Hope this helps.

- Simon Taylor




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

Date: Fri, 08 Aug 2003 10:49:22 GMT
From: "joeri" <jvandervloet@hotmail.com>
Subject: undo the (?i)
Message-Id: <SeLYa.55197$F92.6598@afrodite.telenet-ops.be>

Hi all,

I have an RE where I use the (?i) somewhere, but I want to undo that effect
further on in the RE.
Here's an example:

$var="(?i)(forty|fifty)";
$input = "Forty-ninth ST";
if ($input =~ /$var(\-ninth)\s[S|s]t/) {
    print "$&\n";
}

Because the $var contains the (?i), it matches the rest of the RE
case-insensitively, but I want
to match everything after the $var case-sensitively. Can I escape the ($i)
or set the scope of it?

Thanks,

J




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

Date: 8 Aug 2003 11:02:05 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: undo the (?i)
Message-Id: <bgvvvd$4iu$1@nets3.rz.RWTH-Aachen.DE>

Also sprach joeri:

> I have an RE where I use the (?i) somewhere, but I want to undo that effect
> further on in the RE.
> Here's an example:
> 
> $var="(?i)(forty|fifty)";
> $input = "Forty-ninth ST";
> if ($input =~ /$var(\-ninth)\s[S|s]t/) {
>     print "$&\n";
> }
> 
> Because the $var contains the (?i), it matches the rest of the RE
> case-insensitively, but I want
> to match everything after the $var case-sensitively. Can I escape the ($i)
> or set the scope of it?

You can again turn it off at some point:

    $input =~ /$var(?-i)(-ninth)\s[S|s]t/;

So, -i will prevent case-insensitive matching for the patterns right of
it.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Fri, 08 Aug 2003 11:05:55 GMT
From: "joeri" <jvandervloet@hotmail.com>
Subject: Re: undo the (?i)
Message-Id: <nuLYa.55225$F92.6552@afrodite.telenet-ops.be>

Tassilo v. Parseval wrote:

> > I have an RE where I use the (?i) somewhere, but I want to undo that
effect
> > further on in the RE.
> > Here's an example:
> >
> > $var="(?i)(forty|fifty)";
> > $input = "Forty-ninth ST";
> > if ($input =~ /$var(\-ninth)\s[S|s]t/) {
> >     print "$&\n";
> > }
> >
> > Because the $var contains the (?i), it matches the rest of the RE
> > case-insensitively, but I want
> > to match everything after the $var case-sensitively. Can I escape the
($i)
> > or set the scope of it?
>
> You can again turn it off at some point:
>
>     $input =~ /$var(?-i)(-ninth)\s[S|s]t/;
>
> So, -i will prevent case-insensitive matching for the patterns right of
> it.
>
> Tassilo

Thanks! I couldn't find it in the docs or google.

Cheers,
J




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

Date: 8 Aug 2003 11:27:51 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: undo the (?i)
Message-Id: <bh01fn$61g$1@nets3.rz.RWTH-Aachen.DE>

Also sprach joeri:

> Tassilo v. Parseval wrote:
> 
>> > I have an RE where I use the (?i) somewhere, but I want to undo
>> > that effect further on in the RE.
>> > Here's an example:
>> >
>> > $var="(?i)(forty|fifty)";
>> > $input = "Forty-ninth ST";
>> > if ($input =~ /$var(\-ninth)\s[S|s]t/) {
>> >     print "$&\n";
>> > }
>> >
>> > Because the $var contains the (?i), it matches the rest of the RE
>> > case-insensitively, but I want to match everything after the $var
>> > case-sensitively. Can I escape the ($i) or set the scope of it?
>>
>> You can again turn it off at some point:
>>
>>     $input =~ /$var(?-i)(-ninth)\s[S|s]t/;
>>
>> So, -i will prevent case-insensitive matching for the patterns right of
>> it.

> Thanks! I couldn't find it in the docs or google.

You'll find it in perlre.pod under "Extended patterns":

    "(?imsx-imsx)"
              One or more embedded pattern-match modifiers, to be turned on
              (or turned off, if preceded by "-") for the remainder of the
              pattern or the remainder of the enclosing pattern group (if
              any). [...]

It can indeed be easily overlooked.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Fri, 08 Aug 2003 11:40:13 GMT
From: "joeri" <jvandervloet@hotmail.com>
Subject: Re: undo the (?i)
Message-Id: <x_LYa.55271$F92.6533@afrodite.telenet-ops.be>


Tassilo v. Parseval wrote:

> Also sprach joeri:
>
> > Tassilo v. Parseval wrote:
> >
> >> > I have an RE where I use the (?i) somewhere, but I want to undo
> >> > that effect further on in the RE.
> >> > Here's an example:
> >> >
> >> > $var="(?i)(forty|fifty)";
> >> > $input = "Forty-ninth ST";
> >> > if ($input =~ /$var(\-ninth)\s[S|s]t/) {
> >> >     print "$&\n";
> >> > }
> >> >
> >> > Because the $var contains the (?i), it matches the rest of the RE
> >> > case-insensitively, but I want to match everything after the $var
> >> > case-sensitively. Can I escape the ($i) or set the scope of it?
> >>
> >> You can again turn it off at some point:
> >>
> >>     $input =~ /$var(?-i)(-ninth)\s[S|s]t/;
> >>
> >> So, -i will prevent case-insensitive matching for the patterns right of
> >> it.
>
> > Thanks! I couldn't find it in the docs or google.
>
> You'll find it in perlre.pod under "Extended patterns":
>
>     "(?imsx-imsx)"
>               One or more embedded pattern-match modifiers, to be turned
on
>               (or turned off, if preceded by "-") for the remainder of the
>               pattern or the remainder of the enclosing pattern group (if
>               any). [...]
>
> It can indeed be easily overlooked.
>

Here's what my 5.6 docs say. It is indeed there, but I overlooked it...

(?imsx-imsx)
One or more embedded pattern-match modifiers. This is particularly useful
for dynamic patterns, such as those read in from a configuration file, read
in as an argument, are specified in a table somewhere, etc. Consider the
case that some of which want to be case sensitive and some do not. The case
insensitive ones need to include merely (?i) at the front of the pattern.
For example:
    $pattern = "foobar";
    if ( /$pattern/i ) { }    # more flexible:    $pattern = "(?i)foobar";
    if ( /$pattern/ ) { }Letters after a - turn those modifiers off.

J




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

Date: 08 Aug 2003 13:13:25 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: undo the (?i)
Message-Id: <u9he4suz2y.fsf@wcl-l.bham.ac.uk>

"joeri" <jvandervloet@hotmail.com> writes:

> $var="(?i)(forty|fifty)";
> $input = "Forty-ninth ST";
> if ($input =~ /$var(\-ninth)\s[S|s]t/) {
>     print "$&\n";
> }

> Can I escape the ($i) or set the scope of it?

/(?:$var)(\-ninth)\s[S|s]t/


-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 8 Aug 2003 13:02:36 -0500
From: "George R. Gonzalez" <grg@umn.edu>
Subject: Useless use of private variable in void context ... ?
Message-Id: <bh0ojq$n17$1@lenny.tc.umn.edu>



I get:
Useless use of private variable in void context at b.pl line 588,
which is the last line of this sub, '$A", the returned value.

The weird thing is this has been working fine for weeks,
now it starts to complain!

Any ideas?



sub LookForDirLo{ my( $pat, $Base ) = @_;  my( @D, $f, $fn, $A );
 $A = '';
    ##print "lookfordirlo of '$Base'\n";
 if( $Base =~ /$pat/i ) { $A = $Base;  print "Setting A to '$A'" }
 else {
 if( -d $Base ) {
  if( -r $Base ) {
   if( opendir( DIR, $Base ) ) {
    @D = readdir( DIR ); closedir( DIR );
    if( scalar @D == 0  ) { Warn "Empty directory info returned for
'$Base'" }

    foreach $f ( @D ) {
      if( $A eq '' ) {
     if( $f eq '.' or $f eq '..' ) { }
     else {
      $fn = "$Base\\$f";
      if( -d $fn ) { $A = LookForDirLo( $pat, $fn ) }
     }
      }
    }

   }
   else { Warn "opendir failed: Cant grovel in folder '$Base', System said:
'$!'" }
  } else { Warn "LookForDirLo found that '$Base' is not readable!" }
 } else { Warn "LookForDirLo found that '$Base' is not a directory!" }
$A;
}





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

Date: Fri, 8 Aug 2003 11:56:39 +0100
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: Win32-OLE excel cell reference.
Message-Id: <bgvvnl$k1c$1@newshost.mot.com>

Guys,

I'm struggling with the syntax to point to the cells that I want to use in
Excel.

It seems that the Range command likes data like (A14), or (A14:B26), and I
am happy with this.

My problem occurrs when I only have numeric data to work with, because of
incremented counters, or Count commands.

I have had success with Cells(1,14), but I cannot for the life of me work
out how to reference an area of cells like this...

Cells(1,14:5,28)

Can anyone help me with the correct syntax, please?

Thanks.

R.




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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

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


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