[15607] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3020 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 11 18:15:46 2000

Date: Thu, 11 May 2000 15:10:24 -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: <958083024-v9-i3020@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 11 May 2000     Volume: 9 Number: 3020

Today's topics:
    Re: file upload <lr@hpl.hp.com>
    Re: Getopt::Long : use of uninitialized value (Torsten Mohr)
        Help needed with Perl and Netscape Fasttrack server!!!! <mkhan@crosscom.com>
        Help using split and arrays <gnielson@charlotte.infi.net>
    Re: Help using split and arrays <tina@streetmail.com>
    Re: I need help installing Perl <lr@hpl.hp.com>
    Re: Increase a selected fieldvalue <lr@hpl.hp.com>
        MacPerl: access to floppy and harddisk? <mario.gunkel@fast-net.de>
        Mmap module usage <enrecka@sandia.gov>
    Re: MUCH better DATA file formatting :) (THANK YOU) <nospam@devnull.com>
    Re: Need to make UNIX autoresponder <jstaedele@freshnet.de>
        Perl2exe Error tamiraw@my-deja.com
    Re: portable open for read/write? <baughj@rpi.edu>
        Regular expression ? tvn007@my-deja.com
    Re: Regular expression ? <jeff@vpservices.com>
    Re: Regular expression ? <aqumsieh@hyperchip.com>
    Re: Regular expression ? tvn007@my-deja.com
    Re: Regular expression ? <jeff@vpservices.com>
        regx question (dc)
        removing perl modules <jens@irs-net.com>
    Re: removing perl modules <makarand_kulkarni@My-Deja.com>
    Re: removing perl modules <makarand_kulkarni@My-Deja.com>
    Re: Seeking a file <igorleal@dcc.ufmg.br>
    Re: Seeking a file (Randal L. Schwartz)
        Sharing Data between JS and Perl acrfp@my-deja.com
    Re: shooting yourself in the foot ... (Tad McClellan)
    Re: shooting yourself in the foot ... (Andrew Johnson)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 11 May 2000 10:58:09 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: file upload
Message-Id: <MPG.138494886673ac1098aa55@nntp.hpl.hp.com>

In article <FlCS4.102$Yb5.429242@nnrp3.proxad.net> on Thu, 11 May 2000 
17:46:13 GMT, Guillaume GERMAIN <germain@greyinteractive.it> says...
> I have got a problem with a upload script in ActivePerl (Perl working on
> IIS, NT Server).
> In fact, the upload seems to work well for text files, but the size of the
> uploaded picture file is slightly higher than the original one.

 ...

> open (SAVE,">$upload_dir/$file_id.$file_type") || die $!;
> $total_size = 0;
> #binary SAVE ":raw";

  binmode $file;
  binmode SAVE;

> while ($size = read($file,$data,1024))

We'll assume the missing left brace here is a transcription error.  :-)

>     $total_size += $size;
>     print SAVE $data;
>   }
> close SAVE;

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 11 May 2000 19:41:19 GMT
From: tmohr@schleim.qwe.de (Torsten Mohr)
Subject: Re: Getopt::Long : use of uninitialized value
Message-Id: <8ff2cv$1sj$2@schleim.qwe.de>

> Options are matched case insensitive by default, so you can say:
> 
>   $result = GetOptions(	"mode=s" => \$m,
>  			"i=s@" => \@INCS,
>  			"d=s%" => \%DEFS
>  			);
> 
> (with lowercase "i" and "d").
> 
> If you _require_ the options to be in uppercase only, use
> 
>   Getopt::Long::Configure("noignorecase");


Thank you for your fast answer,

i use Getopt::Long in a script i use in the office where i
can't install new modules.  The last date of modification
is somewhere in Oct 1996.  Instead of "Configure" i clear
$Getopt::Long::ignorecase by hand.

Regards,
Torsten.


http://www.s.netic.de/tmohr/linux.html


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

Date: Thu, 11 May 2000 15:24:39 -0500
From: "Mohammad Khan" <mkhan@crosscom.com>
Subject: Help needed with Perl and Netscape Fasttrack server!!!!!!!!!!!!!!!1
Message-Id: <391b1650$0$1085@wodc7nh6.news.uu.net>

Hi,
    We have a customer who is using Netscap Fasttrack server on HPUX and our
web server software. Now he get's a Internal Server Error when he tries to
execute these perl scripts. This is netscape web server log file, when he
executes one of the perl script.

When Message Results selected:  [10/May/2000:15:40:05] config: for host
162.100.117.29 trying to POST /cgi-bin/logres.pl, handle-processed reports:
no way to service request for /cgi-bin/logres.pl

The perl script run's fine from the command line. I will appreciate any help
on this issue.

Thanks.




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

Date: Thu, 11 May 2000 15:38:01 -0400
From: Gary Nielson <gnielson@charlotte.infi.net>
Subject: Help using split and arrays
Message-Id: <391B0C19.61F7ABDF@charlotte.infi.net>

I am having trouble using an array and split to parse an html document.

I am trying to isolate just those lines that contain urls and links and
create an array whose elements I can then insert into a form, with urls
and links as separate elements.

First, I find just though lines that contain an A HREF and grab that
entire line. I then get rid of extraneous markup language until I am
left with just the code I want, the URL and the link, separated by a "
". The script works fine until I try to use split. My limited (but
hopefully growing) understanding of perl is that you can't perform
substitutions on arrays, just scalar variables. So as the script loops
through the file and finds the desired lines, it pushes the scalar
variable into an array.

But then how do I split the array since perl won't let you split arrays,
just scalars, but when I try to convert the array to a scalar, the
syntax is telling perl $variable = @array to give me the number of
elements. So I feel like I am caught in my own loop of sorts mixing
scalars and arrays when trying to use split.

So for now, I can get one array element that includes both the link and
the URL, which is not what I want; I want each element to contain only a
link or only the URL.

Code below:

$var = "";
@headlines = "";
$delimiter = "   ";
$filename = "docs/filename.htm";
open(FILE, $filename);
while (<FILE>)
{
 if (/<A HREF=/) # line contains <A HREF tag
 {
  $var = $_;

# strip out crap

  $var =~ s/<DIGEST>|<\/DIGEST>|<\/FONT>|<\/TD>//g;
#  $var =~ s/<[A-Za-z\_].+DIGEST[A-Za-z\_].+>|<\/FONT>|<\/TD>//g;
  $var =~ s/\n/$delimiter/g;
  $var =~ s/<\/A>//g;
  $var =~ s/\">/$delimiter/g;
  push(@headlines, $var);
 }
}
close (FILE);
#$tmp = @headlines ## won't work because returns the number of elements,
doesn't convert back to scalar
#split(m/$delimiter/, @headlines); ## wont work because I dont think
split works on arrays, just scalars.

print @headlines;

Any help appreciated. Please email reply as well.

Gary





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

Date: Thu, 11 May 2000 17:44:52 -0400
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Help using split and arrays
Message-Id: <8ff9k6$an4hf$1@fu-berlin.de>

hi,

Gary Nielson wrote:

> I am having trouble using an array and split to parse an html document.

first suggestion: try the CPAN module HTML::Parser

> First, I find just though lines that contain an A HREF and grab that
> entire line.

what about reading the whole file in one $scalar?
look at the documentation for the $/ variable, which
can be useful for reading files.

> But then how do I split the array since perl won't let you split arrays,
> just scalars, but when I try to convert the array to a scalar,

converting an array to a scalar:
try
join("with whatever in between", @array);

(but be careful with regexp; you have to set the flag s for matching
newlines; that's the reason why you should look at $/ )


tina

--
       --- ICQ #73179850 ---        |     _   enter the
http://user.berlin.de/~tina.mueller |  __| |___  ___ _ _ ___
----    tina's moviedatabase    ----| / _` / _ \/ _ \ '_(_-< of
--search & add comments or reviews--| \__,_\___/\___/_| /__/ perception





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

Date: Thu, 11 May 2000 14:10:07 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: I need help installing Perl
Message-Id: <MPG.1384c18838608f198aa59@nntp.hpl.hp.com>

In article <04699d92.e2f5f976@usw-ex0105-034.remarq.com> on Thu, 11 May 
2000 10:45:01 -0700, bjanko <waldo700NOwaSPAM@aol.com.invalid> says...
> Thanks for your help, but I have tried downloading it from
> several sources and continue to get the same error message when
> I run the configure.com (see previous post).
> 
> I have Win98 am downloading the .zip version.  Or should I be
> using the tar.gz?

Don't try to compile your own perl binaries for Windows 98.  Download it 
direct from <URL:http://www.activestate.com/>.  Installing it is a 
breeze. 

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 11 May 2000 14:05:05 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Increase a selected fieldvalue
Message-Id: <MPG.1384c05faaaefa2698aa58@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <391a55fd$0$9490@reader3> on Thu, 11 May 2000 08:39:20 +0200, 
Eric van Huijgevoort <huijgbv@casema.net> says...
> 
> Can anyone tell my how to increase a selected fieldvalue in undermentioned
> code.
> $_max_ordernumber++; doesn't work, please tell my the right query.
> 
> <eval>
>    $max_ordernumber = $dbh->prepare("SELECT max(ordernumber) FROM
> orderlist");

So $max_ordernumber is a statement handle, i.e. a reference.

>       $_max_ordernumber++;

$_max_ordernumber isn't used elsewhere in this code.  If you meant it to 
be $max_ordernumber, then incrementing it is meaningless, because one 
can't do useful arithmetic on a reference.

>    $max_ordernumber->execute;
> #checking
>    while (my $ref = $max_ordernumber->fetchrow_hashref)   {
>    print "Found maximum ordernumber: $ref->{'ordernumber'}\n";
>    }
>   $max_ordernumber->finish;
> <eval>
> 
> Every suggestion is welcome.

I suggest you start to use the '-w' flag and 'use strict;', so you will 
eliminate typographical errors from your code from the beginning.

As for what your intentions were, I cannot help you, because I don't see 
what you were trying to accomplish.

> Thanks in advance, you can also mail me.

My pleasure, because you made it easy by giving your address correctly 
in the headers.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 11 May 2000 20:47:12 +0100
From: Mario Gunkel <mario.gunkel@fast-net.de>
Subject: MacPerl: access to floppy and harddisk?
Message-Id: <mario.gunkel-420594.20471211052000@news2.fast-net.de>

MacPerl question 1:
How can I access a floppy-disk on the mac. Is there a routine or 
function built-in in MacPerl
that read out the connected devices and how can I access them. The MacOS 
allows it to name the 
floppy and hard-disks at will. How can I access a drive without knowing 
its name?

MacPerl question 2:
Some directories have names with a blank within, like "Macintosh HD". If 
I try to read in the
contents of such directory, MacPerl can't find it. I used the following 
commands:

$path="Macintosh HD";
opendir(DIR, $path) || die "can't opendir $path: $!";
foreach $filename (glob($path))
{
print $filename,"\n"
} 

MacPerl failed at the command "opendir..."

-- 
homepage: http://www.fast-net.de/~mario.gunkel/main.htm
(!Die Site mit den Cartoons!)


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

Date: Thu, 11 May 2000 13:52:36 -0600
From: Erik Reckase <enrecka@sandia.gov>
Subject: Mmap module usage
Message-Id: <391B0F84.26B16ABD@sandia.gov>

I'm curious if anyone has used or is using the Mmap module to access
shared memory POSIXly.  It looks like what I've been looking for, but
since it hasn't been updated since June '96, I'm wondering if it will
work with POSIX.4

--Erik Reckase
--Sandia National Laboratories
--Albuquerque, NM


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

Date: 11 May 2000 21:40:11 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: MUCH better DATA file formatting :) (THANK YOU)
Message-Id: <8ff9br$m0g$0@216.155.32.166>

and the final finished script (you'll need the first two in this thread) that provides the 
formatted output of the maps_list.txt 

Thank you, one and all.. I couldn't have come this far, this fast, without your help. 

Now to show it to the admins, and get the to replace the crappy slow javascript routines 
at http://www.planetunreal.com/nalicity/ut_dm_maps.htm and other associated files. (you 
can view these two side by side for comparison.. that page, and this script.)

(I managed to widen the linewrapping in my newsreader to 90 chars.. hope this is enough. )

-=-ncmapslist.cgi
#!/usr/bin/perl -w
use strict;
#use diagnostics -verbose;
use File::Spec;
use CGI qw( :standard :html3 );
use CGI::Pretty qw( :html3 );
use CGI::Carp qw(fatalsToBrowser);

######
### NaliCity Maplist Parsing CGI
### Written by Scott R. Godin aka FuzzBuster, fuzzbuster@planetunreal.com
### May 7 - 11, 2000. 
######

#predefine some stuff
my $input_File = File::Spec->catfile( File::Spec->curdir(), 'maps_list.txt');
my %master_maps_list = ();
my @data = ();

#stylesheet for html output
my $newStyle = <<'EON';
Body {
    color: white;
    background-color: black;
    font-family: Helvetica, Arial, sans-serif;
}
P { color: white; background: transparent }
tt { color: #000000; background: transparent; font-family: "Courier MT", Courier; 
font-size: small }
th { color: #FFC600; font-family: Helvetica, Arial, sans-serif }
td { font-family: Helvetica, Arial, sans-serif }
td.a { color: #339966; font-family: Helvetica, Arial, sans-serif }
    }
EON

# map fileslist to section titles and split utdm properly
my %dirname = (
    'utassault' => 'utassault',
    'utdma' => 'utdm',
    'utdmb' => 'utdm',
    'utctf' => 'utctf',
    'utdomination' => 'utdomination',
    'utother' => 'utother'
);
my %files_list = (
    'utassault' => 'Assault Maps',
    'utctf' => 'Capture The Flag Maps',
    'utdma' => 'DeathMatch Maps A-L',
    'utdmb' => 'DeathMatch Maps M-Z',
    'utdomination' => 'Domination maps',
    'utother' => 'Other Maps'
);
my %button_labels = (
    'all' => 'Show All Maps',
    'rated' => 'Show Rated Maps Only',
    'unrated' => 'Show Unrated Maps Only',
);
open(IN, "<$input_File");
#I don't understand how to dereference this yet. um, 'help'? :)
#   @data = map {chomp; [split /\|/]} <IN>; 
#so I did it the 'long' way. is this the 'better' way? 
while (<IN>) {
    chomp;
    push @data, $_;
}
close IN;

foreach (@data) {
    my($gametype, $filename, $title, $size, $review, $rating) = split /\|/;
  $master_maps_list{$gametype}{$filename} = [$title, $size, $review, $rating];
}

# start HTML section
print header;
print start_html({-Title=>"NaliCity Maps via FuzzBuster's CGI",
                  -Style=>{-Code=>$newStyle}, 
                  -dtd=>'-//W3C//DTD HTML 3.2//EN',
                  -background=>'http://www.planetunreal.com/nalicity/images/maps_back.gif',
                  -bgcolor=>'black',
                  -text=>'white',
                  -"link"=>'#ffff99',
                  -vlink=>'yellow'});
print div({-align=>'center'});
print qq{<table border="0" cellpadding="0" cellspacing="1" width="215">\n};
print qq{<tr><td colspan="3">\n};
print h4({-align=>"center"}, 'Choose One'),
      start_form;
print div({-align=>"center"},
      p( popup_menu({-name=>'mapstyle',
                 -Values=>['utdma','utdmb','utctf','utdomination','utassault','utother'],
                 -default=>'utdma',
                 -labels=>\%files_list}))); #/div
print p( radio_group({-name=>'short',
                   -Values=>['all','rated','unrated'],
                   -default=>'all',
                   -labels=>\%button_labels,
                   -linebreak=>'true'}));
print div({-align=>"center"},
      p( submit({-name=>'action', -Value=>'submit', -"label"=>'Update Maps List'}))); #/div
print end_form;
print qq{</td></tr>\n};

my $GameType = "";
my $count = 0;
my %hash = ();

if (param('mapstyle')) {$GameType = param('mapstyle')} else {$GameType = 'utdma'};

#note to self foreach my $GameType ( keys %master_maps_list ) { 
my $mapcount = scalar keys (%{ $master_maps_list{$GameType}});

foreach my $mapName ( sort ( keys %{$master_maps_list{ $GameType }} ) ) {

    my( $Title, $size, $review, $rating ) = @{$master_maps_list{ $GameType }{ $mapName }};
        if (param()) {
        next if ((param('short') eq 'rated' && $rating == -1));
            next if ((param('short') eq 'unrated') && ($rating != -1));
        };
    ++$count; 
    push @{$hash{map_name}},  "$mapName.zip";
    push @{$hash{Title}},     $Title;
    push @{$hash{file_size}}, $size;
    if ($rating != -1) {
        push @{$hash{review}}, '<a href="http://www.planetunreal.com/nalicity/reviews/' . 
"$review.html" . '" target="_new">';
        push @{$hash{rating}}, "$rating</a><br>\n";
    }  # if
    else {
        push @{$hash{review}}, "";
        push @{$hash{rating}}, "N/A<br>\n";
    }  # else
}  # foreach mapName
print '<th colspan="3">'.$files_list{$GameType}.' - '.$count."</th>\n";
print '<tr><td align="left" class="a">Map Name</td><td align="left" class="a">Size</td><td 
align="left" class="a">Rating</td></tr>'."\n";
print qq{<tr>\n<td align="left" valign="top"><font size="2">\n};
for ( 0..--$count ) {
    print <<_end_;
    <a 
href="http://www.planetunreal.com/dl/nc.asp?nalicity/$dirname{$GameType}/$hash{map_name}->[
$_]" target="_new">$hash{Title}->[$_]</a><br>
_end_
}
    
print qq{</font></td>\n<td align="right" valign="top"><font size="2">\n};
for ( 0..$count ) { print qq{$hash{file_size}->[$_]<br>\n} }
    
print qq{</font></td>\n<td align="center" valign="top"><font size="2">\n};
for ( 0..$count ) { print   $hash{review}->[$_] . $hash{rating}->[$_] }
    
print qq{</font></td>\n</tr>\n};
#}
print qq{</table></div>\n};
print qq{</body></html>};

__END__

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: Thu, 11 May 2000 23:12:54 +0200
From: Joerg Staedele <jstaedele@freshnet.de>
Subject: Re: Need to make UNIX autoresponder
Message-Id: <391B2256.7B34D805@freshnet.de>

Hi..

autoresponder for what email?

acunet3278@my-deja.com wrote:

> I would like to make an autoresponder in Perl on a UNIX server. Any
> ideas tips about doing that? I look forward to hearing from you. Thank
> you.
>
> --
> Auction Booth:
> http://page.auctions.yahoo.com/booth/acunet3278
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.



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

Date: Thu, 11 May 2000 18:47:41 GMT
From: tamiraw@my-deja.com
Subject: Perl2exe Error
Message-Id: <8fev88$kab$1@nnrp1.deja.com>

To all:

I am trying to convert my Perl script into a stand-alone perl
executable file, but I keep getting an Error.

Error:
=====
Can't locate PERL2EXE_STORAGE/Mail/Sender.config in @INC (@INC
contains: PERL2EXE_ST
ORAGE C:\TEMP lib\site .) at PERL2EXE_STORAGE/Mail/Sender.pm line 26.
BEGIN failed--compilation aborted at PERL2EXE_STORAGE/Mail/Sender.pm
line 27.
BEGIN failed--compilation aborted at C:\src\NetSwitch\NetSwitch.pl line
5.
End Error
=========

No matter what I do, I can't seem to get rid of this Error. Can someone
please enlighten me on this issue.

Thankx,
Tamira


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


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

Date: Thu, 11 May 2000 14:35:37 -0400
From: justin baugh <baughj@rpi.edu>
Subject: Re: portable open for read/write?
Message-Id: <391AFD79.B93267E2@rpi.edu>

> Okay, www.perlfaq.com suggests that to open a file for both reading and
> writing, one does this:
> 
> open(FILEHANDLE, "<+filename");
> 
> But when I do that, the open fails with "No such file or directory" --
> and yes, the file is there, and the open works as expected with
> "filename", ">filename", and ">>filename" -- just not "<+filename".

The plus sign must come first:

open (FILEHANDLE, "+<filename");

> So, how do I open a file for both read and write on my system(s)?
> 

You could also use sysopen or the FileHandle module.

sysopen FILEHANDLE, "filename", O_RDWR; (sysopen)

perldoc FileHandle will tell you more about the FileHandle module.


Hope this helps,

~j

-- 
==================================================
Justin Baugh (baughj@nocannedmeat.rpi.edu)
PGP: http://www.rpi.edu/~baughj/keys.txt
"Evil is easy, and has infinite forms." - Pascal


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

Date: Thu, 11 May 2000 19:53:39 GMT
From: tvn007@my-deja.com
Subject: Regular expression ?
Message-Id: <8ff33q$p2a$1@nnrp1.deja.com>



 Hi,

Could someone please help me with the following pattern matching ?

Here is the data:

305   : 0_0  2.01  A
306   : 0_0  1.80  AR
305   : 0_0  2.50  AR


I would like to extract number 2.01, 1.80 and 2.50

Here is what I have, and it does not work (i.e does not print out
anything)

if($_ =~ /^[0-9]\s*:\s*0_0\s*([0-9])\s*[A-R]/)

	print "$_\n";
	print  "$1\n";

Thanks in advance for  any help,


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


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

Date: Thu, 11 May 2000 13:07:23 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Regular expression ?
Message-Id: <391B12FB.F3A649CA@vpservices.com>

tvn007@my-deja.com wrote:
> 
>  Hi,
> 
> Could someone please help me with the following pattern matching ?
> 
> Here is the data:
> 
> 305   : 0_0  2.01  A
> 306   : 0_0  1.80  AR
> 305   : 0_0  2.50  AR
> 
> I would like to extract number 2.01, 1.80 and 2.50

I'd use split() rather than a regex to do that.

  while(<DATA>) {
      my @ary = split /\s+/;
      print "$ary[3]\n";
  }

-- 
Jeff


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

Date: Thu, 11 May 2000 21:07:23 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Regular expression ?
Message-Id: <7a66sk94om.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>


tvn007@my-deja.com writes:

>  Hi,
> 
> Could someone please help me with the following pattern matching ?
> 
> Here is the data:
> 
> 305   : 0_0  2.01  A
> 306   : 0_0  1.80  AR
> 305   : 0_0  2.50  AR
> 
> 
> I would like to extract number 2.01, 1.80 and 2.50
> 
> Here is what I have, and it does not work (i.e does not print out
> anything)
> 
> if($_ =~ /^[0-9]\s*:\s*0_0\s*([0-9])\s*[A-R]/)
> 
> 	print "$_\n";
> 	print  "$1\n";

First of all, the above won't compile because of the missing braces for
the if() block. Please post legitimate code next time if you want your
problem to be accurately diagnosed.

Second of all, others have told you that split() is a better choice
here, but it really depends on your input data. If you can guarantee
that there will always be spaces in the places shown in your test case,
then a simple split() should do:

	my $number = (split)[3];

Third of all, if you are interested in knowing why your regexp didn't
work, then here's a brief explanation. In the regexp, you ask to match a
*SINGLE* digit at the beginning of the line, followed by zero or more
spaces, followed by a colon, followed by zero or more spaces, followed
by the string '0_0' followed by zero or more spaces, followed by another
*SINGLE* digit (which you try to capture in $1), followed by zero or more
spaces, followed by a letter in the range A to R.

I think you can see your problems now. You should ask to match more than
one digit at the beginning. Also, the number that you want to match
contains a decimal point which will NOT be matched by [0-9].

Here's a regexp that will work:

	if (/^\d+\s*:\s*0_0\s+(\d+\.\d+)\s+AR?/) {
		print "Match found = $1.\n";
	}

I used \d here for digit, which is the same as [0-9].

--Ala


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

Date: Thu, 11 May 2000 21:03:44 GMT
From: tvn007@my-deja.com
Subject: Re: Regular expression ?
Message-Id: <8ff774$trg$1@nnrp1.deja.com>

sorry, the input file is more complicate so I do not think I can use
split.

The actual input file would be something like this:
        abc   : 0_0  2.02  A
	305   : 0_0  2.01  A
	306   : 0_0  1.80  AR
 	305   : 0_0  2.50  AR



> 	305   : 0_0  2.01  A
> > 	306   : 0_0  1.80  AR
> > 	305   : 0_0  2.50  AR


In article <391B12FB.F3A649CA@vpservices.com>,
  Jeff Zucker <jeff@vpservices.com> wrote:
> tvn007@my-deja.com wrote:
> >
> >  Hi,
> >
> > Could someone please help me with the following pattern matching ?
> >
> > Here is the data:
> >
> > 305   : 0_0  2.01  A
> > 306   : 0_0  1.80  AR
> > 305   : 0_0  2.50  AR
> >
> > I would like to extract number 2.01, 1.80 and 2.50
>
> I'd use split() rather than a regex to do that.
>
>   while(<DATA>) {
>       my @ary = split /\s+/;
>       print "$ary[3]\n";
>   }
>
> --
> Jeff
>


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


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

Date: Thu, 11 May 2000 14:16:46 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Regular expression ?
Message-Id: <391B233E.81CCF047@vpservices.com>

tvn007@my-deja.com wrote:
> 
> sorry, the input file is more complicate so I do not think I can use
> split.
> 
> The actual input file would be something like this:
>         abc   : 0_0  2.02  A
>         305   : 0_0  2.01  A
>         306   : 0_0  1.80  AR
>         305   : 0_0  2.50  AR
> 

That would work exactly the same as the other with the split.  The only
thing that would break the split would be if there were a different
number of non-whitespace elements before the one you want to catch.

-- 
Jeff

> >       305   : 0_0  2.01  A
> > >     306   : 0_0  1.80  AR
> > >     305   : 0_0  2.50  AR
> 
> In article <391B12FB.F3A649CA@vpservices.com>,
>   Jeff Zucker <jeff@vpservices.com> wrote:
> > tvn007@my-deja.com wrote:
> > >
> > >  Hi,
> > >
> > > Could someone please help me with the following pattern matching ?
> > >
> > > Here is the data:
> > >
> > > 305   : 0_0  2.01  A
> > > 306   : 0_0  1.80  AR
> > > 305   : 0_0  2.50  AR
> > >
> > > I would like to extract number 2.01, 1.80 and 2.50
> >
> > I'd use split() rather than a regex to do that.
> >
> >   while(<DATA>) {
> >       my @ary = split /\s+/;
> >       print "$ary[3]\n";
> >   }
> >
> > --
> > Jeff
> >
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.


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

Date: Thu, 11 May 2000 21:31:57 GMT
From: ANTISPAMfartknocker@cyberdude.com (dc)
Subject: regx question
Message-Id: <391b22cf.351921699@24.2.2.74>


Can anyone provide a better perl regular expression for matching on
any word that has all 5 vowels in any order?  This is not a homework
problem, but a homework problem did lead to trying to figure this out
(the homework problem was to write a perl *script* to do this).
Anyway I'm providing my solution to hopefully alleviate any fears.

/(?=.*a)(?=.*e)(?=.*i)(?=.*o).*u/

Is there a more efficient way to do this?  Is this grossly
inefficient?  Is there a way to do this without using lookahead?

This seems like a problem that would have been asked before, but I
didn't see it anywhere in the archive search I did or in any FAQs.  

thanks,
david


   Anti-Spam Address in Use.  Remove the AntiSpam
    in above address before replying to this
    message.  


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

Date: Thu, 11 May 2000 22:42:06 +0200
From: Jens Luedicke <jens@irs-net.com>
Subject: removing perl modules
Message-Id: <391B1B1E.40AF0248@irs-net.com>

hi there ...

I installed several perl modules, that
I don't need anymore. Is there a way
to get rid of them? 

-- 
with friendly regards...

	Jens Luedicke <jens@irs-net.com>
	http://www.irs-net.com/

$a="34t3354s3434u553453J";$b="r324eht37282o34534na";
$c="3345l534r523e55P234234";$d="345r342e345k2314c56a34h";
@beg = ("$a","$b","$c","$d");foreach $p (@beg){	$p =~ 
s/[0-9]//g;$sl=reverse("$p");print"$sl ";}print"\n";

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GIT/H/P/L d- s: a-- C+++ UL P++ L+++ E---- W++ N+ o? K? w-- O? M(-) V?
PS++ PE Y+ PGP++ t+ 5-- X- R- tv+ b++ DI++++ D- G e h! r-- z?
------END GEEK CODE BLOCK------


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

Date: Thu, 11 May 2000 14:39:58 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: removing perl modules
Message-Id: <391B28AE.F62F9D82@My-Deja.com>

> I installed several perl modules, that
> I don't need anymore. Is there a way
> to get rid of them?

This is just an idea.
Check the " .packlist" file for the module you
want to remove. Be careful about dependencies.
--



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

Date: Thu, 11 May 2000 14:59:36 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: removing perl modules
Message-Id: <391B2D48.28230F8@My-Deja.com>

> I installed several perl modules, that
> I don't need anymore. Is there a way
> to get rid of them?

I found this script "modrm" that does that.
http://www.perl.com/pub/doc/manual/html/lib/ExtUtils/Packlist.html#EXAMPLE

--




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

Date: Thu, 11 May 2000 16:38:46 -0300
From: Igor Campos Leal <igorleal@dcc.ufmg.br>
To: nobull@mail.com
Subject: Re: Seeking a file
Message-Id: <Pine.GSO.4.21.0005111635500.4824-100000@turmalina.dcc.ufmg.br>

On 11 May 2000 nobull@mail.com wrote:

> Igor Campos Leal <igorleal@dcc.ufmg.br> writes:
> 
> > 	I need to know how the function seek works.
> 
> perldoc -f seek
> 
> > 	I wanna read a line of the file and, if a condition, seek the file
> > for one line up.
> > 	How can I do that? Can I use offset with kline nmber?
> 
> No, you have to record byte offsets for the start of each line in an
> array.
> 
> If the file is small you may decide to just slurp the whole thing into
> an array.

	All lines of the file have the same lenght, 83 chars so can I do
something like:
         seek (FILEHANDLE, -(83*number_of_line_I_want), 1);

	Thanks for helping...
		Igor Campos Leal



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

Date: 11 May 2000 13:12:07 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Seeking a file
Message-Id: <m1em78978o.fsf@halfdome.holdit.com>

>>>>> "Igor" == Igor Campos Leal <igorleal@dcc.ufmg.br> writes:

Igor> 	All lines of the file have the same lenght, 83 chars so can I do
Igor> something like:
Igor>          seek (FILEHANDLE, -(83*number_of_line_I_want), 1);

I think you want 2 there, unless you have already done a seek
to the end that you're not showing.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Thu, 11 May 2000 18:56:07 GMT
From: acrfp@my-deja.com
Subject: Sharing Data between JS and Perl
Message-Id: <8fevnv$kv3$1@nnrp1.deja.com>

I am fairly new to perl development and this issue is becoming a mojor
stumbling block for me. I have a multiframed HTML document. In one
frame the fields within its form are used to populate an array. As each
new element is populated to the array, i need to run a perl script that
can read the array and then dynamically re-create an html file to be
displayed in another frame.

I cannot get the perl script to see or access the array created with
the JS in the other frame.

My application needs to be run on the IIS server and by multiple
people, so storing the array in local file is not really an option.

Does anyone have any ideas??

Thanks,
Alex Cameron
Riverside Forest Products Limited
Kelowna BC Canada


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


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

Date: Thu, 11 May 2000 14:17:04 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: shooting yourself in the foot ...
Message-Id: <slrn8hlu90.krf.tadmc@magna.metronet.com>

On Thu, 11 May 2000 16:55:01 GMT, Andrew Johnson <andrew-johnson@home.com> wrote:
>In article <slrn8hlfpr.k1b.tadmc@magna.metronet.com>,
> Tad McClellan <tadmc@metronet.com> wrote:
>[snip] 
>> Make a trigger pulling motion, and Perl will:
>> 
>>    autovivify a gun for you
>> 
>>    initialize it with bullets
>> 
>>    fire a bullet
>> 
>>    move your foot so as to coincide with the bullet's trajectory
>> 
>>    say "Ouch!" for you
>
>I hear that soon a new Foot::Intercede module will even step in
>and take the bullet for you :-)


We can do without the namespace pollution.

There are already lots of those Foot::* modules planned,


   Foot::MouthInsert (I expect I'll find lots of use for that one)

   Foot::Athlete's   (boo to those 3-level hierarchies and 
                      one-character names...)

   Foot::Bone::Connected::To::Ankle::Bone

   Foot::Ball        (DWIMs between pointy-ended ball and soccer varieties
                      based on locale)

   Foot::Print


It more correctly belongs in the      Secret::Service   module.

heh, heh


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 11 May 2000 20:29:30 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: shooting yourself in the foot ...
Message-Id: <KKES4.12077$95.154064@news1.rdc1.mb.home.com>

In article <slrn8hlu90.krf.tadmc@magna.metronet.com>,
 Tad McClellan <tadmc@metronet.com> wrote:
> On Thu, 11 May 2000 16:55:01 GMT, Andrew Johnson <andrew-johnson@home.com> wrote:
[snip]
> >
> >I hear that soon a new Foot::Intercede module will even step in
> >and take the bullet for you :-)
> 
> 
> We can do without the namespace pollution.
> 
> There are already lots of those Foot::* modules planned,

[snip]
 
> It more correctly belongs in the      Secret::Service   module.

your points are well taken -- however, it should probably be a pragma
anyway: 
    
    use foot 'intercede';

This won't further pollute the Foot:: namespace and still allows for
the 'step in' to take the bullet pun.

regards,
andrew (never underestimate the value of a stupid pun).

-- 
Andrew L. Johnson   http://members.home.net/andrew-johnson/epwp.html
      Some people, when confronted with a problem, think 'I know,
      I'll use regular expressions.'  Now they have two problems.
          -- Jamie Zawinski, on comp.lang.emacs


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

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


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