[22807] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5028 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 23 00:06:06 2003

Date: Thu, 22 May 2003 21:05:09 -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           Thu, 22 May 2003     Volume: 10 Number: 5028

Today's topics:
    Re: Copying all files in a directory (Mark Jason Dominus)
        extract pattern (vaidehi)
    Re: extract pattern <jkeen@concentric.net>
    Re: extract pattern <REMOVEsdnCAPS@comcast.net>
    Re: extract pattern (vaidehi)
    Re: extract pattern (Sara)
    Re: extract pattern (Tad McClellan)
    Re: help me with these guts (Sara)
    Re: Help strange bug: "panic: utf8_length: unaligned en <bwalton@rochester.rr.com>
    Re: HP Perl build issue <REMOVEsdnCAPS@comcast.net>
        Info files? <dont_w@nt_spam.org>
    Re: is flock() needed when reading a DB ? (dan baker)
    Re: Net::AIM help! <REMOVEsdnCAPS@comcast.net>
    Re: Parse all xml tags and put them in an array (Jay Tilton)
    Re: Parse all xml tags and put them in an array <REMOVEsdnCAPS@comcast.net>
    Re: Parse all xml tags and put them in an array (Tad McClellan)
    Re: Parse all xml tags and put them in an array (Tad McClellan)
    Re: Parse all xml tags and put them in an array <jurgenex@hotmail.com>
    Re: perl search script <minceme@start.no>
        Problem with Addition - doesn't interpret as a number? (Dave)
    Re: Problem with Addition - doesn't interpret as a numb (Jay Tilton)
    Re: Problem with Addition - doesn't interpret as a numb <bwalton@rochester.rr.com>
    Re: Scalar String concatination not working <REMOVEsdnCAPS@comcast.net>
    Re: skipping lines based on a condition <mongo.pop@verizon.net>
    Re: Software Engineer - Verilog/Perl - EDA tool develop <dha@panix.com>
    Re: splitting a very large file based on characters in  <jkeen@concentric.net>
    Re: splitting a very large file based on characters in  <harris@zk3.dec.com>
    Re: Strange output from three arrays defined in one sta <krahnj@acm.org>
        Strange output from three arrays defined in one stateme <somebody@foobar.xxx>
    Re: Strange output from three arrays defined in one sta <chad@vellum.demon.co.uk>
    Re: Strange output from three arrays defined in one sta <abigail@abigail.nl>
    Re: trying to create spaces <chris_12003@yahoo.com>
    Re: trying to create spaces <REMOVEsdnCAPS@comcast.net>
    Re: trying to create spaces (Tad McClellan)
    Re: trying to create spaces (Tad McClellan)
    Re: wierd behaviour in writing out a file <REMOVEsdnCAPS@comcast.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 22 May 2003 22:12:44 +0000 (UTC)
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Copying all files in a directory
Message-Id: <baji0s$4u9$1@plover.com>

In article <3eccd69d.3625496618@news.cis.dfn.de>,
Helgi Briem <helgi@decode.is> wrote:
>Well, as our occasionally resident guru, Mark Jason Dominus,
>once said:
>
>"#11901 You can't just make s**t up and expect the computer 
>to know what you mean, R******!"

I did not.  I said

#11901 You can't just make shit up and expect the computer 
       to know what you mean, Retardo!

If you find the words 'shit' and 'Retardo' too offensive to utter,
then perhaps you should not be quoting my offensive remark.



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

Date: 22 May 2003 15:56:44 -0700
From: vaidehi_30@yahoo.com (vaidehi)
Subject: extract pattern
Message-Id: <b20ff12f.0305221456.7e72faa2@posting.google.com>

Hello, 

I have got strings like this one:
1: 196.37.75.158:1024 - 10.10.1.12:79 (a2b)             6>    6<  (complete)

I want to extract only "196.37.75.158:1024 - 10.10.1.12:79" from this string
How do we do it?

thanks
-vaidehi


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

Date: 22 May 2003 23:40:37 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: extract pattern
Message-Id: <bajn5l$pd4@dispatch.concentric.net>


"vaidehi" <vaidehi_30@yahoo.com> wrote in message
news:b20ff12f.0305221456.7e72faa2@posting.google.com...
> Hello,
>
> I have got strings like this one:
> 1: 196.37.75.158:1024 - 10.10.1.12:79 (a2b)             6>    6<
(complete)
>
> I want to extract only "196.37.75.158:1024 - 10.10.1.12:79" from this
string
> How do we do it?
>
I'm assuming that what you want to extract may be generalized as "everything
from just after colon-wordspace up to but not including the first open
parenthesis".

my $str = "1: 196.37.75.158:1024 - 10.10.1.12:79 (a2b)             6>    6<
(complete)";
$str =~ /^.*: (.*?)\(/;
my $sought = $1 if defined $1;
print $sought, "\n";




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

Date: Thu, 22 May 2003 20:15:36 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: extract pattern
Message-Id: <Xns9383D8647F3CAsdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

vaidehi_30@yahoo.com (vaidehi) wrote in
news:b20ff12f.0305221456.7e72faa2@posting.google.com: 

> Hello, 
> 
> I have got strings like this one:
> 1: 196.37.75.158:1024 - 10.10.1.12:79 (a2b)             6>    6< 
> (complete) 
> 
> I want to extract only "196.37.75.158:1024 - 10.10.1.12:79" from this
> string How do we do it?

Well, do you mean "everything after a colon and a space but before a space 
and a parenthesis"?  Or "everything from column 4 to column 37"?  Or 
perhaps "everything that looks like an IP and port, followed by a hyphen, 
followed by another IP and port"? 

It's really not obvious what you are looking to do.

"A problem well stated is half solved."
- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPs12YWPeouIeTNHoEQL23gCfaS2kn6NgVw6jRyCglyllnnIokVEAnRgP
8wNtH2/V5TikLe8jVsICvWJR
=WawN
-----END PGP SIGNATURE-----


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

Date: 22 May 2003 18:43:48 -0700
From: vaidehi_30@yahoo.com (vaidehi)
Subject: Re: extract pattern
Message-Id: <b20ff12f.0305221743.f7bc48b@posting.google.com>

vaidehi_30@yahoo.com (vaidehi) wrote in message news:<b20ff12f.0305221456.7e72faa2@posting.google.com>...
> Hello, 
> 
> I have got strings like this one:
> 1: 196.37.75.158:1024 - 10.10.1.12:79 (a2b)             6>    6<  (complete)
> 
> I want to extract only "196.37.75.158:1024 - 10.10.1.12:79" from this string
> How do we do it?
> 
> thanks
> -vaidehi

Hello,
I could do that!
$line =$_;
$line= s/\(.+//;         #substitutes everything followed by "(" with
nothing
$line= s/.*?://;         #substitutes  evrything b4 ":" with nothing.

But it is taking two instructions to accomplish the job. Can we do it
in a single instruction??

Thanks
-Vaidehi


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

Date: 22 May 2003 19:09:47 -0700
From: genericax@hotmail.com (Sara)
Subject: Re: extract pattern
Message-Id: <776e0325.0305221809.20273b54@posting.google.com>

vaidehi_30@yahoo.com (vaidehi) wrote in message news:<b20ff12f.0305221456.7e72faa2@posting.google.com>...
> Hello, 
> 
> I have got strings like this one:
> 1: 196.37.75.158:1024 - 10.10.1.12:79 (a2b)             6>    6<  (complete)
> 
> I want to extract only "196.37.75.158:1024 - 10.10.1.12:79" from this string
> How do we do it?
> 
> thanks
> -vaidehi

This isn't really all that clear - you mean you want to drop alphas
and parens and trailing spaces?

DEPENDING on the variance of your data, you have a few options:

  s/^.*(\d+\..*\:/d+).*$/$1/; # replaces string with the part you want

* or *

  s/\d+\:\s+//; s/\s*\{\w+\).*$//; # strips of beginning and end in 2
statements

* or lots of others? 

Gx


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

Date: Thu, 22 May 2003 19:26:19 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: extract pattern
Message-Id: <slrnbcqqlb.3id.tadmc@magna.augustmail.com>

James E Keenan <jkeen@concentric.net> wrote:

> $str =~ /^.*: (.*?)\(/;
> my $sought = $1 if defined $1;


You should never use the dollar-digit variables unless you have
first ensured that the match succeeded.

$1 can be defined even when the match above fails.


   if ( $str =~ /^.*: (.*?)\(/ ) { # safe to use $1

   }


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 22 May 2003 19:13:39 -0700
From: genericax@hotmail.com (Sara)
Subject: Re: help me with these guts
Message-Id: <776e0325.0305221813.2abd55d6@posting.google.com>

Eric Wilhelm <ericw@nospam.ku.edu> wrote in message news:<pan.2003.05.22.08.30.14.783629.8205@nospam.ku.edu>...
> On Thu, 22 May 2003 07:43:27 -0500, Sara wrote:
> 
> > Not sure exactly what you're trying to do, but on the surface it looks
> > like you're a c-programmer who is trying to make his Perl look as much
> > like c as you can.
> 
> No, I'm a Perl programmer who is trying to use as little C as possible to
> create an interface to a C library which is usable from Perl:)
> 
> SWIG is a wrapper generator system.
> 
> The typemap is a chunk of code which gets spliced into the wrapped
> function to translate the C variables to Perl and vica-versa.
> 
> It is basically like building an XS module, but with less coding.
> 
> The perl-looking variables are just SWIG's way of handling the C
> variables.  They all get replaced with things like argvi and such.
> 
> --Eric

Ahh OK then I understand sorry I'm not well versed in this realm.
Didn't mean to  chime in where I'm uninitiated. I thought this was a c
dude looking to use as little Perl as possible!


Gx


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

Date: Fri, 23 May 2003 02:11:23 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Help strange bug: "panic: utf8_length: unaligned end at ....."
Message-Id: <3ECD817D.40004@rochester.rr.com>

Craig Manley wrote:

> Hi,
> 
> I've got a chat application that is now being used by french speakers. Since
> french people use a lot if non-ascii characters, my code often die's with
> this unexpected error when checking the length() of the string:
> panic: utf8_length: unaligned end at ....... line 21.
> all that line does is check the length of the string like this:
> if (length($s)) { .....
> where $s = "Jannot s'est connecté." (for example).
> 
> I can't simulate this error by copying and pasting the string + code into a
> new script, so I hope somebody can figure it out for me.
> I'm using Perl 5.6.1 on Linux.
> 
> -Craig Manley


<guess>You're attempting to process a "Latin-1" string 

using UTF8 decoding.  Won't work. </guess>


-- 
Bob Walton



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

Date: Thu, 22 May 2003 20:05:06 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: HP Perl build issue
Message-Id: <Xns9383D69C398D8sdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"k" <k@k.com> wrote in news:bain43$o0b$1@rockyflats.ardentsoftware.com:

> 
> I've been struggling with a particular problem building Perl on HP.  I

I don't know anything about HP systems, and little about threading, but:
Is there a hints file for HP?  Did you check it? 

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPs1z62PeouIeTNHoEQJO/QCgwJTvSbYrGYWja8TOD0dhmqXDhnwAoMnp
IPYIBkSEJM7DUmIBl3P3H4/O
=W23F
-----END PGP SIGNATURE-----


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

Date: Fri, 23 May 2003 02:47:55 GMT
From: Mike Ballard <dont_w@nt_spam.org>
Subject: Info files?
Message-Id: <m2of1u8jk8.fsf@west_f1.net>


Hi - 

Anyone know where (or if) I can get Info files for the latest Perl? 

Mike
-- 

mike.ballard--at--earthlink.net

  "Play an accordion, go to jail.  It's the law!"


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

Date: 22 May 2003 19:58:51 -0700
From: botfood@yahoo.com (dan baker)
Subject: Re: is flock() needed when reading a DB ?
Message-Id: <13685ef8.0305221858.4eef7809@posting.google.com>

Garry Williams <garry@ifr.zvolve.net> wrote in message news:
>     # writers use this:
> ...
>     # readers use this:
> ...
----------
thanks for your very nice simple examples. I am wondering two more
things

- if a process that has a lock on a file dies unexpectedly, I am
assuming that the lock is released.... correct?

- I test the application on windows 98, and flock() kills the script
since it is not implemented. I remember seeing somewhere that if the
flock is enclosed in an eval() it wont kill the script. (wont flock
the file either, but thats ok in my local testing.) correct?

d


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

Date: Thu, 22 May 2003 20:09:12 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Net::AIM help!
Message-Id: <Xns9383D74E622ACsdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"Richard Mahoney" <rm.mymail@NOSPAMHEREntlworld.com> wrote in
news:Re6za.10403$Mu3.200136@newsfep4-glfd.server.ntli.net: 

> Hi!
> 
> I'm having trouble sending an instant message with the Perl module
> Net::AIM. 
> 
> I can connect to the service but it will not send a message???

I note that the Net::AIM documentation is skimpy on what happens when 
things go wrong.  Perhaps you could ask the author if there's a status 
variable you could check.

Did you try the debug() method, which is supposed to display helpful 
information on STDERRR [sic]?

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPs1012PeouIeTNHoEQJnnQCgqxpZya+zduLActMTu40ipoOMdN8AoOuA
rfBKCcksxHrcnVEd8I42t4fS
=QN4i
-----END PGP SIGNATURE-----


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

Date: Thu, 22 May 2003 23:30:17 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Parse all xml tags and put them in an array
Message-Id: <3ecd5c42.200410258@news.erols.com>

post@jfl.dk (Jacob Larsen) wrote:

: Would it be possible to create a regular expression that can parse all
: xml tags and put them in an array?

Why a regex?  Is there something unacceptable about Perl's existing
XML tools?  XML::Simple looks especially useful in this case.



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

Date: Thu, 22 May 2003 20:10:50 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Parse all xml tags and put them in an array
Message-Id: <Xns9383D7952EC2Bsdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

post@jfl.dk (Jacob Larsen) wrote in news:b0ec2425.0305221343.73424525
@posting.google.com:

> Would it be possible to create a regular expression that can parse all
> xml tags and put them in an array?

Nope.  That way lies insanity.

Use one of the bazillion XML:: parsing modules.  I am only starting out 
with XML stuff, so I can't really make a recommendation or comparison, but 
I've been working with XML::DOM lately and it's been fine for me.

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPs11Q2PeouIeTNHoEQJ1wACgoSmIivpGfsN1wYQwo3z+r42j/ZcAoIJW
wITonz0KJyVJD46lqLmdeFMQ
=hzTY
-----END PGP SIGNATURE-----


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

Date: Thu, 22 May 2003 19:21:12 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Parse all xml tags and put them in an array
Message-Id: <slrnbcqqbo.3id.tadmc@magna.augustmail.com>

Jacob Larsen <post@jfl.dk> wrote:

> Would it be possible to create a regular expression that can parse all
> xml tags and put them in an array?


No.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 22 May 2003 21:52:42 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Parse all xml tags and put them in an array
Message-Id: <slrnbcr37q.3qc.tadmc@magna.augustmail.com>

Eric J. Roode <REMOVEsdnCAPS@comcast.net> wrote:
> post@jfl.dk (Jacob Larsen) wrote in news:b0ec2425.0305221343.73424525
> @posting.google.com:
> 
>> Would it be possible to create a regular expression that can parse all
>> xml tags and put them in an array?
> 
> Nope.  That way lies insanity.
> 
> Use one of the bazillion XML:: parsing modules.  I am only starting out 
> with XML stuff, so I can't really make a recommendation or comparison, but 


There is also a mailing list for discussing doing XML stuff using Perl:

   http://lists.perl.org/showlist.cgi?name=perl-xml


> I've been working with XML::DOM lately and it's been fine for me.


Unless your documents are "big".


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 23 May 2003 03:16:05 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Parse all xml tags and put them in an array
Message-Id: <Vngza.539$t42.370@nwrddc04.gnilink.net>

Jacob Larsen wrote:
> Would it be possible to create a regular expression that can parse all
> xml tags and put them in an array?

With standard regular expressions: no, because XML is not a regular
language.
With the enhanced regular expressions as supported in Perl: maybe, but no
sane person would attempt to do so.

> If so, how should I do that for the following tags?

Can't you find any XML parsers on CPAN that suits your needs?

jue




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

Date: Fri, 23 May 2003 02:06:33 +0000 (UTC)
From: Vlad Tepes <minceme@start.no>
Subject: Re: perl search script
Message-Id: <bajvn9$mqa$1@troll.powertech.no>

> Terry Carter <tcarter@entigo.com> wrote:

> I have a large log file to search that looks like this:
>
>
> [05/22/2003] Start New Trans!
> .......
> .......
> .......
> .......
> [05/22/2003] End Trans
> [05/22/2003] Start New Trans!
> .......
> .......
> .......
> .......
> [05/22/2003] End Trans
> [05/22/2003] Start New Trans!
> .......
> .......
> .......
> .......
> [05/22/2003] Start New Trans!
> .......
> .......
> .......
> .......
> [05/22/2003] End Trans
>
>
> as you can see that are times when a new trans starts without an
> ending tag.  I'd like to search for 2 start tags without an ending tag
> and display the start tag line so I can search for it in the log.
>
> Can this be done in perl and can someone give me an example?
>
> Thanks

Untested, but looks okay:


#!/usr/bin/perl
use strict;
use warnings;

my $start        = qr/Start New Trans!/;
my $end          = qr/End Trans/;
my @transactions = ();

while (<>) {

    if ( /$start/ ) { push @transactions, "line $. : $_" }

    if ( /$end/   ) {
        print "End without start, line $. : $_"
          unless pop @transactions;
    }

    if ( @transactions == 2  or  eof() and @transactions ) {
        print "Unended ", shift @transactions;
    }
}

__END__

-- 
                                              (,_    ,_,    _,)
                                              /|\`\._( )_./'/|\
                                             · ·  \/ L /\ D  · ·
                                            /__|.-'`-\_/-`'-.|__\
                                           `          "          `


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

Date: 22 May 2003 19:43:24 -0700
From: nipper1999@aol.com (Dave)
Subject: Problem with Addition - doesn't interpret as a number?
Message-Id: <ad817f81.0305221843.4d4004b3@posting.google.com>

I have a tab-delimited input file I am trying to parse.  I load the
lines into an array and when I try to add to the numbers in one of the
columns, it doesn't seem to be converting the array values to numbers.
 I am using UWIN on Windows XP.  Here is sample code:

while (<INPUT>) {
        $_ =~ s/(\r|\n)//g;
        @array = split("\t",$_);
        print "*$array[13]*\t";
        $test = $array[13] + 1;
        print "$test\n";   
} 

Output is similar to this:
*0*      1
*0.05*   1
*0.05*   1
*0*      1
*0.1*    1
*3.95*   1

What am I missing?  I want to do simple addition and I can't seem to
get it to work.  Your help is greatly appreciated!


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

Date: Fri, 23 May 2003 03:06:27 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Problem with Addition - doesn't interpret as a number?
Message-Id: <3ecd8f9f.213561311@news.erols.com>

nipper1999@aol.com (Dave) wrote:

: I have a tab-delimited input file I am trying to parse.  I load the
: lines into an array and when I try to add to the numbers in one of the
: columns, it doesn't seem to be converting the array values to numbers.
:  I am using UWIN on Windows XP.  Here is sample code:
: 
: while (<INPUT>) {
:         $_ =~ s/(\r|\n)//g;
:         @array = split("\t",$_);
:         print "*$array[13]*\t";
:         $test = $array[13] + 1;
:         print "$test\n";   
: } 
: 
: Output is similar to this:
: *0*      1
: *0.05*   1
: *0.05*   1
: *0*      1
: *0.1*    1
: *3.95*   1
: 
: What am I missing?  I want to do simple addition and I can't seem to
: get it to work.  Your help is greatly appreciated!

Freaky.

Did you accidentally set $#=1 anywhere in your program?



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

Date: Fri, 23 May 2003 03:11:41 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Problem with Addition - doesn't interpret as a number?
Message-Id: <3ECD8F9B.2040101@rochester.rr.com>

Dave wrote:

> I have a tab-delimited input file I am trying to parse.  I load the
> lines into an array and when I try to add to the numbers in one of the
> columns, it doesn't seem to be converting the array values to numbers.
>  I am using UWIN on Windows XP.  Here is sample code:
> 
> while (<INPUT>) {
>         $_ =~ s/(\r|\n)//g;
>         @array = split("\t",$_);
>         print "*$array[13]*\t";
>         $test = $array[13] + 1;
>         print "$test\n";   
> } 
> 
> Output is similar to this:
> *0*      1
> *0.05*   1
> *0.05*   1
> *0*      1
> *0.1*    1
> *3.95*   1
> 
> What am I missing?  I want to do simple addition and I can't seem to
> get it to work.  Your help is greatly appreciated!
> 

You don't say what your OS is, or to what device your output is being 
sent.  My guess is that $array[13] contains one or more leading 
non-printing control characters which are both preventing the string 
from being interpreted as a number and also are not showing up on your 
output.  You could try removing any such characters, perhaps with 
something like:

     $array[13]=~y/\000-\037//d;

prior to your prints and see if the behavior changes.

-- 
Bob Walton



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

Date: Thu, 22 May 2003 18:00:13 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Scalar String concatination not working
Message-Id: <Xns9383C130F2D7Asdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Garry Short <g4rry_short@zw4llet.com> wrote in
news:bai9gr$24h$1$830fa79f@news.demon.co.uk: 

> Warrick FitzGerald wrote:
> 
> <SNIP>
>> print $LastLine." LastLine\n";
> 
> print "$LastLine LastLine\n";
> 
> In other words, just put the variable in quotes! (For the scalar one,
> do it on two lines if you have to:
> $x = scalar $1;
> print "$x Test\n";
> )
> 
> HTH,
> 
> Garry

I'm unclear on how this will change the OP's symptoms.  What are you 
expecting will be the difference?

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPs1WTmPeouIeTNHoEQKb9ACg51eUK+0RMCmEW7lm9Msx8iQj/DkAn0JI
LAk0p8K7+9dys5ofchLoJxwx
=W6WP
-----END PGP SIGNATURE-----


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

Date: Fri, 23 May 2003 01:44:38 GMT
From: "Verne" <mongo.pop@verizon.net>
Subject: Re: skipping lines based on a condition
Message-Id: <a2fza.48$gY1.5644@news-west.eli.net>

Not sure I'm understanding this right, but it looks like you're already
processing the ^8 lines on your 'if' statement and so all you would have to
do is add the 'else' statement to push the data without processing it:
Don't count on my syntax below to be correct, and better perl programmers
could probably use the implied $_.  Also, I see you've made a mistake I also
made when I was beginning, only use 'ne' on text comparisons and '!=' on
numerical.  It does seem to work sometimes, but you'll be stuck when it
doesn't.

else { push (@out, $_); }


"david" <dwlepage@yahoo.com> wrote in message
news:b09a22ae.0305220841.40a55079@posting.google.com...
> I have a data file that has alternating lines in a comma seperated
> format like this:
> 8,00000000,xxxx,yyyyy etc etc. (There are 37 fields in records
> starting with '8')
> 37,0000000,bbbbb,ccccc,12345
> 8,00000000,ddddd,eeeeee, etcetc
> 37,0000000,fffff,gggggg,45678
>
> I want to parse only records starting with 8, and leave the 37's
> alone. I can't seem to find a way to do this. Here is what I have so
> far. (which removes the 37 lines from the output file entirely. I want
> to rewrite the file in the exact format that it is in now, without
> touching '37' records:
>
> use strict;
> my @out;
>
> if (@ARGV ne 1) {
>         print "Not enough ARGVS\n";
>         exit 0
>         }
> open (IN, "<$ARGV[0]") || die "Cannot open input file\!\n";
> open (OUT, ">Import52.txt") || die "Cannot open output file\!\n";
>
> while ( <IN> ) {
>         if (/^8\,00000000.*?/) {
>         # Split fields by ;
>         my @comments = split (/,/);
>                 if ($comments[8] =~ m/(.*)?/) {
>                         my $new = $1;
>                         $new =~ s/\//\-/g;
>                         ( $comments[8], $new ) = ( $new, $comments[8]
> );
>                         push (@out, join(",", @comments));
>                         }
>                 }
>         }
> print OUT @out;
> close(IN);
> close(OUT);




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

Date: Thu, 22 May 2003 23:43:15 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: Software Engineer - Verilog/Perl - EDA tool development - Cambridge, UK - to =?iso-8859-1?Q?c=A330,000?=
Message-Id: <slrnbcqo4j.h2f.dha@panix2.panix.com>

In article <Lg2za.7347$0a4.1416927@newsfep2-win.server.ntli.net>, ECM
Selection Ltd wrote:
> A great opportunity for a young Grad/PhD engineer to join a  near start-up
> company developing advanced EDA tools for low-power device design.


You have posted a job posting or a resume in a technical group.

Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.

Had you read and understood the Usenet user manual posted frequently to
"news.announce.newusers", you might have already known this. :)  (If
n.a.n is quieter than it should be, the relevent FAQs are available at
http://www.faqs.org/faqs/by-newsgroup/news/news.announce.newusers.html)
Another good source of information on how Usenet functions is
news.newusers.questions (information from which is also available at
http://www.geocities.com/nnqweb/).

Please do not explain your posting by saying "but I saw other job
postings here".  Just because one person jumps off a bridge, doesn't
mean everyone does.  Those postings are also in error, and I've
probably already notified them as well.

If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.

http://jobs.perl.org may be of more use to you

Yours for a better usenet,

dha
-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"Anybody's apt to trip."
"Not over a sofa!" - The Lady Eve


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

Date: 22 May 2003 23:49:59 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: splitting a very large file based on characters in a record (performance)
Message-Id: <bajnn7$pcq@dispatch.concentric.net>


"Billy" <puremeteor@yahoo.com> wrote in message
news:a8eb837.0305220655.5dc41f71@posting.google.com...
> I have a file with a large number of records (from 0.5 million to 1
> million records). Each record is of length 250 characters and does not
> have delimiters. I have to split each record into 2 separate records
> (each of 125 characters), and further I have to split the 125
> characters into different fields and based on the value of a field I
> have to write it to 2 different output fields.
>
> I would like to know if :
> 1. For a file of such huge size, should I split each record first into
> 2 and then work on it OR should I treat the whole 250 char record as
> one and split it into fields as it is?? Performance is important here
>

There's unlikely to be a significant difference.  The only way to be sure is
to write a benchmarking script -- but the time it takes you to write that
would probably be greater than the time saved by employing the results
thereof.

> 2. Is it preferable to use ksh/awk over perl here?
>
Well, if you cross-post to 3 different lists, you're likely to get 3
different answers.  But since Perl is more flexible than shell and awk, try
it in Perl.




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

Date: Fri, 23 May 2003 03:00:44 GMT
From: Bob Harris <harris@zk3.dec.com>
Subject: Re: splitting a very large file based on characters in a record (performance)
Message-Id: <harris-62CC3C.22475922052003@juggl7.zk3.dec.com>

In article <a8eb837.0305220655.5dc41f71@posting.google.com>,
 puremeteor@yahoo.com (Billy) wrote:

X I have a file with a large number of records (from 0.5 million to 1
X million records). Each record is of length 250 characters and does not
X have delimiters. I have to split each record into 2 separate records
X (each of 125 characters), and further I have to split the 125
X characters into different fields and based on the value of a field I
X have to write it to 2 different output fields.
X 
X I would like to know if :
X 1. For a file of such huge size, should I split each record first into
X 2 and then work on it OR should I treat the whole 250 char record as
X one and split it into fields as it is?? Performance is important here

One pass is going to be faster than reading the data twice and writing 
it twice.  The in memory work is trivial (performance wise) compared to 
reading and writing the data.

X 2. Is it preferable to use ksh/awk over perl here?

While I use awk for most of my text manipulation work, I would say from 
personal experience perl will be much faster than awk.  My example is 
that I had an awk script and a perl script that read sendmail files to 
generate a mail summary of who sent it and the subject line.  The perl 
script was about twice as fast.  So while I still use awk for quick and 
dirty throw away scripts and for scripts where lots of data is not going 
to be processed, I will use perl if the amount of data to be processed 
is large and I will need to do it more than once of twice.

X 3. Is it ok to use the "cut" command here?

Without seeing the data and the rules for separating the data, it is 
difficult to say if cut would be a better choice.
 
X Regards,
X Billy


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

Date: Thu, 22 May 2003 22:42:32 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Strange output from three arrays defined in one statement.   Can  anyone explain?
Message-Id: <3ECD5249.AEB85A37@acm.org>

who me? wrote:
> 
> Here is, in its entirety, a script demonstrating
> what seems strange output. Of course, I can do what
> I want in a different way, but can anyone explain?
> 
> #!/usr/local/bin/perl -w
> use 5.6.1;
> use strict;
> $|=1;         # shouldn't need this, but ...
> my (@a, @b, @c) = (
>     qw/a b c/,
>     qw/1 2 3/,
>     qw/p q r/
>   );
> for(@a){
>   print "$_\n";
> }
> print "======\n";
> for(@b){
>   print "$_\n";
> }
> print "++++++\n";
> for(@c){
>   print "$_\n";
> }
> print "------\n";
> 
> this gives the following output:
> 
> a
> b
> c
> 1
> 2
> 3
> p
> q
> r
> ======
> ++++++
> ------
> 
> Strange?!

No, it is normal.  You are telling perl to store all the values in @a
and nothing in @b or @c.  That is the way arrays and lists work in perl.


John
-- 
use Perl;
program
fulfillment


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

Date: Thu, 22 May 2003 15:14:59 -0700
From: who me? <somebody@foobar.xxx>
Subject: Strange output from three arrays defined in one statement.   Can anyone explain?
Message-Id: <dpiqcvk8bpqkr8d16kvmg2kc9f52odaq85@4ax.com>

Here is, in its entirety, a script demonstrating
what seems strange output. Of course, I can do what 
I want in a different way, but can anyone explain?


#!/usr/local/bin/perl -w
use 5.6.1;
use strict;
$|=1;         # shouldn't need this, but ...
my (@a, @b, @c) = (
    qw/a b c/,
    qw/1 2 3/,
    qw/p q r/
  );
for(@a){
  print "$_\n";
}
print "======\n";
for(@b){
  print "$_\n";
}
print "++++++\n";
for(@c){
  print "$_\n";
}
print "------\n";



this gives the following output:

a
b
c
1
2
3
p
q
r
======
++++++
------

Strange?!

I am really 
mdonn
at
harbornet
dot
com



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

Date: Thu, 22 May 2003 23:32:22 +0100
From: Chad Hanna <chad@vellum.demon.co.uk>
Subject: Re: Strange output from three arrays defined in one statement.   Can anyone explain?
Message-Id: <i4kTjuP2$Uz+Ew+n@vellum.demon.co.uk>

In message <dpiqcvk8bpqkr8d16kvmg2kc9f52odaq85@4ax.com>, who me? 
<somebody@foobar.xxx> writes
>Here is, in its entirety, a script demonstrating
>what seems strange output. Of course, I can do what
>I want in a different way, but can anyone explain?
>
>
>#!/usr/local/bin/perl -w
>use 5.6.1;
>use strict;
>$|=1;         # shouldn't need this, but ...
>my (@a, @b, @c) = (
>    qw/a b c/,
>    qw/1 2 3/,
>    qw/p q r/
>  );
>for(@a){
>  print "$_\n";
>}
>print "======\n";
>for(@b){
>  print "$_\n";
>}
>print "++++++\n";
>for(@c){
>  print "$_\n";
>}
>print "------\n";
>
>
>
>this gives the following output:
>
>a
>b
>c
>1
>2
>3
>p
>q
>r
>======
>++++++
>------
>
>Strange?!
>
>I am really
>mdonn
>at
>harbornet
>dot
>com
>
Perl flattens the list on the right hand side of the assignment, so all 
3 lists are treated as one list.
In the assignment an array on the left hand side is greedy and will 
'eat' any remaining elements on the right hand side. This explains your 
output.

-- 
Chad Hanna
Chairman Berkshire Family History Society www.berksfhs.org.uk
Quality Family History Data www.familyhistoryonline.net


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

Date: 22 May 2003 23:25:40 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Strange output from three arrays defined in one statement.   Can anyone explain?
Message-Id: <slrnbcqn3j.kuj.abigail@alexandra.abigail.nl>

who me? (somebody@foobar.xxx) wrote on MMMDLI September MCMXCIII in
<URL:news:dpiqcvk8bpqkr8d16kvmg2kc9f52odaq85@4ax.com>:
::  Here is, in its entirety, a script demonstrating
::  what seems strange output. Of course, I can do what 
::  I want in a different way, but can anyone explain?
::  
::  
::  #!/usr/local/bin/perl -w
::  use 5.6.1;
::  use strict;
::  $|=1;         # shouldn't need this, but ...
::  my (@a, @b, @c) = (
::      qw/a b c/,
::      qw/1 2 3/,
::      qw/p q r/
::    );

A list assignment. On the left hand side, three arrays. On the right
hand side, a nine element list. Perl will assign all the elements
of the right hand side list to the first array (@a), while @b and @c
remain empty.



Abigail
-- 
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))


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

Date: Thu, 22 May 2003 16:49:47 -0700
From: "Chris" <chris_12003@yahoo.com>
Subject: Re: trying to create spaces
Message-Id: <vcqm8grp32dbd5@corp.supernews.com>

I'm not being rude.  I was simply asking a question and apparently in the
wrong place.  Since it had to do with a perl variable I assumed variables
couldn't be used in html but apparently I'm wrong.  Html does allow the
spaces to display but I need to join "a             b" to a variable and
when I attempt to display it in html using $variable it doesn't work.  Again
if I wasn't using variables it would be easy to display a               b
but again I'm using variables and perl or whatever it is I'm programming in
removes the spaces before displaying.

I apologize for posting in the wrong place.  Thanks for telling me I was Top
Posting, from this day forward I will only post my question and remove the
text of the other person I'm replying to.

- Chris




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

Date: Thu, 22 May 2003 20:20:50 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: trying to create spaces
Message-Id: <Xns9383D9479EA20sdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"Chris" <chris_12003@yahoo.com> wrote in
news:vcqm8grp32dbd5@corp.supernews.com: 

> I'm not being rude.  I was simply asking a question and apparently in
> the wrong place.  Since it had to do with a perl variable I assumed
> variables couldn't be used in html but apparently I'm wrong.  Html
> does allow the spaces to display

Well, not really.  The HTML standards state that all whitespace is 
effectively reduced to a single space.


> but I need to join "a             b"
> to a variable and when I attempt to display it in html using $variable
> it doesn't work.

Right.  Perl is outputting "a          b" as you desire.  Your browser is 
displaying it as "a b" because that's what it's supposed to do.

There are a number of ways to get the browser to display the string the way 
you want.  Which way is correct depends on what you're trying to do.  Such 
a discussion would be way off-topic for this newsgroup.  Perhaps you could 
try in comp.infosystems.www.authoring.html or 
comp.infosystems.www.authoring.stylesheets.

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPs13l2PeouIeTNHoEQKLNQCfdYvtGjlkcnUHtMG7mwlh72gwQ2gAoIwN
k3cYKNY6XOoMnUinGW+6cqVs
=RlvA
-----END PGP SIGNATURE-----


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

Date: Thu, 22 May 2003 19:50:42 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: trying to create spaces
Message-Id: <slrnbcqs32.3id.tadmc@magna.augustmail.com>

Chris <chris_12003@yahoo.com> wrote:

> I'm not being rude.  


Who said that you _were_ being rude?

It is customary to quote a bit of context when you are commenting
on what was said.


> Thanks for telling me I was Top
> Posting, from this day forward I will only post my question and remove the
> text of the other person I'm replying to.


That isn't the proper way of formatting a followup either.

Have you seen the Posting Guidelines that are posted here frequently?

They offer many tips to avoid appearing rude...


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 22 May 2003 21:20:18 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: trying to create spaces
Message-Id: <slrnbcr1b2.3id.tadmc@magna.augustmail.com>

Chris <chris_12003@yahoo.com> wrote:

> I assumed variables
> couldn't be used in html but apparently I'm wrong.  


No, you are right.

There are no "variables" in HTML. HTML is not a programming language.


> Html does allow the
> spaces to display 


HTML does not "display" anything.

HTML is just "data" it does not "do" anything, it has things done to it.

A _browser_ may display multiple consecutive spaces, but it would be 
a rare one. Common browsers will "squeeze" them down to a single space.


> but I need to join "a             b" to a variable and
> when I attempt to display it in html 


How do you display it in HTML? ie. in which browser?

Have you looked at the actual HTML that your program outputs?


> using $variable it doesn't work.  


Telling us it "doesn't work" does not help us help you.

What output is it making? What output were you expecting it to make?


> Again
> if I wasn't using variables it would be easy to display a               b


Not using HTML in any of the common browsers, it won't.

It is easy to _output_ multiple spaces from Perl, but how they
get _displayed_ is up to the browser, not to your CGI program.


> but again I'm using variables and perl or whatever it is I'm programming in
> removes the spaces before displaying.


It is not what you are programming in (Perl), it is what is 
displaying it (browser).

We do not need to know how it is displayed in order to be able 
to help you with a Perl problem.

We _do_ need to know what _output_ your CGI program is supposed to make,
what happens to the data after Perl outputs it will not matter as
far as fixing your program is concerned...

 ... and therefore your first question to answer is:

   What output must this program make?

The answer to _that_, in turn, is found elsewhere (HTML or browser newsgroup).


It will be easy for you to write a program that makes the output you want,
if you know what output you want when you write it.   :-)


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 22 May 2003 20:03:16 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: wierd behaviour in writing out a file
Message-Id: <Xns9383D64CB7136sdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

TruthXayer <TruthXayer@yahoo.com> wrote in
news:3ECD0174.39D1855B@yahoo.com: 

> Yes, Its using write from a large hash...Again I think its a
> file system issue
> rather than a script thingy. I just leanred that the disk
> was full and someone was
> deleting files while the script was running. Will this cause
> the behavious observed?

Hard to say.  It's possible, I think.  Well, I'm glad the problem isn't 
happening at the moment.  Good luck.

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPs1zfWPeouIeTNHoEQJ2ZgCgu3Yx+dZZvZEGjsxz6LGa1fA7LZ0AoMjq
I3wK5rQAaxj9U5lT6QwXvtha
=WijC
-----END PGP SIGNATURE-----


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

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


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