[19181] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1376 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 25 14:05:59 2001

Date: Wed, 25 Jul 2001 11:05:10 -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: <996084310-v10-i1376@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 25 Jul 2001     Volume: 10 Number: 1376

Today's topics:
        bitwise operations <lhswartw@ichips.intel.com>
    Re: Directory Diff <swan@peak2peak.com>
        dynamically resizing pictures for a web page <danield@life.uiuc.edu>
    Re: FAQ: Why aren't my random numbers random? <andras@mortgagestats.com>
    Re: FAQ: Why aren't my random numbers random? <tsee@gmx.net>
    Re: Frustrated people (not) answering questions (JR)
    Re: How to redirect a user ? <alexis.roda@si.urv.es>
        IP address incorrect by $ENV{'REMOTE_ADDR'} <peter.cch@mailexcite.com>
    Re: Java applet in perl? <paul.johnston@dsvr.co.uk>
    Re: kill idle user using unix w <gerard@NOSPAMlanois.com>
    Re: Multi tuple hashes <bkennedy99@Home.com>
    Re: newbie semantic (non-code) question -"what the pros <jeff@vpservices.com>
        Please review the following code for ejecting tapes fro (Drew Myers)
        Reading ASP Session obj. vars via Perl? <confused@times.doh>
    Re: Reading ASP Session obj. vars via Perl? <carlos@plant.student.utwente.nl>
    Re: regex question - sort of - how to count if the stri <paul.johnston@dsvr.co.uk>
    Re: regex question - sort of - how to count if the stri (Yves Orton)
    Re: Regular Expression Reduction (Moonshiner)
        Regular Expression <osbornelee@hotmail.com>
    Re: Regular Expression <jeff@vpservices.com>
    Re: Regular Expression <holland@origo.ifa.au.dk>
    Re: Regular Expression <godzilla@stomp.stomp.tokyo>
    Re: Regular expressions... (Yves Orton)
        Self-Searchable Perl documention - Extremely Useful! (John Holdsworth)
    Re: Self-Searchable Perl documention - Extremely Useful <jeff@vpservices.com>
    Re: sizes of strings in Activeperl ? (Jan)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 25 Jul 2001 10:19:27 -0700
From: "Swanthog" <lhswartw@ichips.intel.com>
Subject: bitwise operations
Message-Id: <9jmv30$hmp@news.or.intel.com>

Greetings all,

I have 4 variables each of which will be set to logic level 1 or 0. I then
want to use those 4 variables to create a 4 bit vector and compare against
the 16 possible combinations. I have managed to do this but I don't like the
solution.

Is there a better way?

Thanks,
Larry S.

# The 4 variables as described above. The test pattern is decimal 5.
$var_0 = 1;
$var_1 = 0;
$var_2 = 1;
$var_3 = 0;

# The sixteen possible combinations to compare against.
$b_0 = pack("b4", "0000");
$b_1 = pack("b4", "0001");
$b_2 = pack("b4", "0010");
$b_3 = pack("b4", "0011");
$b_4 = pack("b4", "0100");
$b_5 = pack("b4", "0101");
$b_6 = pack("b4", "0110");
$b_7 = pack("b4", "0111");
$b_8 = pack("b4", "1000");
$b_9 = pack("b4", "1001");
$b_a = pack("b4", "1010");
$b_b = pack("b4", "1011");
$b_c = pack("b4", "1100");
$b_d = pack("b4", "1101");
$b_e = pack("b4", "1110");
$b_f = pack("b4", "1111");

# Create a vector of 4 bits using the 4 variables
vec( $status, 3, 1) = $var_0;
vec( $status, 2, 1) = $var_1;
vec( $status, 1, 1) = $var_2;
vec( $status, 0, 1) = $var_3;

# Do the comparison
print "Bits in status: ";
$status = unpack("b4", $status);
if( $status == unpack("b4", $b_0)) {
 print "0\n";
} elsif( $status == unpack("b4", $b_1)) {
 print "1\n";
} elsif( $status == unpack("b4", $b_2)) {
 print "2\n";
} elsif( $status == unpack("b4", $b_3)) {
 print "3\n";
} elsif( $status == unpack("b4", $b_4)) {
 print "4\n";
} elsif( $status == unpack("b4", $b_5)) {
 print "5\n";
} elsif( $status == unpack("b4", $b_6)) {
 print "6\n";
} elsif( $status == unpack("b4", $b_7)) {
 print "7\n";
} elsif( $status == unpack("b4", $b_8)) {
 print "8\n";
} elsif( $status == unpack("b4", $b_9)) {
 print "9\n";
} elsif( $status == unpack("b4", $b_a)) {
 print "a\n";
} elsif( $status == unpack("b4", $b_b)) {
 print "b\n";
} elsif( $status == unpack("b4", $b_c)) {
 print "c\n";
} elsif( $status == unpack("b4", $b_d)) {
 print "d\n";
} elsif( $status == unpack("b4", $b_e)) {
 print "e\n";
} elsif( $status == unpack("b4", $b_f)) {
 print "f\n";
} else {
 print "Fell through. Status is $status\n";
}






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

Date: Wed, 25 Jul 2001 16:27:10 GMT
From: "Ross" <swan@peak2peak.com>
Subject: Re: Directory Diff
Message-Id: <3b5efbaf@news.peakpeak.com>

Thanks,
You guys, comp.lang.perl are the best.
--Ross

"Matt Christian" <mattc@visi.com> wrote in message news:87puaplx6v.fsf@powerhouse.boogie.cx...
Ross,

> I've done a backup on a UNIX directory
> to a temporary location and I'd like to find
> the files that have been changed from my
> current version of the directory. Has anyone
> written a utility to do this? What makes it a
> little tricky is that the directory has many sub-
> directories.

Yes, Paul Mackerras has written dirdiff which does
exactly what you want, it runs in X and requires TCL/TK.
The subdirectories shouldn't be a problem...

dirdiff CVSWeb (download the current/unstable version):
http://samba.org/cgi-bin/cvsweb/dirdiff/

dirdiff FTP site (download the stable version):
ftp://ftp.samba.org/pub/paulus/

Thanks,

Matt

--
Matt Christian - mattc@visi.com
http://www.visi.com/~mattc/
ftp://ftp.visi.com/users/mattc/
Learn to love and love to learn.




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

Date: Wed, 25 Jul 2001 12:42:12 -0500
From: Daniel Davidson <danield@life.uiuc.edu>
Subject: dynamically resizing pictures for a web page
Message-Id: <3B5F04F3.49405263@life.uiuc.edu>

All right here is the problem.  I need to be able to take a 4MP photo
and resize it so that people on slower connections dont have to leave
their computer running at night to view one of them.  Sounds simple,
just run imagemagick and resize to something smaller (~800x600).
However at the same time, I have people on the higher end who want to
see the full size to do publications.  And with the quantity of photos
we will be handeling, storing both is not an option (well, that is what
I was told anyway).  The best solution would be to resize the image with
imagemagick, then let the server get the resized picture.  The only way
I can think of how to do this is to have a temporary - resized image
that the browser uses to load the picture.  However when I think of the
problems that I will run into by doing it this way, I start to go nuts.
Anyone know of a way to display directly from the servers memory or some
other better way?

thanks,

Dan



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

Date: Wed, 25 Jul 2001 10:14:07 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: FAQ: Why aren't my random numbers random?
Message-Id: <3B5ED42E.2201E7C4@mortgagestats.com>



"Steffen Müller" wrote:

> "Andras Malatinszky" <andras@mortgagestats.com> schrieb im Newsbeitrag
> news:3B5E1491.2E8F8051@mortgagestats.com...
> >
> >
> > PerlFAQ Server wrote:
> >
> > >Don't call "srand" more than once--you make your numbers less random,
> rather
> > than  more.
> >
> > Why is that?
>
> Read the man pages.

I did, a couple of weeks ago, and that's when the question first occurred to me
(and, let me add, your quote didn't answer it). I can see why reseeding rand( )
would not make my random numbers more random, but why it would make them less
random is not obvious to me..

>

>
>
> From perlfunc: "The point of the function is to ``seed'' the rand() function
> so that rand() can produce a different sequence each time you run your
> program."
>
> Cheers,
> Steffen Müller



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

Date: Wed, 25 Jul 2001 18:20:06 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: FAQ: Why aren't my random numbers random?
Message-Id: <9jmrc1$pmm$00$1@news.t-online.com>

"Andras Malatinszky" <andras@mortgagestats.com> schrieb im Newsbeitrag
news:3B5ED42E.2201E7C4@mortgagestats.com...

[snip]

> I did, a couple of weeks ago, and that's when the question first occurred
to me
> (and, let me add, your quote didn't answer it). I can see why reseeding
rand( )
> would not make my random numbers more random, but why it would make them
less
> random is not obvious to me..

I'm sorry in case my answer seemed unfriendly. It was not intended to be.
The quote didn't quite answer your question but maybe pointed in the right
direction:
You would introduce some form of (trying to think of an english
expression...) redundancy (!?) to the "randomness" of the numbers. AFAIK,
such things give rise to possibilities to guess the numbers.

That's all I can tell you about this.

Steffen




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

Date: 25 Jul 2001 06:46:44 -0700
From: tommyumuc@aol.com (JR)
Subject: Re: Frustrated people (not) answering questions
Message-Id: <319333f5.0107250546.4bd1969f@posting.google.com>

My advice is to just ignore the `sarcastic` responses.  I've several
times submitted questions to this newsgroup, and some of them were not
responded to kindly.  Yet, other times I have received very helpful
responses.  I think we just have to take the good with the bad and
realize that the longer we're at this, the better we will become. 
Once those of us that are now novices become experts, we should
remember that we too were once beginners and try to treat with respect
questions by novices so that we don't propagate the
sometimes-contemporary prevalent attitude of certain megalomaniacs
that harshly respond to this newsgroup.


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

Date: Wed, 25 Jul 2001 15:07:52 +0200
From: Alexis Roda <alexis.roda@si.urv.es>
Subject: Re: How to redirect a user ?
Message-Id: <3B5EC4A8.4ABCB1D1@si.urv.es>

Ciric Vukasin wrote:
> 
> Is that going to work in PHP ?

That's perl, not php. Redirecting is a matter of printing some header.
Write a simple scrip with perl to redirect the user to some page, run it
interactively from the command line and see what kind of header prints,
then translate this to php or whatever language you like.



HTH
-- 
                                  ////
                                 (@ @)
---------------------------oOO----(_)----OOo------------------------
        Los pecados de los tres mundos desapareceran conmigo.
Alexis Roda - Universitat Rovira i Virgili - Reus, Tarragona (Spain)
--------------------------------------------------------------------


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

Date: Thu, 26 Jul 2001 00:58:53 +0800
From: "Peter Chan" <peter.cch@mailexcite.com>
Subject: IP address incorrect by $ENV{'REMOTE_ADDR'}
Message-Id: <3b5efa14.0@news.tm.net.my>

I'm using Perl to write CGI, but I encounter some problem on the IP address.

I'm using the environment variable, $ENV{'REMOTE_ADDR'} to print the
address, but what i get is 127.0.0.1, which is local PC IP.

Then I try access the CGI in different place, Cyber cafe, CIT room, My
house, my friend house, but what i get is still the same .... is 127.0.0.1

So, may i know what is the problem ?

This is the statement that i use:

print "IP = $ENV{'REMOTE_ADDR'}";


all the result i get is:
127.0.0.1
127.0.0.1
127.0.0.1
127.0.0.1
127.0.0.1
127.0.0.1
 .
 .
 .
 .

Can i know what is the problem ?
How can I make correction on it, so that I can get some IP like 202.133.0.5


Thanks for helping.

By Peter








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

Date: Wed, 25 Jul 2001 14:25:03 +0100
From: Paul Johnston <paul.johnston@dsvr.co.uk>
Subject: Re: Java applet in perl?
Message-Id: <3B5EC8AF.8FC4AFD9@dsvr.co.uk>

Hi,

> does anybody know how to run a java applet in perl?

Assuming you have java installed, you can run a java program like:

  system('/usr/bin/java', 'program.class');

Or use backticks or pipes if you want to capture output or send input.

An applet is a specific type of java program, which can only run inside
a browser or something pretending to be a browser. appletviewer is part
of the JDK for running applets, which you can run from Perl in a similar
way to the above.

Paul


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

Date: 25 Jul 2001 09:52:55 -0700
From: Gerard Lanois <gerard@NOSPAMlanois.com>
Subject: Re: kill idle user using unix w
Message-Id: <u1yn554t4.fsf@NOSPAMlanois.com>

"eric leung" <eric.leung@philips.com> writes:

> Hi
> I want using unix command "w" and those users idle more than 30 minutes
> without change on JCPU time.
> How to write perl ?
> /home/eric>w
> 
> 9:11am up 2 day(s), 2:34, 11 users, load average: 4.59, 4.34, 3.94
> 
> User tty login@ idle JCPU PCPU what

Wouldn't it be easier to have the users set up their shells
to automatically logout at 30 minutes?

In tcsh and csh, this is called "autologout".

In bash it is called "TMOUT".

-Gerard


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

Date: Wed, 25 Jul 2001 13:44:34 GMT
From: "Ben Kennedy" <bkennedy99@Home.com>
Subject: Re: Multi tuple hashes
Message-Id: <63A77.27215$EP6.6845683@news1.rdc2.pa.home.com>


"Paul" <pa_watts@hotmail.com> wrote in message
news:e6007a72.0107250401.2fd57272@posting.google.com...
> The following code produces FooBar
>
> $areas{1}{A} = 1;
> $areas{2}{A} = 1;
>
> $areas{1}{A}{2} = "Foo";
> print $areas{1}{A}{2};
> $areas{2}{A}{2} = "Bar";
> print $areas{1}{A}{2};
>
> I expected FooFoo (why should $areas{2} have any bearing on {1}?). If
> anyone can explain, I would be very grateful.

This is a great example of why using 'strict' is good, as it tells you that
you can't use "1" as a symbolic ref on the "Foo" assignment line.  You can
verify this by looking at %areas with Data::Dumper, which doesn't contain
Foo or Bar.  These elements however will be found in the hash "%1".  Maybe
someone can correct me on this, but what appears to be happening is that
when the assignment to $areas{1}{A}{2} is made, Perl first tries to
dereference $areas{1}{A} - but this only has a string.  But since strict
wasn't in effect, Perl doesn't give up and uses the string as a soft
reference to the global hash %1.  Hope this helps--

--Ben Kennedy






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

Date: Wed, 25 Jul 2001 08:57:07 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: newbie semantic (non-code) question -"what the pros call it" [OT]
Message-Id: <3B5EEC53.D7BF77E5@vpservices.com>

Jason Goodrow wrote:
> 
> For instance: Say I have a bunch of data serverside that's going to the
> client - I put the data in a '_' delimited string so my client-app can
> say @array = split string on '_' - (psuedo not perl code)

Well, I ain't a pro (in the sense of being an expert), but those who are
picky would stop you right there and say:  yours is not an
underscore-delimited string, this is an underscore-delimited string: 
_foo,bar,baz_.  And this is an underscore-terminated sting:
foo,bar,baz_.  And what you are describing is an underscore-separated
string: foo_bar_baz.  (Think CSV = comma *separated* values).

> now say my array elements are all '**' delimited so each @array => split
> '**' into more arrays.

Not sure, but I believe you are describing what might be called an
underscore-separated string containing embedded
double-asterisk-separated strings?  foo_alpha**bravo**charlie_bar.   But
maybe you are just talking about using double asterisks instead of
underscores.

> Now I have to decide for client server reasons how dense I want to make
> the incoming data - say 100 items each a 1k array.
> Do I send these at once in one big string or one at a time.

That's the part you are probably asking about, and sorry, though I've
done that and dealt with that issue many, many times, I don't have the
slightest idea what it would be called, though it certainly relates to
an issue I would label "granularity".

But I don't have any formal CS background, just a couple of 
anthro/linguistics degrees and 15+ years of getting paid to program
(which I suppose makes me a pro in the other sense of that word).

The [OT] I inserted into the subject line of this thread stands for "Off
Topic", as your question certainly is (the answers would be the same for
other languages than perl).  But there is a difference between "off
topic" and "uninteresting". :-)

-- 
Jeff



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

Date: 25 Jul 2001 06:45:40 -0700
From: bh_ent@hotmail.com (Drew Myers)
Subject: Please review the following code for ejecting tapes from an HP 85597A Sure Store E
Message-Id: <d1b6a249.0107250545.3d75938f@posting.google.com>

My objective with this script is to eject multiple tapes from the
Media Pool (the general holding area in the Tape Library) into the Cap
(the section where you remove the tapes).

A brief rundown on the Tape Silo commands:

"/opt/omni/bin/omnirpt -report used_media -timeframe 24 24" is used to
determine the tapes that have been used in the last 24 hours.

"/opt/omni/lbin/uma -ioctl /dev/scsi/robot4 -barcode" is used to start
the interactive menu with the tape library's robot arm.

"stat d" in the interactive menu provides the status of the drives
(i.e., what tapes are in the drives, currently being written to).

"stat x" in the interactive menu provides the status of the CAP (i.e.,
what tapes are in the area for removal).

There are 20 drives, and 20 slots in the CAP.

This means the "stat d" and "stat x" commands will return 20 lines.

What I want to do (I know it took me long enough).  I want to get a
list of tapes to be ejected (this could, quite probably, be more than
20).  Remove the tapes that are currently in use from the list (via
the "stat d" command), eject as many tapes into the CAP as there are
room for, and wait to eject the remaining round(s) of tapes after the
CAP has been emptied.

I've figured out writing to and retrieving data from the interactive
prompt (via open2), as well as getting all the data I need from the
actual outputs.  My main concern is the logic and the data structures
that are used.  I'm also curious as to a good method to eject more
than 20 tapes (obviously only 20 can be ejected at a time).

Thanks for any help, and here's the code:


#!/opt/perl5/bin/perl -w
use strict;
use IPC::Open2;

# Determine day of week (Monday has several tape batches, Tues-Fri
have 1 batch)
my $dayofweek = ("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
[(localtime)[6]];

# Get list of tapes to be ejected
open (TAPES,"/opt/omni/bin/omnirpt -report used_media  -timeframe 24
24 |") ||
die "Can't open omnireport: $!\n";
my %tapecap;
while (<TAPES>) {
  if (/TO_DESTROY/) { next; }
  if (/(R\D\d+).*:\s+(\d+)/gm) {
    $tapecap{$2}=$1;
  }
}

my @tapesindrives;
&GetTapesinDrives;

foreach my $tapes (@tapesindrives) {
  for (keys %tapecap) { 
    if ($tapes eq $tapecap{$_} ) {
      delete $tapecap{$_};
    }
  } 
}  

my @slot;
&GetEmptyCapSlot;
my $count=0;
for (keys %tapecap) { 
  for my $slot (@slot) {
  &open2( \*Reader,\*Writer,"/opt/omni/lbin/uma -ioctl /dev/scsi/robot
-barcode");
    eval { print Writer "move s$_ $slot\n"; };
    if ($@) { 
      print "Cap appears to be open, will try again in 5 minutes.\n";
      sleep 300; 
    }
  }
  close (Writer) || die "Can't close Writer: $!\n";
}

sub GetTapesinDrives {
  &open2( \*Reader,\*Writer,"/opt/omni/lbin/uma -ioctl /dev/scsi/robot
-barcode");
  print Writer "stat d\nquit\n";
  close (Writer) || die "Can't close Writer: $!\n";
  while (<Reader>) { 
    if (/"(R\D\d+)"/) {
      my $tapesindrives=$1;
      push @tapesindrives,$tapesindrives;
    }
  }
  return @tapesindrives;
}

sub GetEmptyCapSlot {
  &open2( \*Reader,\*Writer,"/opt/omni/lbin/uma -ioctl /dev/scsi/robot
-barcode");
  print Writer "stat x\nquit\n";
  close (Writer) || die "Can't close Writer: $!\n";
  while (<Reader>) { 
    if (/\d+\s+(X\d+)\s+Empty/) {
      my $slot=$1;
      push @slot,$slot;
    }
  }
  return \@slot;
}


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

Date: Wed, 25 Jul 2001 14:56:52 GMT
From: Confused @ Times <confused@times.doh>
Subject: Reading ASP Session obj. vars via Perl?
Message-Id: <MPG.15c88c256d8bb801989683@news.telusplanet.net>

Does anyone know if it's possible to read an ASP Session Objects 
variables from Perl?

If so, how?  TIA.


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

Date: Wed, 25 Jul 2001 17:46:15 +0200
From: "carlos" <carlos@plant.student.utwente.nl>
Subject: Re: Reading ASP Session obj. vars via Perl?
Message-Id: <9jmpk8$5p5$1@dinkel.civ.utwente.nl>

rtf activestate manual

"Confused @ Times" <confused@times.doh> wrote in message
news:MPG.15c88c256d8bb801989683@news.telusplanet.net...
> Does anyone know if it's possible to read an ASP Session Objects
> variables from Perl?
>
> If so, how?  TIA.




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

Date: Wed, 25 Jul 2001 14:27:47 +0100
From: Paul Johnston <paul.johnston@dsvr.co.uk>
Subject: Re: regex question - sort of - how to count if the string has more than   25 words in it
Message-Id: <3B5EC953.C2DABC39@dsvr.co.uk>

Hi,

> subsidiary question - how do I modify the regex to allow for HTML or
> words ?

If you want an entire HTML tag to count as one word, replace it with
/\w+|<[^>]+>/
That regex won't cope with all cases, for example <a href=">"> will
break it.
If you need complete HTML standards conformance, use one of the HTML
parsing modules.

Paul


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

Date: 25 Jul 2001 07:54:21 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: regex question - sort of - how to count if the string has more than 25 words in it
Message-Id: <74f348f7.0107250654.62e98f2e@posting.google.com>

david_gurney@hotmail.com (David Gurney) wrote in message news:<3b5e9a1d.4248829@news.dircon.co.uk>...
> hi,
> 
> I'm trying to count the number of words in a string repeatedly. If the
> number is greater than 25 then the string is shortened and the entire
> string written to another file. The problem seems to be that the way
> I'm doing the count is very slow. can anyone show me a faster way than
> 
> 		$match = 0 ;
> 		while ($ttxts[$i]){
> 			if ($ttxts[$i] =~ /(\w+)/g){
> 				$match++ ;
> 				$tshrt .= "$1 ";
> 			}
> 		}
> 		if ($match <= 25){
> ##			do stuff
> 		}

Howabout

my @ttxts=(
           "this line has only a few words",
	   "this line has more than 25 words this line has more than 25 words
this line has more than 25 words this line has more than 25 words this
line has more than 25 words this line has more than 25 words",
	  );

foreach my $line (@ttxts) {
	my @words=($line=~m/(\w+)/gms); #All words into an array...
	if (@words<=25) { #array size is the number of words...
		warn "less than 25 words\n";
	}
	warn join(",",@words)."\n"; #compute $tshrt only if needed. 
}

Obviously the join statement fills the same job as your $tshrt
concatenation but with no space added to the end. Also, if you have
lines with MANY words then storing them in an array and join()ing them
as needed is faster.

Yves


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

Date: 25 Jul 2001 06:29:00 -0700
From: douglas.neufeld@cisf.af.mil (Moonshiner)
Subject: Re: Regular Expression Reduction
Message-Id: <fdda4b64.0107250528.29a70da8@posting.google.com>

Thanks everyone.

I appreciate all your suggestions and will put them to use.

I have been amazed by how Classes work.  I forgot about placing the
minus sign first to lose it's significance.  I actually had to use it
that way in another regex but did not think about it with the plus
sign.

I wondered about the hanging parenthesis but left it in the example
because I wanted to show exactly what I have in my code.  I have sent
examples of code before when asking a question and did not send
exactly what I had in my code.  This caused great concernation(sic)
and I vowed only to send exactly what I had.

The $nm_att vs $name|$attribute answer/reasoning is the same as above
plus it works that way.  When I put $nm_att in the second half, the
search misses some of the test cases I have created.

I did not know about gr//.  I will put it to use and see how much it
helps the readability.

I am using /x in the matching of the actual regex.  What I showed was
the variables used to build the regexs for searching the code.  The
editor used in creating the post was wrapping automatically then when
sent it was all on one line (as far as the example was concerned.)

I will look into lex and yacc.

I will check out the perl module mentioned (can't see it at this time
but will go back to the messages and print everything out.)

The example I showed was just a small piece of the whole.  I have
created a module that contains most all of the constructs in the
syntax.  In this module is a hash that is exported and several
subroutines.  The hash is simply all the constructs indexed by
construct name.  Entire regexs are created from individual items from
the hash.  The subroutines are still being worked.  I do have one that
will find any of the regexs input.  I also have another that will go
through the Ada code and find each and every if-statement from
beginning to end(that was quite a task by itself.)

This is my first attempt at using Perl and regexs.  I have been an Ada
and C++ coder for the past 11 years.  My boss showed me a book -
Mastering Regular Expressions by Jeffrey E. F. Friedl - and I was
impressed.  I really had no idea about them.  In my research, I have
been totally amazed at the amount of information out there and how
long it has been going on.  I feel like I have been kept in the dark
and fed .... Oh well that's what I get for working with the military. 
I did get to learn about Perl and JavaScript through them though.

Anyway, I am doing this to try and understand regexs better and to
create new tools for our use.  The tools will be used to do
verification and validation of thousands of files that are upto 60,000
lines long.  At the present time, a lot of our time is spent preusing
code manually verifying certain situations are or are not happening as
required.

Again, thanks for your suggestions and I will keep checking back for
further responses.  I will also let everyone know I this comes out.

Moonshiner
-- Linux User because MS sucks.
-- Go Mikey #15


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

Date: Wed, 25 Jul 2001 17:37:55 +0100
From: "Lee Osborne" <osbornelee@hotmail.com>
Subject: Regular Expression
Message-Id: <996079173.11940.0.nnrp-01.c2de1f0e@news.demon.co.uk>

Hi all,

Sorry to bother you all but I can't find a solution to a simple problem. I
assure you I have had a good look for the solution, but have had no success.

What is the regular expresssion to check whether a string contains ONLY
numbers?

It will be part of the code:

if ($stringIn =~ /<THE RE SOLUTION>/) {

  #  Numbers only in this string}
else {

  # There are characters other than number in the string.
}

Thanks in advance,

Lee.




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

Date: Wed, 25 Jul 2001 09:44:31 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Regular Expression
Message-Id: <3B5EF76F.4BBF042B@vpservices.com>

Lee Osborne wrote:
> 
> Hi all,
> 
> Sorry to bother you all but I can't find a solution to a simple problem. I
> assure you I have had a good look for the solution, but have had no success.
> 
> What is the regular expresssion to check whether a string contains ONLY
> numbers?

perldoc -q number produces an article titled:

  "How do I determine whether a scalar is a number/whole/integer/float?"

-- 
Jeff



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

Date: 25 Jul 2001 18:57:06 +0200
From: Steve Holland <holland@origo.ifa.au.dk>
Subject: Re: Regular Expression
Message-Id: <w47y9pdx7z1.fsf@origo.ifa.au.dk>

"Lee Osborne" <osbornelee@hotmail.com> writes:

> What is the regular expresssion to check whether a string contains ONLY
> numbers?

     When you say numbers, do you mean digits (0123456789) or do you
mean any number, such as -8.9, +1.2e-6, (2,2i), etc.?  If you just
mean digits then you can use \D to match any non digit character.  If
you mean any number then I'm stumped.

=====================================================================
               To find out who and where I am look at:
               http://www.nd.edu/~sholland/index.html
=====================================================================


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

Date: Wed, 25 Jul 2001 10:06:45 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Regular Expression
Message-Id: <3B5EFCA5.A828A73@stomp.stomp.tokyo>

Lee Osborne wrote:

(snipped)

> What is the regular expresssion to check whether a string contains ONLY
> numbers?


My presumption is you are "John Howard" over in the alt.perl newsgroup.


Godzilla!


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

Date: 25 Jul 2001 08:17:40 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: Regular expressions...
Message-Id: <74f348f7.0107250717.7fce273d@posting.google.com>

markku@huilustudio.fi (Markku Hirvonen) wrote in message news:<3b5e342a.4576437@uutiset.saunalahti.fi>...
> Hi all!
> 
> I would like to know if there is a newsgroup for regular expressions
> plz.
> 
> Markku

Markku, there is a vry good book on regular expression by Jeffery
Friedl from O'Reiley Books called 'Master Regular Expressions' its a
good intro to the technology as well as the various flavours, and is a
very good way to learn perl regexes, whcih (and this is from the book)
are about the most advanced there are.

Yves


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

Date: 25 Jul 2001 07:13:29 -0700
From: coldwave@bigfoot.com (John Holdsworth)
Subject: Self-Searchable Perl documention - Extremely Useful!
Message-Id: <2a46b11e.0107250613.ec45f1d@posting.google.com>

Folks,

If you have ActiveState's "Active Perl" installed on a PC along
with Perl Documentation you can make it searchable without having
to run a Web server or be connected to the internet by running
this script:

http://www.openpsp.org/source/perltoc.pl

This pathes the the ActiveState table of contents to use "PerlScript"
and run as a Web server inside Internet Explorer (port 8088).

This server will service local requests to search the Perl 
documentation (and source) for any pattern input. 

This seems to work on Activesate buils 627+, Internet Explorer V5+.

Please get back to me if you have any problems..



John Holdsworth

coldwave@bigfoot.com
http://www.openpsp.org


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

Date: Wed, 25 Jul 2001 09:06:19 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Self-Searchable Perl documention - Extremely Useful!
Message-Id: <3B5EEE7B.F7E6D934@vpservices.com>

John Holdsworth wrote:
> 
> If you have ActiveState's "Active Perl" installed on a PC along
> with Perl Documentation you can make it searchable without having
> to run a Web server or be connected to the internet by 

a) using the built-in "find" function of windoze: start menu / find /
files or folders / containing text ...

or

b) at the command line with standard switches to the perldoc command or
with grep

-- 
Jeff



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

Date: 25 Jul 2001 06:39:44 -0700
From: jan2_b@hotmail.com (Jan)
Subject: Re: sizes of strings in Activeperl ?
Message-Id: <114130f5.0107250539.70a36e6f@posting.google.com>

"John W. Krahn" <krahnj@acm.org> wrote in message news:<3B5DCB57.DD1A45B8@acm.org>...
> Jan wrote:
> > 
> > Strange one here.  I use a perl script (ActivePerl) to do some checks
> > on our clearcase vobs.  At a certain moment, I start loading a string
> > variable with the output of a command-line which generates a huge
> > output (4 to 5 meg).  Afterwards I split this on \n's to end up with a
> > huge array, which I start investigating for problems.  I do this
> > several times with the same string and array.
> 
> It might be better to read the output a line at a time instead:
> 
> open CL, "command-line |" or die "Can't open pipe from command-line:
> $!";
> while ( <CL> ) {
>     # do something with line of data
>     }
> close CL or die "Can't close pipe from command-line: $!";

This was the correct solution...  No crashes anymore.  Thanks !

btw : don't know what made it fail, but it wasn't a shortage of memory
since I monitored free memspace during the process.

> 
> AFAIK Perl doesn't have built in limitations. It might help to buy more
> RAM, memory is relatively cheap.
> 
> 
> 
> John


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

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


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