[28624] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9988 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 20 14:10:14 2006

Date: Mon, 20 Nov 2006 11:10:07 -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           Mon, 20 Nov 2006     Volume: 10 Number: 9988

Today's topics:
        Matching and Regular Expressions <deadpickle@gmail.com>
    Re: Matching and Regular Expressions <spamtrap@dot-app.org>
    Re: Matching and Regular Expressions <deadpickle@gmail.com>
    Re: Matching and Regular Expressions <someone@example.com>
        parsing a string <mariecuddy@gmail.com>
    Re: parsing a string <mritty@gmail.com>
    Re: parsing a string <someone@example.com>
        perl -d memory fault and core dump. <lhradowy@gmail.com>
    Re: Perl is worth nothing!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! <robertospara@gmail.com>
    Re: reg exp: helping hand needed <oli.meister@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 20 Nov 2006 08:44:40 -0800
From: "deadpickle" <deadpickle@gmail.com>
Subject: Matching and Regular Expressions
Message-Id: <1164041080.502447.280890@f16g2000cwb.googlegroups.com>

I need to search a txt document for several strings and then report
them in an array. The source document looks as follows:

AR FLIPPIN (AWOS)   KFLP  FLP          36 17N  092 35W  219   X
  W    7 US
AR FORT SMITH       KFSM  FSM   72344  35 20N  094 22W  140   X     U
  A    3 US
AR SLATINGTON MTN.  KSRX  SRX          35 17N  094 22W  195      X
       8 US
AR HARRISON         KHRO  HRO          36 16N  093 09W  417   X     T
  A    6 US
AR HOT SPRINGS      KHOT  HOT          34 29N  093 06W  162   X     T
  A    6 US
AR JONESBORO        KJBR  JBR          35 50N  090 39W   79   X     T
  A    6 US
AR LITTLE ROCK      KLIT  LIT          34 44N  092 14W   79   X     U
  A    0 US

The string I want to search for is KFSM and  KJBR and I want the
following numerical values reported to an array. I started to try and
make this but I dont understand regular expressions very well. Thanks
for the help.



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

Date: Mon, 20 Nov 2006 12:01:59 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Matching and Regular Expressions
Message-Id: <m2mz6m59x4.fsf@Sherm-Pendleys-Computer.local>

"deadpickle" <deadpickle@gmail.com> writes:

> I started to try and
> make this but I dont understand regular expressions very well. Thanks
> for the help.

Well, since you didn't post the code you need help with, it's impossible
to offer any specific advice about whatever problems you may be having
with that code.

In general, you can find info about regexes in:

    perldoc perlretut
    perldoc perlre

I would advise reading them in that order - the first is a tutorial, and
the second more of a reference.

Once you've had a go at it, post your code here and someone will probably
be able to help you get past any specific trouble spots.

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: 20 Nov 2006 10:40:50 -0800
From: "deadpickle" <deadpickle@gmail.com>
Subject: Re: Matching and Regular Expressions
Message-Id: <1164048050.153086.212100@h54g2000cwb.googlegroups.com>

Here is a quick code I came up with:

source
===================================
!23456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
!


NORTH DAKOTA       24-JUN-05
CD  STATION         ICAO  IATA  SYNOP   LAT     LONG   ELEV   M  N  V
U  A  C
ND BISMARCK         KBIS  BIS   72764  46 46N  100 45W  505   X  X  U
X  A  F 0 US
ND DEVILS LAKE      KDVL  DVL   72757  48 07N  098 55W  443   X
  W    7 US
ND DEVILS LAKE      KP11  P11   72758  48 07N  098 55W  443   X
  W    7 US
ND DICKINSON        KDIK  DIK          46 48N  102 48W  788   X     U
  A    6 US
ND FARGO            KFAR  FAR   72753  46 56N  096 49W  277   X     U
  A    1 US


Code
====================================
use strict;
use warnings;
open (ID, "stations.txt") || die ("cannot open file!!");
while (my $stations = <ID>) {
	my @station = split (/\r/,$stations);
	foreach (@station) {
		print $_;
		if (my %stid = $_ =~ m/(?:^\w+|\s+)(KBIS|KDVL)(\s+|\w+)/) {
			print %stid,"\n";
			if ( defined ($stid{KBIS})) {
				print $stid{KBIS};
			}
		}
	}
}

It does not return anything in the print after the hash is initialized.



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

Date: Mon, 20 Nov 2006 18:55:46 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Matching and Regular Expressions
Message-Id: <SSm8h.7279$rB6.584@clgrps13>

deadpickle wrote:
> Here is a quick code I came up with:
> 
> source
> ===================================
> !23456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
> !
> 
> 
> NORTH DAKOTA       24-JUN-05
> CD  STATION         ICAO  IATA  SYNOP   LAT     LONG   ELEV   M  N  V
> U  A  C
> ND BISMARCK         KBIS  BIS   72764  46 46N  100 45W  505   X  X  U
> X  A  F 0 US
> ND DEVILS LAKE      KDVL  DVL   72757  48 07N  098 55W  443   X
>   W    7 US
> ND DEVILS LAKE      KP11  P11   72758  48 07N  098 55W  443   X
>   W    7 US
> ND DICKINSON        KDIK  DIK          46 48N  102 48W  788   X     U
>   A    6 US
> ND FARGO            KFAR  FAR   72753  46 56N  096 49W  277   X     U
>   A    1 US
> 
> 
> Code
> ====================================
> use strict;
> use warnings;
> open (ID, "stations.txt") || die ("cannot open file!!");
> while (my $stations = <ID>) {
> 	my @station = split (/\r/,$stations);
> 	foreach (@station) {
> 		print $_;
> 		if (my %stid = $_ =~ m/(?:^\w+|\s+)(KBIS|KDVL)(\s+|\w+)/) {
> 			print %stid,"\n";
> 			if ( defined ($stid{KBIS})) {
> 				print $stid{KBIS};
> 			}
> 		}
> 	}
> }
> 
> It does not return anything in the print after the hash is initialized.

Perhaps you want something like this:

use strict;
use warnings;

open ID, '<', 'stations.txt' or die "cannot open 'stations.txt' $!";

while ( my $stations = <ID> ) {
    next unless $stations =~ /\A.{20}(KBIS|KDVL)\s+(.+)/;
    print "$1: $2";
}




John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall


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

Date: 20 Nov 2006 09:44:42 -0800
From: "marie" <mariecuddy@gmail.com>
Subject: parsing a string
Message-Id: <1164044682.207094.6560@h54g2000cwb.googlegroups.com>

I have a string for example "perl878juio"

I want to cut off everthing beginning with the first number, so I would
be left with "perl"

Is there a simply way to do this?



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

Date: 20 Nov 2006 10:04:38 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: parsing a string
Message-Id: <1164045878.633146.326990@m7g2000cwm.googlegroups.com>

marie wrote:
> I have a string for example "perl878juio"
>
> I want to cut off everthing beginning with the first number, so I would
> be left with "perl"
>
> Is there a simply way to do this?

Yes.

Use a regular expression and the s/// operator.  Search for a digit
followed by "anything", and replace with nothing.

Read `perldoc perlretut` to get you started with doing this.  Once you
make your attempt, feel free to post a short-but-complete script here
if it does not work to your satisfaction.

Paul Lalli



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

Date: Mon, 20 Nov 2006 18:42:31 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: parsing a string
Message-Id: <rGm8h.19764$C94.4470@edtnps82>

marie wrote:
> I have a string for example "perl878juio"
> 
> I want to cut off everthing beginning with the first number, so I would
> be left with "perl"
> 
> Is there a simply way to do this?

$ perl -le'$_ = q[perl878juio]; print; s/\d.*//; print'
perl878juio
perl



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall


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

Date: 20 Nov 2006 11:04:46 -0800
From: "LHradowy" <lhradowy@gmail.com>
Subject: perl -d memory fault and core dump.
Message-Id: <1164049486.624601.303550@h54g2000cwb.googlegroups.com>

 I just installed:
perl 5.8.7 + defined-or + DBI 1.48 + Tk 804.027 built with gcc-4.0.0
From:
http://mirrors.develooper.com/hpux/downloads.html

I have an HP 11.00 PA_RISC System.

Looks like everything is running good, but when I try to get into the
debug mode, I get a memory fault and core dump.
user@medusa$ perl -de0
Memory fault(coredump)

My path is correct and point to the correct perl.
user@medusa$ which perl
/usr/bin/perl

/opt/perl64/bin>
acadmin@medusa$ ll /usr/bin/perl
lrwxr-xr-x   1 root       sys             20 Nov 20 11:56 /usr/bin/perl
-> /opt/perl64/bin/perl


user@medusa$ perl -V
Summary of my perl5 (revision 5 version 8 subversion 8 patch 27029)
configuration:
  Platform:
    osname=hpux, osvers=11.00, archname=PA-RISC2.0-LP64
    uname='hp-ux a5 b.11.00 u 9000800 871940681 unlimited-user license
'
    config_args='-Dusedevel -Dcc=gcc64 -Duse64bitall -des'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=define uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc64', ccflags ='-mpa-risc-2-0 -DPERL_DONT_CREATE_GVSV
-D_HPUX_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe
-Wdeclaration-after-statement -I/usr/local/pa20_64/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-g -O',
    cppflags='-mpa-risc-2-0 -DPERL_DONT_CREATE_GVSV -D_HPUX_SOURCE
-mpa-risc-2-0 -DPERL_DONT_CREATE_GVSV -D_HPUX_SOURCE -DDEBUGGING
-fno-strict-aliasing -pipe -Wdeclaration-after-statement
-I/usr/local/pa20_64/include'
    ccversion='', gccversion='4.0.2', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=87654321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='/usr/bin/ld', ldflags =' -L/usr/local/pa20_64/lib
-L/lib/pa20_64'
    libpth=/usr/local/pa20_64/lib /lib/pa20_64 /lib /usr/lib
/usr/ccs/lib /usr/local/lib
    libs=-lcl -lpthread -lnsl -lnm -lgdbm -ldb -ldl -ldld -lm -lsec -lc
    perllibs=-lcl -lpthread -lnsl -lnm -ldl -ldld -lm -lsec -lc
    libc=/lib/pa20_64/libc.sl, so=sl, useshrplib=false,
libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_hpux.xs, dlext=sl, d_dlsymun=undef, ccdlflags='-Wl,-E '
    cccdlflags='-fPIC', lddlflags='-b -L/usr/local/pa20_64/lib
-L/lib/pa20_64'


Characteristics of this binary (from libperl):
  Compile-time options: DEBUGGING PERL_DONT_CREATE_GVSV
PERL_MALLOC_WRAP
                        USE_64_BIT_ALL USE_64_BIT_INT USE_LARGE_FILES
                        USE_PERLIO
  Locally applied patches:
        defined-or
  Built under hpux
  Compiled at Feb  1 2006 12:58:01
  @INC:
    /opt/perl64/lib/5.8.8/PA-RISC2.0-LP64
    /opt/perl64/lib/5.8.8
    /opt/perl64/lib/site_perl/5.8.8/PA-RISC2.0-LP64
    /opt/perl64/lib/site_perl/5.8.8
    /opt/perl64/lib/site_perl
    .



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

Date: 20 Nov 2006 06:51:20 -0800
From: "robertospara" <robertospara@gmail.com>
Subject: Re: Perl is worth nothing!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Message-Id: <1164034280.226062.270460@b28g2000cwb.googlegroups.com>


Off course I wanted to hear voices of wisdom and I hear a lot.
Discussion is very interesting. Thanks to all and greetings to all.
I love Perl like U also. It was simple provocation. At least someone
can
take from it to defend himself as Perl programmer.
Ciao, nara, bye.

On 20 Lis, 10:52, bugbear <bugbear@trim_papermule.co.uk_trim> wrote:
> So how do you explain all the rather useful
> work people are doing with it?
> 
>    BugBear



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

Date: 20 Nov 2006 06:58:04 -0800
From: "Oliver Meister" <oli.meister@gmail.com>
Subject: Re: reg exp: helping hand needed
Message-Id: <1164034684.644104.185430@k70g2000cwa.googlegroups.com>


Paul Lalli schrieb:

> Oliver Meister wrote:
 ...
>
> I think you mean that a "separator" is a colon, two digits, and another
> colon.  Okay, but what about ":60F:" and ":62F:" ?  Are those
> separators too?  They don't match your description.
>

True! And yes, they are seperators too.

 ...

> >
> > I was trying with $fld_28 =~ s/(:28:)(.*?)/$1/ ; print $1;
> > This prints ":28:" only ...
>
 ...

> you matched - which, again, was only ":28:" - with whatever was in $1,
> which was ":28:".  So the string doesn't change at all, and $1 is
> printed out after the s///.  No idea what made you think that would do
> anything else.

A Lack of wisdom!

 ...

> You want to match all the characters, including newlines, that exist
> between ":28:" and the next insance of colon, two digits, colon.  So do
> that:
>
> if ($fld_28 =~ /:28:(.*?):\d{2}:/s){
>    print "Value: $1";
> }
>
> Paul Lalli

Thank you. Looking at it now, I SHOULD have figured out on my own. I
was too sure that I need an option like /s or /m....

Well, I'll figure out now (on my own), how I split on a single minus
sign without catching on anything else what includes a minus sign. :-)

Thanks,
Oliver



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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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