[25517] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7761 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 9 14:05:45 2005

Date: Wed, 9 Feb 2005 11:05:20 -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           Wed, 9 Feb 2005     Volume: 10 Number: 7761

Today's topics:
        Alternative in regexps <grabek@invalid.com>
    Re: back references <bogus@nowhere.net>
    Re: back references (Anno Siegel)
        Easy Method to 'slurp' a line toeknized by split <rhugga@yahoo.com>
    Re: Easy Method to 'slurp' a line toeknized by split <mritty@gmail.com>
    Re: Easy Method to 'slurp' a line toeknized by split <nobull@mail.com>
    Re: Easy Method to 'slurp' a line toeknized by split <jgibson@mail.arc.nasa.gov>
    Re: Easy Method to 'slurp' a line toeknized by split <postmaster@castleamber.com>
    Re: How to resolve parameter read from text file in per <noreply@gunnar.cc>
    Re: How to resolve parameter read from text file in per <nobull@mail.com>
    Re: How to resolve parameter read from text file in per <nobull@mail.com>
    Re: Net::SSH::Perl sending output to STDOUT ryanmhuc@yahoo.com
        Perl debugger has wrong initial entry point and line nu luke_airig@hotmail.com
        regex help (Rainer Collet)
    Re: Regexp::Common question related to URI query <info4l@info-for-life.com>
    Re: Regexp::Common question related to URI query <phaylon@dunkelheit.at>
    Re: The Problem with Perl ioneabu@yahoo.com
    Re: The Problem with Perl <goedicke@brandeis.edu>
    Re: The Problem with Perl <rhugga@yahoo.com>
    Re: The Problem with Perl <phaylon@dunkelheit.at>
    Re: The Problem with Perl xhoster@gmail.com
    Re: Trouble with Regexps <generic_x@hotmail.com>
    Re: using perl to submit username/password and access s <segraves_f13@mindspring.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 9 Feb 2005 18:52:53 +0000 (UTC)
From: Lukasz Grabun <grabek@invalid.com>
Subject: Alternative in regexps
Message-Id: <slrnd0kmpl.2pb.grabek@localhost.localdomain>

Hello,

Say there is a HTML code containting HTML tags (oh, really?) to which we 
want to add id="p-$number" attribute. The number, after each insertion, 
is increased by, say, five in order to make ids unique. I guess it can 
be easily done with regexps though I couldn't figure out the way. Here's 
what I've come up with so far:

#!/usr/bin/perl -w

# getting input values
$prefix = $ARGV[0]; $infile = $ARGV[1]; $outfile = $ARGV[2];

open(INPUT,"<$infile");
open(OUTPUT,">$outfile");

$number = 5;
while (<INPUT>)
{

# match any element worth adding an id to

    if (s/(\<p)|(\<h1)|(\<h2)|(\<h3)|(\<h4)|(\<h5)|(\<h6)|
       (\<blockquote)|(\<ul)|(\<ol)|(\<em)|(\<strong)/$1 
	id=\"$prefix-$number\"/)
	{ $number += 5; } # and increase the counter
    print OUTPUT $_;
}

I am very new to perl so please don't critisize my poor coding skills.

Anyway, this one does not work; or rather it does the work but only 
under special circumstances which are not alway true when dealing with 
real HTML (this works fine, for example, when all tags are in seperate 
lines but since you can embed <p> in <dl> you can't assume it will 
always happen).

To put myself even more clearly

 ./script prefix test1 test2 where test1 file looks as follows

<p><dd>
<dl><p><em><strong><h1><dd>

yields an output (test2 file)

<p id="prefix-5"><dd>
<dl><p id="prefix-10"><em><strong><h1><dd>

As you can see the "if" condition is fullfilled when just one of 
alternatives is satisfied. Quite logical. Of course, the required output 
looks like:

<p id="prefix-5"><dd id="prefix-10">
<dl id="prefix-15"> (and so on).

I tried to tinker with \G assertion but it does not lead me anywhere - 
the program seems to loop infinetely; I had to screwed something.

Could anyone, please, provide me with few tips or a proper google query?
Thanks in advance.



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

Date: Wed, 9 Feb 2005 12:31:52 -0500
From: "REH" <bogus@nowhere.net>
Subject: Re: back references
Message-Id: <cudhe9$igo3@cui1.lmms.lmco.com>


"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:cudbuc$n1g$2@mamenchi.zrz.TU-Berlin.DE...
> > I'm sorry for being vague.  I mean using backreferences in the
replacement
> > part of a regular expression.  I need to have a "\1" immediately
followed by
> > a number, such as "\11" but the last one is not part of the
backreference.
>
> You don't use that kind of backreference in the replacement part, you
> use the capturing variables $1, $2, etc.  This is simple string
> interpolation:  "${1}2".
>
> Anno

Thank you.  That's interesting.  I've always used the backslash form and
Perl allowed it.  Is there a difference between the two?





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

Date: 9 Feb 2005 18:55:46 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: back references
Message-Id: <cudmbi$12j$1@mamenchi.zrz.TU-Berlin.DE>

REH <bogus@nowhere.net> wrote in comp.lang.perl.misc:
> 
> "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
> news:cudbuc$n1g$2@mamenchi.zrz.TU-Berlin.DE...
> > > I'm sorry for being vague.  I mean using backreferences in the
> replacement
> > > part of a regular expression.  I need to have a "\1" immediately
> followed by
> > > a number, such as "\11" but the last one is not part of the
> backreference.
> >
> > You don't use that kind of backreference in the replacement part, you
> > use the capturing variables $1, $2, etc.  This is simple string
> > interpolation:  "${1}2".
> >
> > Anno
> 
> Thank you.  That's interesting.  I've always used the backslash form and
> Perl allowed it.  Is there a difference between the two?

Use \1, etc only inside the regex itself (you don't need that often).
Use $1, etc everywhere else, including the replacement part of s///.
See "perldoc perlre", look for "Warning on" (... \1 vs $1).

Anno



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

Date: 9 Feb 2005 10:02:54 -0800
From: "Rhugga" <rhugga@yahoo.com>
Subject: Easy Method to 'slurp' a line toeknized by split
Message-Id: <1107971996.823903.259010@o13g2000cwo.googlegroups.com>


I am writing a syslog parser that normalizes log entries and the loads
them into a oracle database, I open the input file and process each
line and tokenize it for use but I am running into a roadblock that I
can't seem to find a clean solution for. (my perl skills have grown
rusty over the years)

Here is a sample entry from my input file:

1 Feb  8 00:05:41 back-0202 tldcd[928]: [ID 359804 daemon.notice]
TLD(0) opening robotic path /dev/sg/c3t0l0

This is basically 7 fields of info:
<log count> <timestamp (3 fields)> <hostname> <process info> <log
content>

(<log count> is the number of times an identical log entry was detected
and truncated)

So using split I break this down into components:

        @ARGS = (split / /, $line);
        $line =~ s/ +/ /g;
        $line =~ s/^ +//g;
        $log_count      = $ARGS[0];
        $log_month      = $ARGS[1];
        $log_day        = $ARGS[2];
        $log_time       = $ARGS[3];
        $log_hostname   = $ARGS[4];
        $log_proc_info  = $ARGS[5];
        $log_message    = $ARGS[6];

My problem is I want $log_message to contain everything after the
process info field. (in the sample entry above, $log_proc_info will
contain tldcd[928]). However $log_message will only contain the next
space delimited field, in this case it will be '[ID'. WHat I want to do
is after I glean $log_proc_info, I then want to set $log_message to the
remaining bytes up to but not including EOL. (ie: I want $log_message =
"[ID 359804 daemon.notice] TLD(0) opening robotic path /dev/sg/c3t0l0"
)

I hope this is making sense, I have working on no sleep as usual.

Thanks for any help,
CC



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

Date: Wed, 09 Feb 2005 18:13:47 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Easy Method to 'slurp' a line toeknized by split
Message-Id: <vpsOd.13447$ya6.11983@trndny01>

"Rhugga" <rhugga@yahoo.com> wrote in message
news:1107971996.823903.259010@o13g2000cwo.googlegroups.com...
>
>         @ARGS = (split / /, $line);
>         $line =~ s/ +/ /g;
>         $line =~ s/^ +//g;
>         $log_count      = $ARGS[0];
>         $log_month      = $ARGS[1];
>         $log_day        = $ARGS[2];
>         $log_time       = $ARGS[3];
>         $log_hostname   = $ARGS[4];
>         $log_proc_info  = $ARGS[5];
>         $log_message    = $ARGS[6];
>
> My problem is I want $log_message to contain everything after the
> process info field.

Have you considered reading the documentation for the function you're
using?  The solution is readily available to anyone who reads
perldoc -f split
(fourth paragraph)

Paul Lalli




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

Date: 9 Feb 2005 10:21:40 -0800
From: "nobull@mail.com" <nobull@mail.com>
Subject: Re: Easy Method to 'slurp' a line toeknized by split
Message-Id: <1107973300.067971.108290@g14g2000cwa.googlegroups.com>

Rhugga wrote:

>         @ARGS = (split / /, $line);

>         $log_count      = $ARGS[0];
>         $log_month      = $ARGS[1];
>         $log_day        = $ARGS[2];
>         $log_time       = $ARGS[3];
>         $log_hostname   = $ARGS[4];
>         $log_proc_info  = $ARGS[5];
>         $log_message    = $ARGS[6];

This is more simply written

my ($log_count,$log_month,$log_day,$log_time,$log_hostname,
    $log_proc_info,$log_message) = split / /, $line;

Note: I've guessed that the omission of my() was a mistake since it
probably was.  An assignment without a my() overwrites one or more
existing variables rather then intruducing new ones.  Unless you have a
possitive reason to modify an existing variable it is generally not a
good idea to do so.

Note: It would probably be more natural to represent the parsed record
as a hash rather than 7 separate scalars.  It is generally a good idea
to us the natural representations of things unless you have a positive
reason to do otherwise.

my %log;
@log{'count','month','day','time','hostname',
     'proc_info','message'} = split / /, $line;

> My problem is I want $log_message to contain everything after the
> process info field. (in the sample entry above, $log_proc_info will
> contain tldcd[928]).

You appear to have a question about the split() function.

Have you considered the radical option of looking-up the description of
the split function in the reference manual?

Pay particular attension to the semantics of the 4th argument.



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

Date: Wed, 09 Feb 2005 10:22:56 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Easy Method to 'slurp' a line toeknized by split
Message-Id: <090220051022560801%jgibson@mail.arc.nasa.gov>

In article <1107971996.823903.259010@o13g2000cwo.googlegroups.com>,
Rhugga <rhugga@yahoo.com> wrote:

> I am writing a syslog parser that normalizes log entries and the loads
> them into a oracle database, I open the input file and process each
> line and tokenize it for use but I am running into a roadblock that I
> can't seem to find a clean solution for. (my perl skills have grown
> rusty over the years)
> 
> Here is a sample entry from my input file:
> 
> 1 Feb  8 00:05:41 back-0202 tldcd[928]: [ID 359804 daemon.notice]
> TLD(0) opening robotic path /dev/sg/c3t0l0
> 
> This is basically 7 fields of info:
> <log count> <timestamp (3 fields)> <hostname> <process info> <log
> content>
> 
> (<log count> is the number of times an identical log entry was detected
> and truncated)
> 
> So using split I break this down into components:
> 
>         @ARGS = (split / /, $line);
>         $line =~ s/ +/ /g;
>         $line =~ s/^ +//g;

Why are you modifying $line after its components have been placed in
@ARGS? Why is ARGS in all caps?

>         $log_count      = $ARGS[0];
>         $log_month      = $ARGS[1];
>         $log_day        = $ARGS[2];
>         $log_time       = $ARGS[3];
>         $log_hostname   = $ARGS[4];
>         $log_proc_info  = $ARGS[5];
>         $log_message    = $ARGS[6];
> 
> My problem is I want $log_message to contain everything after the
> process info field. (in the sample entry above, $log_proc_info will
> contain tldcd[928]). However $log_message will only contain the next
> space delimited field, in this case it will be '[ID'. WHat I want to do
> is after I glean $log_proc_info, I then want to set $log_message to the
> remaining bytes up to but not including EOL. (ie: I want $log_message =
> "[ID 359804 daemon.notice] TLD(0) opening robotic path /dev/sg/c3t0l0"
> )

Use various combinations of split, substr, index, unpack, and
custom-written regular expressions to parse your input line and extract
the information therein. You have not given us enough information about
your input to recommend which methods apply. E.g., if your log message
always starts with '[' you can find it in the line with
index($line,'[') or extract it with the regex m/(\[ID.*)/.

In general, use unpack or substr to extract information from
fixed-format lines. Use split, index, and regex to extract from
variable-format lines.

You could do this (untested):

   my ($log_count, $log_month, $log_day, $log_time, $log_hostname,
      $log_proc_info, @rest ) = split( / /, $line);
   my $log_message = join(' ',@rest);

To put all trailing fields into log_message, but you will lose any
extra spaces. If that is important, use this instead (also untested):

   my $log_message = substr($line,index($line,'['));


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


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

Date: 9 Feb 2005 18:30:37 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Easy Method to 'slurp' a line toeknized by split
Message-Id: <Xns95F87F40E9276castleamber@130.133.1.4>

nobull@mail.com wrote:

> Rhugga wrote:

[ .. ]

> my %log;
> @log{'count','month','day','time','hostname',
>      'proc_info','message'} = split / /, $line;

@log{ qw( count month day time ...

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: Wed, 09 Feb 2005 16:59:57 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: How to resolve parameter read from text file in perl script
Message-Id: <36uqqkF56j4qcU1@individual.net>

Gancy wrote:
> I have a perl script which reads parameters from text file and builds
> the command line string for another perl script.  and i intend to
> execute the same with systm command.

<snip>

> print $CmdLine;
> 
> perl BinaryParser.pl -d ~gancy/testsource pwd
> 
> system("$CmdLine");
> 
> but the problem is system command does not resolve ~ and pwd.

Why are you using system() to invoke another Perl script? Why not

     @ARGV = qw(-d ~gancy/testsource pwd);
     do 'BinaryParser.pl';

or to also check for errors

     defined do 'BinaryParser.pl' or die $!;

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 9 Feb 2005 10:26:12 -0800
From: "nobull@mail.com" <nobull@mail.com>
Subject: Re: How to resolve parameter read from text file in perl script
Message-Id: <1107973572.935148.49410@f14g2000cwb.googlegroups.com>


Gunnar Hjalmarsson wrote:
> Gancy wrote:
> > system("$CmdLine");
> >
> > but the problem is system command does not resolve ~ and pwd.
>
> Why are you using system() to invoke another Perl script?

He is using it to resolve ~.



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

Date: 9 Feb 2005 10:30:58 -0800
From: "nobull@mail.com" <nobull@mail.com>
Subject: Re: How to resolve parameter read from text file in perl script
Message-Id: <1107973858.461246.217930@z14g2000cwz.googlegroups.com>


Gancy wrote:

> if i print the string would look like
> print $CmdLine;
>
> perl BinaryParser.pl -d ~gancy/testsource pwd
>
> system("$CmdLine");
>
> but the problem is system command does not resolve ~ and pwd.

What do you mean by 'resolve pwd'? The string 'pwd' does not contain
any shell metacharacters.

> I have tried same in C, it works exactly as i want.

Works here for me with perl5.6.1 and 5.8.5 on Linux.

What's your perl -V ?

Have you read 'perldoc -q tilde' ?



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

Date: 9 Feb 2005 10:06:29 -0800
From: ryanmhuc@yahoo.com
Subject: Re: Net::SSH::Perl sending output to STDOUT
Message-Id: <1107972389.391411.33760@c13g2000cwb.googlegroups.com>

Martin,
  I think theres a misunderstanding here. The code i am using is in the
first post. And its not like the method $ssh->login is kicking back an
error here if the pass is wrong it is exiting my program and printing
"Permission denied" to the STDOUT. Of course its not going to login if
the pass is wrong but why in the world is it halting my program?

after executing:
$ssh->login($user || $this_user, $pass);

the program dies and prints
"Permission denied at test.pl line 43"

I don't want my program to exit at this statment if the password is
incorrect. How do I do that? How do I trap it? Perhaps this is the
behavior of the module but what good is it if you can't error trap if
the password is incorrect.

Martin Kissner wrote:
> ryanmhuc@yahoo.com wrote :
> > Thanks for the script but it does the same thing.
>
> What same thing?
>
> >                                                   If the password
is
> > incorrect for the login i get:
> > "Permission denied at test.pl line 43"
> > and then it stops the program.
>
> What do you expect? If the pw is incorrect you should't be able to
log
> in, should you?
>
> >                                The issue is I need to catch this.
The
> > script I'm trying to create logins into about 16 different servers.
> > These servers passwords are not supposed to change but every once
in a
> > while one does. I want the program to not die when it can't login
to
> > the server but instead trap it, let me know and then continue with
the
> > script.
>
> Then you should probably check for success.
> if (your command) {
> 	do stuff;
> }
> else {
> 	do other stuff;
> }
>
> btw:
> You'd probably increase your chances of getting qualified help by
> avoiding TOFU quoting an providing some code example.
>
> HTH
> Martin
>
> [ TOFU snipped ]
>
> --
> perl -e 'print
7.74.117.115.116.11.32.13.97.110.111.116.104.101.114.11
> .32.13.112.101.114.108.11.32.13.104.97.99.107.101.114.10.7'



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

Date: 9 Feb 2005 10:02:16 -0800
From: luke_airig@hotmail.com
Subject: Perl debugger has wrong initial entry point and line numbers
Message-Id: <1107972136.540745.16310@c13g2000cwb.googlegroups.com>

UNIX SunOS 5.8, Perl version 5.003

When I invoke the Perl debugger on the following script, the debugger
entry point is line 5 (which inreality is line 75) as follows:

Stack dump during die enabled outside of evals.

Loading DB routines from perl5db.pl patch level 0.94
Emacs support available.

Enter h or `h h' for help.

Unquoted string "null" may clash with future reserved word at junk.perl
line 70.
Useless use of a constant in void context.
main::(junk.perl:5):
5:      #print "Loaded list\n";
  DB<1> w
2:        }
3:      }
4:      close(LIN); # we are done we have our list array.
5==>    #print "Loaded list\n";
6:
7:      open(INFILE, $datainputfile) or die "Can not open input
$datainputfile";
8:      open(OUTFILE, "> " . $dataoutputfile) or die "Can not open
output $dataoutputfile";
9:
10:     # read in real data and put in array!
11:
  DB<1>

How can I get the debugger to start at the first executable line and
accurately reflect the source code
line numbers?


Here is the source code:

#!/usr/bin/perl

# variables

$sortlistfile = "";
$datainputfile = "";
$dataoutputfile = "";
$CMD = "";
$hit99 = 0; # boolean to trigger email with 99 notice

$NOTIFY = `cat /opt/apps/empower/cpi/control/CPI.notify`;
chomp($NOTIFY);
print $NOTIFY;

# take in file names as command line arguments. First the mask list,
# then the data input, then the data output.


chomp($ARGV[0]);
if ($ARGV[0] eq "-c") { exit; }

if (!($ARGV[2]))
{
  print "Execute with: 'cpisort.perl masklist datainput dataoutput
[prog_to_run]'\n";
  exit;
} else {
  $sortlistfile = $ARGV[0];
  $datainputfile = $ARGV[1];
  chomp($ARGV[2]);
  $dataoutputfile = $ARGV[2];
  chomp($ARGV[3]);
  $CMD = $ARGV[3];
}

@LIST = ""; # array holding list of sort patterns in sort order!
@DATA = ""; # array holding data from real input file. Index is
integer!
@MASKHITS = ""; #array holding relationship between masks
                # in @LIST and lines in @DATA. @LIST index is index,
                # while data is index from @DATA
@CARDLINE = ""; # will eventually contain list of lines split from
                 # @MASKHITS data to be printed as a group.

$TRUE = 1;
$opline = "";
$opmask = "";
$card_line_ctr = 0;
$file_line_ctr = 0;
$file_max = 0;
$list_line_ctr = 0;
$list_max = 0;
$knownmask = 0;
$ldelim = "~";

open(LIN, $sortlistfile) or die "Can not open $sortlistfile";

# read in list

while ($sline = <LIN>)
{
  chomp($sline);
  if ($sline)
  {
    if (!(substr($sline,0,1) =~ /^\#/))
    {
       $list_line_ctr++;
       $list_max++;
       $LIST[$list_line_ctr] = $sline;
       #print "list " . $list_line_ctr . " " . $LIST[$list_line_ctr] .
"\n";
    } else {
       null; # is a comment
    }
  }
}
close(LIN); # we are done we have our list array.
#print "Loaded list\n";

open(INFILE, $datainputfile) or die "Can not open input
$datainputfile";
open(OUTFILE, "> " . $dataoutputfile) or die "Can not open output
$dataoutputfile";

# read in real data and put in array!

while ($fline = <INFILE>)
{
  chomp($fline);
  if ($fline)
  {
     $file_line_ctr++;
     $file_max++;
     $DATA[$file_line_ctr] = $fline;
  }
}

# we don't need the INFILE any more we have it in an array
close(INFILE);

#print "Loaded \@DATA array\n";

# Now. Loop through @DATA line by line. Extract the bytes from
# positions 1, 2, 3, 14, 15, 18, 24, 64, 69, 80. Compare the resulting
string
# with ALL the masks in @LIST. If a match is found, use the @LIST index

# number as the index value into @MASKHITS, and take the index from
@DATA,
# the $file_line_ctr, and append it to the existing data value for
@MASKHITS.
# E.g., $MASKHITS[$list_line_ctr] = $MASKHITS[$list_line_ctr] .
# . $file_line_ctr . "~";
#

$file_line_ctr = 1; # must start at 1 or first element will look like
NULL
while ($file_line_ctr <= $file_max)
{
  $opline = $DATA[$file_line_ctr];
  #print "line " . $opline ."\n";
  $opmask = substr($opline,0,3)
  . substr($opline,8,1)
  . substr($opline,13,3)
  . substr($opline,17,1)
  . substr($opline,23,1)
  . substr($opline,63,1)
  . substr($opline,68,1)
  . substr($opline,79,1);

  $lnum = substr($opline,89,13);

  #print "linemask " . $file_line_ctr . " " . $opmask . "\n";

  $knownmask = 0;

  for ($list_line_ctr = 1; $list_line_ctr <= $list_max;
$list_line_ctr++)
  {
    #print "compare " . $opmask . "-" . $list_line_ctr . "-" .
$LIST[$list_line_ctr] . "\n";
    if ($opmask =~ /$LIST[$list_line_ctr]/)
    {
      # Our real line mask matches!
      $MASKHITS[$list_line_ctr] = $MASKHITS[$list_line_ctr]
      . $file_line_ctr . $ldelim;
      #print "matched " . $list_line_ctr . "-" .
$MASKHITS[$list_line_ctr] . "\n";
      $knownmask = 1;
      last;
    }
  }
  # check to make sure we found a matching mask. If not, put the line
in a
  # '99' category to be printed last.
  if (!$knownmask)
  {
    $MASKHITS[99] = $MASKHITS[99] . $file_line_ctr . $ldelim;
    print "99hit " . $opmask . " for loan " . $lnum . "\n";
    $hit99 = 1;
  }

  $file_line_ctr++;
  # remember that @MASKHITS may have entries that are NULL. If, for
example
  # there are no trasn cards of type 20 (say "^0311...1") in today's
feed!
}

#print "Loaded \@MASKHITS array\n";
#print "MASKHITS AFTER LOAD " . $MASKHITS[0] . "**" . $MASKHITS[1] .
"\n";

# Now @MASKHITS is loaded. Simply go through each line of it by its
# index (you can use $list_line_ctr since this represents the same
value)
# and then find the LINES in $DATA that correspond to the string of
lines now
# stored as the data to @MASKHITS, eg. "2449010212345". Note the
presence
# of $ldelim at end of line. Should make split easy, but must use
split() into
# array as don't know how many lines there are matching any given @LIST
mask.
#

for ($list_line_ctr = 1; $list_line_ctr <= 99; $list_line_ctr++)
{
    #print "MASKHITS " . $MASKHITS[$list_line_ctr] . "\n";
    if ($MASKHITS[$list_line_ctr])
    {
      #We want to make sure this data at this position in $MASKHITS
      # is not null!. @CARDLINE must never have null lines!
      @CARDLINE = ""; # reinitialize this array

      (@CARDLINE) = split(/$ldelim/,$MASKHITS[$list_line_ctr]);
      #print "cardline " . $list_line_ctr . " " . $CARDLINE[0] .
$CARDLINE[1] . "\n";

      # @CARDLINE should now be an array of line numbers in @DATA that
contain
      #  the cards we want from this particular line of @MASKHITS...

      $TRUE = 1;
      $card_line_ctr = 0;
      while ($TRUE)
      {
        #print "cardline inside " . $CARDLINE[$card_line_ctr] . "\n";
        if ($CARDLINE[$card_line_ctr])
        {
          # test for data, don't print otherwise cause we're at end
          print OUTFILE $DATA[$CARDLINE[$card_line_ctr]] . "\n";
          #print "cardline to output " .
$DATA[$CARDLINE[$card_line_ctr]] . "\n";
          $card_line_ctr++;
        }else{
          # end of card, we can break from this while
          $TRUE = 0;
        }
      }
    }
}

# we should be done, so close output and do any reporting for test
# purposes, etc.

close(OUTFILE);
open(EMAIL, "| mailx -s'CPI sort report ' $NOTIFY");
print EMAIL "CPI file sorted\n";
if ($hit99) { print EMAIL "There were UNSORTABLE transactions!\n"; }
            else
            { print EMAIL "There were no unsortable transactions.\n"; }
close(EMAIL);
if ($CMD) { exec $CMD; } 

exit;


TIA

Luke



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

Date: 9 Feb 2005 11:01:20 -0800
From: rain_c1@web.de (Rainer Collet)
Subject: regex help
Message-Id: <b86ec2.0502091101.1fd3c664@posting.google.com>

hi!

i need a regex that matches all link-texts in html that are longer
than 17 characters. i started with

/<a.*?href=.*?>[^<\/a>]{18,}<\/a>/i

but the negated char-class [^<\/a>] is wrong, because if there is any
of the characters of the class in the link-text is does not match. so
it must be replaced by an expression that means: match 17 chars or
more, if there is no "</a>" included in them.

has anybody an idea?

- rainer


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

Date: Wed, 9 Feb 2005 10:33:18 -0600
From: "news.socket.net" <info4l@info-for-life.com>
Subject: Re: Regexp::Common question related to URI query
Message-Id: <110keqes7ij0o45@corp.supernews.com>


"Paul Lalli" <mritty@gmail.com> wrote in message
news:UpqOd.13411$ya6.2537@trndny01...

> No, it's being correctly replaced.  The url you listed is not valid.
> The querystring comes after the path part of a URL.  You did not give a
> path.
> http://www.example.com/?ref=1234
> is valid
> http://www.example.com?ref=1234
> is not valid, even if it 'works' in some browser(s).  For more
> information, see the RFCs mentioned in
>
http://search.cpan.org/~abigail/Regexp-Common-2.119/lib/Regexp/Common/URI/http.pm#$RE{URI}{HTTP}{-scheme}
>
> > Any suggestions on how to alter my code (above) would be greatly
> > appreciated.
>
> I would suggest fixing your data, if at all possible.
>
> Paul Lalli
>

Thank you, Paul for the prompt reply!

I am now thinking about checking for .com? .net? .tv?  entries
in the data, and replacing with:  .com/?  .net/?  .tv/?  prior to
hyperlinking them.

Joe  Halbrook


> "news.socket.net" <info4l@info-for-life.com> wrote in message
> news:110ka9pppjh6i83@corp.supernews.com...
> > I'm using:
> >
> > use Regexp::Common qw /!delimited/;
> >
> > and then trying to figure out how to modify this line:
> >
> > $line =~ s!$RE{URI}{HTTP}{-keep}!<a href="$1">$1</a>!g;
> >
> > such that it will convert any line that contains a valid URL
> > to a hyperlinked URL, i.e.
> >
> > http://www.mysite.com    becomes:   <a
> > href="http://www.mysite.com">http://www.mysite.com</a>
> >
> > Currently, this line of code works, but not if  $line contains a query
> after
> > the URL, i.e.
> >
> > http://www.mysite.com?ref=1234
> >
> > which is erroneously being replaced as:
> >
> > <a href="http://www.mysite.com">http://www.mysite.com</a>?ref=1234
> >
>




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

Date: Wed, 09 Feb 2005 18:46:30 +0100
From: phaylon <phaylon@dunkelheit.at>
Subject: Re: Regexp::Common question related to URI query
Message-Id: <pan.2005.02.09.17.46.30.35361@dunkelheit.at>

news.socket.net wrote:

> I am now thinking about checking for .com? .net? .tv?  entries in the
> data, and replacing with:  .com/?  .net/?  .tv/?  prior to hyperlinking
> them.

Does my EMail end in .com? And should the last part of that sentence be
transformed to ".com/?"? Don't think so ;) How about this:

  s!(\S+.com)(\?\S)!$1/$2!g;

I also like the idea not to replace such things as assistance but give a
warning information to the user.

g,phay

-- 
http://www.dunkelheit.at/
Thru the darkness of futures past, the magician longs to see.
One chants out between two worlds: Fire, walk with me.
                                     -- Twin Peaks, »Bob«



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

Date: 9 Feb 2005 08:29:24 -0800
From: ioneabu@yahoo.com
Subject: Re: The Problem with Perl
Message-Id: <1107966564.897787.86520@z14g2000cwz.googlegroups.com>


William Goedicke wrote:

> My best understanding of what they think the problem is that Perl is
> "context sensitive".  That is it behaves differently when data
> changes, if lists slip in where scalars were intended the results may
> be wildly different than expected.  This wouldn't be true in strongly
> typed languages like C or lisp.
>

Regarding C and C++, two words: memory leaks.

I am certain that a strict protocol could be developed within a Perl
project to ensure the same degree of rigor found in projects done in
any language.

I think Perl 6 may resemble Java in a few ways.

wana



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

Date: Wed, 09 Feb 2005 11:44:29 -0500
From: William Goedicke <goedicke@brandeis.edu>
Subject: Re: The Problem with Perl
Message-Id: <m3d5v9smxe.fsf@goedsole.com>

Dear Charlton - 

>>>>> "Charlton" == Charlton Wilbur <cwilbur@mithril.chromatico.net> writes:

    Charlton> Stop worrying about what other people think.

You misunderstood.  I'm not worrying; I'm learning.

     - Billy

============================================================
     William Goedicke     goedicke@goedsole.com            
     Cell 617-510-7244    http://www.goedsole.com:8080      
============================================================

          Lest we forget:

The devil's in the details


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

Date: 9 Feb 2005 10:10:04 -0800
From: "Rhugga" <rhugga@yahoo.com>
Subject: Re: The Problem with Perl
Message-Id: <1107972604.760531.141110@z14g2000cwz.googlegroups.com>


One thing that has always irritated me about perl is its poor
implementation of function arguments lists and the way datatypes are
defined and handled. Being a former C developer this drives me mad. If
you define a function that takes an int for example:

foo (int x) {
 // do something
}

Thus function calls like these should produce errors: (an error would
be the function doesn't exist, because in a sense it doesnt)

foo("some string");
foo();
foo(99.99);

In C/C++ the function foo(int x) and foo(char *) are 2 completely
different functions, the names may seem similiar to the human reader,
but deep down inside the nitty gritty these are basically 2 different
functions.

foo("some string");
foo();
foo(99.99);

To me this makes perl a very sloppy language and I certainly wouldnt
use it to process any mission critical data, just leaves to much to
chance and also in certain situations creates a very difficult
debugging effort. In the past we have seen things go pear-shaped
because of this issue when running very high-troughput type stuff.
Basically your stuck with a massive debug effort with nothing really to
go on. You end up bloating your code with print statements that output
debug info and sort it out that way.



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

Date: Wed, 09 Feb 2005 19:26:08 +0100
From: phaylon <phaylon@dunkelheit.at>
Subject: Re: The Problem with Perl
Message-Id: <pan.2005.02.09.18.26.07.422595@dunkelheit.at>

Rhugga wrote:

> Thus function calls like these should produce errors: (an error would be
> the function doesn't exist, because in a sense it doesnt)

Hm, I just made myself a little helper module, where I do:

  sub {
    my($a, $b, $c) = param '_-:%', @_;
    # ...
  }

This says the parameters are a scalar which must be there (_), one which
can be undefined (-) and the rest is a hash, which will be referenced in
$c. Possibilities are d (digit), a (arrayref), h (guess what), and so it
goes on. I've done this, because prototypes aren't that restricting, and
to experiment with a bit "off-road-coding".

The pro against checking the arguments at compile time is that the given
arguments may vary, which I would miss if it wouldn't be there.

> You end up bloating your code with print statements that output debug
> info and sort it out that way.

If your language doesn't "care" of something that does not mean that you
also have to ignore it. 

g,phay

-- 
http://www.dunkelheit.at/
   -<[::..::::..::::..]>-



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

Date: 09 Feb 2005 18:52:21 GMT
From: xhoster@gmail.com
Subject: Re: The Problem with Perl
Message-Id: <20050209135221.670$Fe@newsreader.com>

"Rhugga" <rhugga@yahoo.com> wrote:
> One thing that has always irritated me about perl is its poor
> implementation of function arguments lists and the way datatypes are
> defined and handled. Being a former C developer this drives me mad. If
> you define a function that takes an int for example:
>
> foo (int x) {
>  // do something
> }
>
> Thus function calls like these should produce errors: (an error would
> be the function doesn't exist, because in a sense it doesnt)
>
> foo("some string");
> foo();
> foo(99.99);
>
> In C/C++ the function foo(int x) and foo(char *) are 2 completely
> different functions, the names may seem similiar to the human reader,
> but deep down inside the nitty gritty these are basically 2 different
> functions.
>
> foo("some string");
> foo();
> foo(99.99);
>
> To me this makes perl a very sloppy language and I certainly wouldnt
> use it to process any mission critical data, just leaves to much to
> chance and also in certain situations creates a very difficult
> debugging effort. In the past we have seen things go pear-shaped
> because of this issue when running very high-troughput type stuff.

Why would the throughput matter?  If your input is garbage, it doesn't
matter how much of it there is.

> Basically your stuck with a massive debug effort with nothing really to
> go on.

You mean other than the warnings that tell you that you used a non-numeric
string as if it were a number at line 1087?

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: 9 Feb 2005 10:31:12 -0800
From: "evlika" <generic_x@hotmail.com>
Subject: Re: Trouble with Regexps
Message-Id: <1107973871.998022.218810@z14g2000cwz.googlegroups.com>

Outstanding suggestions. I took a little from each one. Thanks much!
--



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

Date: Wed, 09 Feb 2005 18:55:10 GMT
From: "Bill Segraves" <segraves_f13@mindspring.com>
Subject: Re: using perl to submit username/password and access subsequent pages
Message-Id: <i0tOd.7729$wK.2149@newsread3.news.atl.earthlink.net>

"Sam S." <junk2junk@hotmail.com> wrote in message
news:16e55509.0502090413.643d3b2b@posting.google.com...
> Semi-newbie here. I am trying to write a perl script that uses LWP to
> access the web pages that follow the initial login at
> https://www.shopqf.com/login.asp
>
> Of course I have a valid username and password that work when I use IE
> but I want to do this entirely within perl.
>
> I have tried a few methods in perl, including using the do_POST
> functions and trying to use cookies, but obviously I am not doing
> something right.
>
> It seems the login page uses some YY_checkform function that I don't
> understand and would prefer to not get into. I'd like to stick with
> doing this in perl only.
>
> Again, the goal is to use perl to login to this web site, then dig
> around some of the subsequent web pages.
>
> Any ideas? Thanks a lot folks!

See Randal L. Schwartz' excellent article "Automatically Testing a Form":

http://www.stonehenge.com/merlyn/WebTechniques/col43.html

for something to help you get started.

In addition, you should review the documentation for LWP::UserAgent,
HTTP::Request::Common, and HTTP::Cookies to see how to perform the steps you
wish to perform after you login.

Good luck!
--
Bill Segraves







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

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


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