Help - Search - Member List - Calendar
Full Version: combinations
WorkTheWeb Forums > Webmaster Resources > Perl Beginner Help
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44
Support our Sponsors!
Chris Devers
On Mon, 6 Dec 2004, Bryan R Harris wrote:

QUOTE
Can you do this:

$var =~ s/{([^}]*)}/$v = $1; $v =~ s!,!|!g; qq!($v)!/ge;

Holy cow, is that legal??!!  It took me at least 30 seconds just to
figure out that those commands were inside the s/// command.

See the 'e' at the end of the s/// block? That turns on Execution of the
code contained inside the right-hand-side of the substitution statement.

Useful trick, sometimes...


--
Chris Devers

Chris Devers
On Mon, 6 Dec 2004, Chris Devers wrote:

QUOTE
On Mon, 6 Dec 2004, Bryan R Harris wrote:

Can you do this:

$var =~ s/{([^}]*)}/$v = $1; $v =~ s!,!|!g; qq!($v)!/ge;

Holy cow, is that legal??!!  It took me at least 30 seconds just to
figure out that those commands were inside the s/// command.

See the 'e' at the end of the s/// block?

$previous_message =~ s/block/statement/;



--
Chris Devers

Graeme St. Clair
Does anyone know why or where the phrase [Contains o f f e n s i v e
content] is being inserted into these headers? I wouldn't care, except my
employer's spam filter is holding them up for whatever reason, as it might
be, use of the said phrase...

Rgds, G.

-----Original Message-----
From: Joshua Berry [mailto:[Email Removed]]
Sent: Monday, December 06, 2004 10:01 AM
To: Jim
Cc: [Email Removed]
Subject: [Released] [Contains offensive content] RE: Building Network
Redundancy into a Perl Client

I don't think that it is possible to do within perl so I had to enable these
options:

echo 1 >> /proc/sys/net/ipv4/tcp_tw_reuse echo 1 >>
/proc/sys/net/ipv4/tcp_tw_recycle

-----Original Message-----
From: Jim [mailto:[Email Removed]]
Sent: Saturday, December 04, 2004 8:27 PM
To: Joshua Berry
Cc: [Email Removed]
Subject: RE: Building Network Redundancy into a Perl Client

QUOTE
I am trying to implement redundancy in a client application that I am
writing so that I can have a primary server and a backup server.  The
client is tailing a logfile and sends results to a server for
processing, at the end of the tail loop it sends data to a function
that tries to establish a connection to the primary server and send
the data, if that fails then the data is sent to the backup (failover)
server.
The way the function works, if the primary comes back online then it
automatically knows and starts sending data back to the primary.

The only problem with the way this is implemented is that every
connection remains for a couple of minutes in the TIME_WAIT stage:

tcp    0      0 ...:      ...:
TIME_WAIT
tcp    0      0 ...:      ...:
TIME_WAIT

Which adds up if I am sending several connections per minute or
possibly per second.  My question is, is there a way to bypass the
TIME_WAIT stage or at least reduce the time it is in this stage from
within the program?  Below is the subroutine and how it is called.  If
there is another way of doing this please let me know.

I took a look at socket options ( setsockopt() ) but I don't see anyting
that would change the time_wait timer ,but I didn't look that hard :).
What
OS are you using? You may have tomodify some kernel settings if you are
using UNIX/LINUX. With windows, here are a few links that may help

http://www.winguides.com/registry/display.php/878/

http://www.windowsitpro.com/Web/Article/Ar...3276/23276.html




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.802 / Virus Database: 545 - Release Date: 11/26/2004



--
To unsubscribe, e-mail: [Email Removed] For additional
commands, e-mail: [Email Removed] <http://learn.perl.org/>
<http://learn.perl.org/first-response>



--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
<http://learn.perl.org/> <http://learn.perl.org/first-response>

Chris Devers
On Mon, 6 Dec 2004, Graeme St. Clair wrote:

QUOTE
Does anyone know why or where the phrase [Contains o f f e n s i v e
content] is being inserted into these headers?  I wouldn't care,
except my employer's spam filter is holding them up for whatever
reason, as it might be, use of the said phrase...

Nope.

Someone (someone else?) is inserting "spam:" in the subjects, which is
about as pointless & annoying.

Spam, and futile efforts to ban it, will kill email yet, just you
watch... :-(


--
Chris Devers

Graeme St. Clair
Yes, I did know it was OT - in fact I nearly put OT in the header. Except
that that might have disturbed whatever was going on, and I wanted to find
if the annotation emanated from the system of one of the list users. Asking
the question on some other list would not have elicited your answer, for
which thanks! I'll try to get an explanation from our anti-spammers.

Rgds, G.


-----Original Message-----
From: Jonathan Paton [mailto:[Email Removed]]
Sent: Monday, December 06, 2004 6:45 PM
To: Graeme St. Clair
Cc: [Email Removed]
Subject: Re: [Released] [Contains offensive content] RE: Building Network
Redundancy into a Perl Client

Dear Graeme,

The problem is with your employers filtering software, as the copy of the
same message I received was unaltered. Perl beginners is not the place to
ask about this.

Jonathan Paton

Bryan R Harris
QUOTE
I can usually figure out regexes, and this one seems simple, but it
still eludes me--

I'm looking for a regex (or a couple of regexes) to do the following:

blahblah{ab,abcd}blah --> blahblah(ab|abcd)blah
blahblah{a,b,c}blah  --> blahblah(a|b|c)blah

Well, you can do

tr/{},/()|/

I don't know if that's robust enough for what you're doing...

Probably not, since there may be commas elsewhere in the string.



QUOTE
If it's not obvious I'm trying to glob-select files like the tcsh
would. I've got the rest, this is the last part...

Doesn't File::Glob have the ability to do this already?

Perhaps. I'm dealing with many thousands of files on perl 5.4, which
doesn't handle globbing correctly on large numbers of files. This script
has to be super-portable, meaning I can't guarantee that the destination
platform will have any modules installed (which I don't know how to do
anyway).

- B

Jonathan Paton
Dear Graeme,

The problem is with your employers filtering software, as the copy of the
same message I received was unaltered. Perl beginners is not the place
to ask about this.

Jonathan Paton

Brian Barto
Sounds like a job for File::Tail

http://search.cpan.org/~mgrabnar/File-Tail-0.99.1/Tail.pm

I'm using it to monitor my auth.log file on my freebsd machine. Works like a
charm!

-----Original Message-----
From: Paul Kraus [mailto:[Email Removed]]
Sent: Tuesday, December 07, 2004 9:24 AM
To: [Email Removed]
Subject: Monitor Squid access.log


I want to write an app that starts up when squid starts that will
monitor access.log. everytime a line is written out to the log file
the script will parse the line and then do some "stuff to it" I don't
need any help with the stuff part :)

What I don't understand is to how to have a program running the
monitors a text file for changes?

I don't want to be to specifict on how I want to monitor because I am
not sure whats the best way so rather then direct you guys I thought I
would just leave it open for your thoughts on the best approach.

What the I plan to do once I have the data...
reformat the data by taking the ip address, arping it to get the mac
address then looking up the mac address to get the machine name.

then basically dump out a csv file like this ...
"date","time","MachineName","url","filesize"
I can do all of this once I have the input from access.log.

It needs to be in real time because these machines are dhcp that being
the case I need to get the mac address of the ip being used the very
instance that it is used.

Your thoughts,
Paul Kraus

--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
<http://learn.perl.org/> <http://learn.perl.org/first-response>

Bob Showalter
[Email Removed] wrote:
QUOTE
if ( $var = ipv4_checkip ($var)) {

Should be ipv4_chkip, not ipv4_checkip

You should contact the module author to see if he's interested in improving
the error handling for this kind of thing...

Peter Scott
In article <[Email Removed]>,
[Email Removed] (Graeme St. Clair) writes:
QUOTE
Does anyone know why or where the phrase [Contains o f f e n s i v e
content] is being inserted into these headers?
[snip]
tcp    0      0 ...:      ...:
^^^


Anything suggest itself now? :-)

--
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/

Bob Showalter
[Email Removed] wrote:
QUOTE
I am attempting to use the Curses module for the first time, and
really have no idea how to use it.  Every example I've been able to
find uses a variety of different keywords, but I haven't been able to
locate any documentation of the available routines.  If someone could
help get me started, I'd appreciate it.

As mentioned, Curses is a wrapper for standard lib[n]curses. A google search
for "curses tutorial" turns up some candidates.

You need to call initwin() to "turn on" curses and endwin() to "turn off"
curses at the end of your program. There are other initialization things you
may or may not need to do, depending on the application.

Here's an initialization example from a program I have:

use Curses;

....

# initalize curses
initscr(); # init screen buffers
curs_set(0); # turn off cursor
cbreak(); # canonical mode
noecho(); # no echo of input chars
eval { keypad(1) }; # allow keypad entry
END { endwin(); }

Kirk Bauer
On Thu, 9 Dec 2004, Bakken, Luke wrote:

QUOTE
Or modules for that matter. When I first read the eval trickery my first
thought was "WHY???".

Well, I have a set of script files. Each file is split into an init
section and several different scripts. The init section is eval'd right
away and each script section is eval'd when needed.

The reason I went this way was to make these script files as simple as
possible and, more importantly, so that I can reload them as many times
as I want without having to exit the program.

When a warning happens in the script file below, it works fine because I
know which file, script, and section is being executed. So
handle_warn() can properly display the error.

But if another script file defines a function in its INIT section, and
this script calls that function, I still think the warning came from
this file. The only way I see around this is to see that this file was
(eval 12) and the other file was (eval 10) so when I see (eval 10) in
the warning I can know that the line number refers to the other file.

Here is an example script file:

--------------------------------------------------------------------
# SECTION(INIT)
script_name 'Bookmarks';
script_version '0.1';
script_desc 'Scripts to add and remove bookmarks';

###############################################################################
# USER SCRIPT(add_bookmark): Adds a new bookmark
# SECTION(INFO)

argument 'sector', required => 1, prompt => 'Bookmark which sector?',
type => 'integer', min => 1,
max => sub {return $game_data{'game_settings'}{'max_sectors'}},
default => sub {return $game_data{'user'}{'curr_sector'}};

argument 'name', required => 1, prompt => 'Name the bookmark', type => 'string';

# SECTION(CODE)

if ($name =~ /^d+$/) {
print_text($RED . "ERROR: Bookmark name must not contain only numbers!n" . $WHITE);
} else {
if (exists $game_data{'bookmarks'}{$name}) {
print_text($RED . "ERROR: Bookmark '$name' already exists!n" . $WHITE);
} else {
$game_data{'bookmarks'}{$name} = $sector;
print_text($GREEN . "Bookmark $name => $sector added.n" . $WHITE);
}
}
###############################################################################
# USER SCRIPT(remove_bookmark): Removes a bookmark
# SECTION(INFO)

argument 'name', required => 1, prompt => 'Remove which bookmark', type => 'string', complete => sub {
my @ret;
if (exists $game_data{'bookmarks'}) {
@ret = (keys %{$game_data{'bookmarks'}});
}
return @ret;
};

# SECTION(CODE)

if (exists $game_data{'bookmarks'}{$name}) {
delete $game_data{'bookmarks'}{$name};
print_text($GREEN . "Bookmark $name removed.n" . $WHITE);
} else {
print_text($RED . "ERROR: Bookmark '
--------------------------------------------------------------------

Here is some of the code that parses this:

my %scripts;
my $curr_script_section;
my $curr_script_file;
my $curr_script;

sub handle_warn {
my $warning = $_[0];
my $file = $curr_script_file;
if ($curr_script) {
$file .= '(' . $curr_script . ')'
}
if ($curr_script_section) {
$file .= '[' . $curr_script_section . ']'
}
my $line = 0;
if ($warning =~ s/(eval d+) line (d+).$/$file/) {
$line = $1;
$line -= 2;
$warning .= "line $line.";
}
print_text($RED . "WARNING: $WHITE");
print_text_wrap($warning . "n");
}
$SIG{__WARN__} = &handle_warn;

sub remove_script_file {
my ($file) = @_;
delete $scripts{$file};
}

sub eval_script_code {
my ($script_file, $script, $section, $code) = @_;
local $SIG{__WARN__} = sub {
return if $_[0] =~ /redefined at/;
&handle_warn(@_);
};
$curr_script_section = $section;
$curr_script_file = $script_file;
$curr_script = $script;
debug("Executing $script($section) from file $script_file");
eval $code;
$curr_script_file = 'main';
$curr_script = '';
$curr_script_section = '';
if ($@) {
print_text("Error(s) in script file '$script_file' $script($section) (aborting and unloading)n", $@);
remove_script_file($script_file);
return 0;
}
return 1;
}

sub process_script_file {
my ($file) = @_;
if ($scripts{$file}{'sections'}{'INIT'}) {
eval_script_code $file, '', 'INIT', $scripts{$file}{'sections'}{'INIT'} or return 0;
}
foreach my $script (keys %{$scripts{$file}{'scripts'}}) {
if ($scripts{$file}{'scripts'}{$script}{'sections'}{'INFO'}) {
eval_script_code $file, $script, 'INFO', $scripts{$file}{'scripts'}{$script}{'sections'}{'INFO'} or return 0;
}
if ($scripts{$file}{'scripts'}{$script}{'sections'}{'FUNCTIONS'}) {
eval_script_code $file, $script, 'FUNCTIONS', $scripts{$file}{'scripts'}{$script}{'sections'}{'FUNCTIONS'} or return 0;
}
}
return 1;
}

sub read_script_file {
my ($file) = @_;
return unless $file;
remove_script_file($file);
if (is_script_file_disabled($file)) {
print_text(" Skipping $file (disabled)n");
return;
}
if (open(CODE, "$global_data{'settings'}{'main'}{'script_dir'}/$file")) {
print_text(" Reading $file...");
my $section = '';
my $script = '';
while (my $line = <CODE>) {
if ($line =~ /^s*#s*SECTION(([^)]+))/) {
$section = $1;
} elsif ($line =~ /^s*#s*SCRIPT(([^)]+)): (.+)/) {
$script = $1;
$scripts{$file}{'scripts'}{$script}{'name'} = $script;
$scripts{$file}{'scripts'}{$script}{'desc'} = $2;
} elsif ($line =~ /^s*#s*USERs+SCRIPT(([^)]+)): (.+)/) {
$script = $1;
$scripts{$file}{'scripts'}{$script}{'name'} = $script;
$scripts{$file}{'scripts'}{$script}{'desc'} = $2;
$scripts{$file}{'scripts'}{$script}{'user'} = 1;
} else {
$line =~ s/__SCRIPT_FILE__/'$file'/g;
if ($script) {
$scripts{$file}{'scripts'}{$script}{'sections'}{$section} .= $line;
} else {
$scripts{$file}{'sections'}{$section} .= $line;
}
}
}
close CODE;
if (process_script_file($file)) {
print_text("$GREEN OK$WHITE.n");
$scripts{$file}{'mod_time'} = (stat("$global_data{'settings'}{'main'}{'script_dir'}/$file"))[9];
}
}
}

Brian Volk
QUOTE
Brian Volk wrote:
Hi All,

I'm having trouble narrow down the correct "<img" tag...

This piece of code will get ALL the "<img" tags:

while (my $img_tag = $parser->get_tag('img')) {
my $i = $img_tag->[1];
my $code = $i->{'src'};
print "$coden"
}

All I want is the 11th one... so I tried to do a foreach
(1..11) , very
unsucessful... :~)

Any suggestions would be greatly appreciated.... Here is the whole
script....

__begin__

#!/usr/bin/perl

use strict;
use warnings;
use HTML::TokeParser::Simple;
use LWP::Simple;

my $url = "
http://www.rcpworksmarter.com/rcp/products...jsp?rcpNum=1013

<http://www.rcpworksmarter.com/rcp/products/detail.jsp?rcpNum=1013> ";
my $page = get($url)
or die "Could not load URLn";

my $parser = HTML::TokeParser::Simple->new($page)
or die "Could not parse page";

while (my $img_tag = $parser->get_tag('img')) {
my $i = $img_tag->[1]; # attributes of this img tag
my $code = $i->{'src'};
print "$coden";
}

__end__

Thanks!

Brian Volk
HP Products

<mailto:[Email Removed]> [Email Removed]



Flemming Greve Skovengaard wrote:
A quick solution could be:

my $counter = 0;
while (my $img_tag = $parser->get_tag('img')) {
++$counter;
my $i = $img_tag->[1]; # attributes of this img tag
my $code = $i->{'src'};
if($counter == 11) {
  print "$coden";
  last;
}
}

But there is properly a better solution.


Thank you! Your solution worked great!

Brian

Luke Bakken
QUOTE
Perl already has a mechanism for splitting a large program in to
several smaller files.

perldoc AutoLoader

Or modules for that matter. When I first read the eval trickery my first
thought was "WHY???".

Mandar Rahurkar
Hello,
Has anyone used perl on windows machine through cygwin ? Is the
usability same as that on linux box ?

Mandar

ext-Chetak Sasalu
-----Original Message-----
From: ext Chris Devers [mailto:[Email Removed]]
Sent: Friday, 10. December 2004 15:58
To: roime puniran
Cc: Perl Beginners List
Subject: Re: Run Shell Script Using Perl


On Fri, 10 Dec 2004, roime puniran wrote:

QUOTE
I have a linux shell script used to transfer files
into the other machine and i need PERL running my
script..
How can i do that?..did some one know?

You need to rewrite a shell script that does file transfer in Perl?

Ok, Perl can do that.

How are you trying to transfer the files? There are a lot of ways that
would work -- ftp, scp, rsync, cp over NFS mount (or SMB mount, or DAV
mount, or...), etc. We need to know what options to go with.

If the shell script isn't very long, can you paste it in a message to
the list? If it is long, can you paste a section with the parts you need
to rewrite in Perl?

Out of curiosity, if the shell script works, why rewrite it? I like Perl
and all, but not to the point that every perfectly good script in some
other language needs to be rewritten in Perl...


I think he wants to call the shell script from a different perl script.
qx( shell script which does ftp)

right ?

Chetak


--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
<http://learn.perl.org/> <http://learn.perl.org/first-response>

Tom Proctor
I've been using Cygwin through Perl on my machine for a few months now.
So far all of my scripts run identically on Cygwin and Linux.

-----Original Message-----
From: Mandar Rahurkar [mailto:[Email Removed]]
Sent: Friday, December 10, 2004 2:23 PM
Cc: [Email Removed]
Subject: Perl on Cygwin

Hello,
Has anyone used perl on windows machine through cygwin ? Is the
usability same as that on linux box ?

Mandar


--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.807 / Virus Database: 549 - Release Date: 12/7/2004


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.807 / Virus Database: 549 - Release Date: 12/7/2004

Mandar Rahurkar
Thank you very much for all your replies.

Mandar

Roime Puniran
no..there is more than 100 file in my
directory...actually it's a flow files...


--- "Ing. Branislav Gerzo" <[Email Removed]> wrote:

QUOTE
roime puniran [rp], on Tuesday, December 14, 2004 at
01:27 (-0800
(PST)) typed the following:

rp> transfered and remove successfull ..Below is my
rp> script...

it works, if you have in your source directory only
1 file, for
example data.dat ?

--

...m8s, cu l8r, Brano.

[He's mostly dead Jim. Get Miracle Max!]



--
To unsubscribe, e-mail:
[Email Removed]
For additional commands, e-mail:
[Email Removed]
<http://learn.perl.org/
<http://learn.perl.org/first-response







__________________________________
Do you Yahoo!?
Dress up your holiday email, Hollywood style. Learn more.
http://celebrity.mail.yahoo.com

Roime Puniran
Thanks for ur opinion...But, when i tried only one
files, it's also cannot executes....i am still
struggled on this matter...

--- "Ing. Branislav Gerzo" <[Email Removed]> wrote:

QUOTE
roime puniran [rp], on Tuesday, December 14, 2004 at
01:48 (-0800
(PST)) contributed this to our collective wisdom:

I never worked with sftp, but if I would on your
place, and have this
kind of problem, I tried transfer only 1 file.

--

...m8s, cu l8r, Brano.

[Mainframe: The BIGGEST PC peripheral available!]






__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail

Roime Puniran
Thanks for ur opinion...But, when i tried only one
files, it's also cannot executes....i am still
struggled on this matter...

--- "Ing. Branislav Gerzo" <[Email Removed]> wrote:

QUOTE
roime puniran [rp], on Tuesday, December 14, 2004 at
01:48 (-0800
(PST)) contributed this to our collective wisdom:

I never worked with sftp, but if I would on your
place, and have this
kind of problem, I tried transfer only 1 file.

--

...m8s, cu l8r, Brano.

[Mainframe: The BIGGEST PC peripheral available!]






__________________________________
Do you Yahoo!?
Send holiday email and support a worthy cause. Do good.
http://celebrity.mail.yahoo.com

Jos Pedro Silva Pinto
Hi,

It songs a funny solutions but...

Create a TEMP table and insert latest 5 days data

After delete the table and rename temp table


Jos Pinto


-----Original Message-----
From: Mallik [mailto:[Email Removed]]
Sent: tera-feira, 14 de Dezembro de 2004 11:31
To: [Email Removed]
Subject: Deleting the records from a table


Hi Friends,

I need a help from you in implementation of purging functionality.
I am given a hash of table(s), each having millions of records. i need to
delete those records keeping latest 5 days records in the tables.

I know the delete query like: delete from $tableName where adddtm < today ?
$numDays ; where $numDays is the variable having number of days latest data
to be retained. if i give the direct query like above it takes a lot of time
to delete records from that set of tables.

Do you have any idea to implement this purging that can be done in time for
any number of tables containing millions of records in a loop. i need to
implement this in perl, with DBI-informix interface.

Thanks in advance,
Mallik.

Mallik
Hi Jose,

Thanks for your prompt reply.

I too thought of same solution, but we don't want to delete the original
table. Any other solution is greatly appreciated.

Thanks & Regards,
Mallik.

-----Original Message-----
From: Jos Pedro Silva Pinto [mailto:[Email Removed]]
Sent: Tuesday, December 14, 2004 5:02 PM
To: [Email Removed]; [Email Removed]
Subject: RE: Deleting the records from a table


Hi,

It songs a funny solutions but...

Create a TEMP table and insert latest 5 days data

After delete the table and rename temp table


Jos Pinto


-----Original Message-----
From: Mallik [mailto:[Email Removed]]
Sent: tera-feira, 14 de Dezembro de 2004 11:31
To: [Email Removed]
Subject: Deleting the records from a table


Hi Friends,

I need a help from you in implementation of purging functionality.
I am given a hash of table(s), each having millions of records. i need to
delete those records keeping latest 5 days records in the tables.

I know the delete query like: delete from $tableName where adddtm < today ?
$numDays ; where $numDays is the variable having number of days latest data
to be retained. if i give the direct query like above it takes a lot of time
to delete records from that set of tables.

Do you have any idea to implement this purging that can be done in time for
any number of tables containing millions of records in a loop. i need to
implement this in perl, with DBI-informix interface.

Thanks in advance,
Mallik.

--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
<http://learn.perl.org/> <http://learn.perl.org/first-response>

Brian Barto
I recently installed Net::Pcap from the cpan shell and the test failed as
well. I did a force install and the install completed and it appears to be
working fine. Not sure if will be any repercussions in the future though.

-----Original Message-----
From: Welsh, Ed [mailto:[Email Removed]]
Sent: Wednesday, December 29, 2004 11:23 AM
To: [Email Removed]
Subject: Net::Pcap Install test fail


Environment:
Fedora Core 3
yum updated libpcap-0.8.3
tarball download of Net-Pcap.0.5
Perl 5.8.5


Problem:
Makefile.PL works fine and creates Makefile
make works
make install works
make test fails on 07-stats.t

Discussion:
The only error is "bad statistics". Has anyone else seen this
problem? How can I further
troubleshoot the issue?





Ed Welsh




The information transmitted in this e-mail is intended only for the
addressee and may contain confidential and/or privileged material.
Any interception, review, retransmission, dissemination, or other use of, or
taking of any action upon this information by persons or entities
other than the intended recipient is prohibited by law and may subject them
to criminal or civil liability. If you received this communication
in error, please contact us immediately at, and delete the
communication from any computer or network system.



--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
<http://learn.perl.org/> <http://learn.perl.org/first-response>

Ed Welsh
I found one other reference to this issue on google and the guy having the problem did exactly what
you did and forced the install. He then had issues. He thought it was related to network device
detection. I'll have to go that route and hope to not have problems. Thanks

We need some smart people to find the root cause of this issue. I'm too dumb.

-----Original Message-----
From: [Email Removed] [mailto:[Email Removed]]
Sent: Wednesday, December 29, 2004 10:34 AM
To: [Email Removed]
Subject: RE: :Pcap Install test fail

I recently installed Net::Pcap from the cpan shell and the test failed as well. I did a force install
and the install completed and it appears to be working fine. Not sure if will be any repercussions in
the future though.

-----Original Message-----
From: Welsh, Ed [mailto:[Email Removed]]
Sent: Wednesday, December 29, 2004 11:23 AM
To: [Email Removed]
Subject: Net::Pcap Install test fail


Environment:
Fedora Core 3
yum updated libpcap-0.8.3
tarball download of Net-Pcap.0.5
Perl 5.8.5


Problem:
Makefile.PL works fine and creates Makefile
make works
make install works
make test fails on 07-stats.t

Discussion:
The only error is "bad statistics". Has anyone else seen this problem? How can I further
troubleshoot the issue?





Ed Welsh




The information transmitted in this e-mail is intended only for the addressee and may contain
confidential and/or privileged material.
Any interception, review, retransmission, dissemination, or other use of, or taking of any action upon
this information by persons or entities other than the intended recipient is prohibited by law and may
subject them to criminal or civil liability. If you received this communication in error, please
contact us immediately at, and delete the communication from any computer or network
system.



--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
<http://learn.perl.org/> <http://learn.perl.org/first-response>

Brian Barto
Should be as simple as:

use CGI;
$co = new CGI;

## Here I grab the info from the form field named "date"
## and assign it to the variable $data

my $data = $co->param('date');

-----Original Message-----
From: [Email Removed]
[mailto:[Email Removed]]
Sent: Wednesday, December 29, 2004 2:14 PM
To: [Email Removed]
Subject: CGI and variables? Whats the problem?


Hi guys... Id like to ask you a question. Some of you might have
encountered something like this... Im creating a web interface using CGI
library so that the user enter a data in the textfield, i put these values
into some variables and use them in the system... for example... I type
the new date and the script executes the date command with that value
typed in the textfield... but I just cant get it done... If I give fixed
value to the variable, it works fine... but in the same script of the CGI,
it doesnt...
Please, help me!

Thanks!


--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
<http://learn.perl.org/> <http://learn.perl.org/first-response>

Bob Showalter
Patricio Bruna V wrote:
QUOTE
i need to parse out one big xml file, 592K, but the only thing i need
to do its eliminate some tags, where the lang attribute is not es
(<name xml:lang="ar">, fox example).
I think its a simple thing to do, so here its the question, what perl
module do you recommend for this task?

XML::SAX + XML::SAX::Base

You can write a very simple filter for this kind of thing.

Chris Devers
On Sun, 2 Jan 2005, Siegfried Heintze wrote:

QUOTE
The following code does not work quite right because it has a trailing ", ".

$sMainTable[2] .= $PCEs[$case_count]{$_}.", " foreach keys
%{$PCEs[$case_count]};

How could I rewrite this, perhaps with a join statement/function, so there
is no trailing ","?

The usual idiom is something like this:

$foo = join( ", ", keys %bar );

So in this case, maybe...

$sMainTable[2] = join( ", ", keys %PCEs[$case_count] );

....or something to that effect.

If you have _Perl Cookbook_, it has sections on commifying lists.



--
Chris Devers

Chris Devers
On Sun, 2 Jan 2005, Siegfried Heintze wrote:

QUOTE
I am posting this query in beginners instead of beginners-cgi because I
believe this is a question about the defined statement and not the $q->param
statement/function.

I'm using this code:
$q = new CGI;
my $nUserId                  = $q->param("userId") ;

I was hoping the defined keyword would tell me if userId was present, but it
does not seem to be doing that.

How can I make this execute the die statement when userId is missing from my
get/post parameters?

if (defined $nUserId) {
$juror_number = $nUserId;
} else {
die "No valid ID for User";
}

I usually just write in a way similar to this:

my $q = new CGI;
my $nUserId = $q->param("userId") or die "No valid ID for User";

Or if I'm feeling less draconian,

my $nUserId = $q->param("userId") or "No valid ID for User";

Which will set $nUserId to "No valid ID for User" if userId isn't
defined. In a lot of cases, this is acceptable, but in your code, maybe
everything falls apart without a userid and it really does need to die.

In any case, I think the '$foo = $bar || "default";' construct is very
useful: it's succinct, clear, and generally does what you want...



--
Chris Devers

Thomas Btzler
Ing. Branislav Gerzo <[Email Removed]> asked:
QUOTE
just pretty simple question: is LWP::UserAgent encode URL ?
for example I have:

my $ua = LWP::UserAgent->new;
my $resp = $ua->get('http://something.net/this:is+just test');

my question is, if LWP first encode (escape) path in URL as
is written in RFC 1738, or I have to care about it in my script ?

LWP does it for you. That can be a major PITA when you're trying
to call braindead CGI code that can't handle quoted-printable
characters in an URI.

HTH,
Thomas

Bob Showalter
Siegfried Heintze wrote:
QUOTE
How do I distinguish between no value and false? I thought defined was
supposed to do that.

So if I call $q->param("xyz"), how do I distinguish between
&xyz=0&abc and &xyz=&abc and xyz being absent all together?

param() will return undef in scalar context, or an empty list in list
context if the parameter is totally absent.

So if the query string is 'xyz=0&abc', param('xyz') will return '0'.

If the query string is 'xyz=&abc', param('xyz') will return ''.

If the query string is 'abc=foo', param('xyz') will return undef (in scalar
context)

So, you can do something like:

my $xyz = param('xyz');
if (defined $xyz) {
print "parameter xyz was present. it's value is [$xyz]n";
}

Bob Showalter
Bob Showalter wrote:
QUOTE
Siegfried Heintze wrote:
How do I distinguish between no value and false? I thought defined
was supposed to do that.

So if I call $q->param("xyz"), how do I distinguish between
&xyz=0&abc and &xyz=&abc and xyz being absent all together?

param() will return undef in scalar context, or an empty list in list
context if the parameter is totally absent.

So if the query string is 'xyz=0&abc', param('xyz') will return '0'.

If the query string is 'xyz=&abc', param('xyz') will return ''.

If the query string is 'abc=foo', param('xyz') will return undef (in
scalar context)

So, you can do something like:

my $xyz = param('xyz');
if (defined $xyz) {
print "parameter xyz was present. it's value is [$xyz]n";
}

I should add that if this is coming from a form submission and they've left
the field blank, you can't test for that with defined(). You need to test
for whatever you consider a blank field to be.

I often do something like this:

die "You must enter an idn" unless $q->param('id') =~ /S/;

That will die if they leave the field blank or just put whitespace in it.

Pablo Wablo
sorry sent it out ot the list

..... if it's just V you want to replace you can try

$something =~ s/V/v/g;
--- "Adamiec, Larry" <[Email Removed]> wrote:

QUOTE


-----Original Message-----
From: William Black [mailto:[Email Removed]]

Sent: Friday, January 07, 2005 08:42
To: [Email Removed]
Subject: re: Search And Replace


Hello All

I'm tryiing to search and replace in both perl and
korn shell.

For Example:

X=G1234V00

I want to replace all occurences of 'V' with 'v'
in both perl
and korn shell

William Black

In Perl, you can use ucase and lcase.
In Korn, you can use tr  (see man pages for details)

Larry

--
To unsubscribe, e-mail:
[Email Removed]
For additional commands, e-mail:
[Email Removed]
<http://learn.perl.org/
<http://learn.perl.org/first-response







__________________________________
Do you Yahoo!?
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250

William Black
Hello All

I'm tryiing to search and replace in both perl and korn shell.

For Example:

X=G1234V00

I want to replace all occurences of 'V' with 'v' in both perl and korn shell

William Black

Jos Pedro Silva Pinto
Hi,

do

perl -pi -e 's/Old_value/new_value/g' Our_File

Bye

-----Original Message-----
From: William Black [mailto:[Email Removed]]
Sent: sexta-feira, 7 de Janeiro de 2005 14:42
To: [Email Removed]
Subject: re: Search And Replace


Hello All

I'm tryiing to search and replace in both perl and korn shell.

For Example:

X=G1234V00

I want to replace all occurences of 'V' with 'v' in both perl and korn shell

William Black



--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
<http://learn.perl.org/> <http://learn.perl.org/first-response>

Larry Adamiec
QUOTE
-----Original Message-----
From: William Black [mailto:[Email Removed]]
Sent: Friday, January 07, 2005 08:42
To: [Email Removed]
Subject: re: Search And Replace


Hello All

I'm tryiing to search and replace in both perl and korn shell.

For Example:

X=G1234V00

I want to replace all occurences of 'V' with 'v' in both perl
and korn shell

William Black

In Perl, you can use ucase and lcase.
In Korn, you can use tr (see man pages for details)

Larry

John W. Krahn
William Black wrote:
QUOTE
Hello All

Hello,

QUOTE
I'm tryiing to search and replace in both perl and korn shell.

For Example:

X=G1234V00

I want to replace all occurences of 'V' with 'v' in both perl and korn
shell

You can use tr in both perl:

perl -pe'tr/V/v/' file.in > file.out

and the shell:

tr V v < file.in > file.out


John
--
use Perl;
program
fulfillment

Siegfried Heintze
I'm getting a warning on line 10 or 11. The program works. I'd like to get
rid of the warnings however. When I change "%hash" to "$hash" on lines 10-11
then the program does not work at all then.

Thanks,
Siegfried



1 package case;
2 our @EXPORT = qw( $crimhelp $evhelp $civhelp $rkhelp);
3 package CaseFactory;
4 require Exporter;
5 use case_constants qw(:DEFAULT btRankSuspects);
6 use strict;
7 use warnings;
8 #($crimhelp, $evhelp, $civhelp) = ("","","");
9 sub mfr {
10 my ($me, %hash )= @_;
11 my $type = %hash->{base_type};
12 if ($type == &case_constants::btRankSuspects ){
13 return RA->new($type, @_); }
14 elsif ($type == &case_constants::btCompareAssertions){
15 return CA->new($type, @_); }
16 elsif ($type == &case_constants::btCriminal){
17 return CR->new($type, @_); }
18 elsif ($type == &case_constants::btEvidenceEvaluation){
19 return EV->new($type, @_); }
20 elsif ($type == &case_constants::btCivil){
21 return CI->new($type, @_); }
22 else{
23 return Case->new($type, @_);
24 }
25 }
26 sub new {
27 my $invocant = shift;
28 my $class = ref($invocant) || $invocant;
29 my $self = { @_ };
30 bless($self, $class);
31 return $self;
32 }
33

Alfred Vahau
QUOTE
10  my ($me, %hash )= @_;
11  my $type = %hash->{base_type};

In 10, is the structure of the hash preserved? What happens if you pass
the hash by reference?
In 11, you are using the hash as a reference. What you want is something
like:

my $type = $hashref->{base_type};

alfred,

Siegfried Heintze wrote:

QUOTE
I'm getting a warning on line 10 or 11. The program works. I'd like to get
rid of the warnings however. When I change "%hash" to "$hash" on lines 10-11
then the program does not work at all then.

Thanks,
Siegfried



1 package case;
2 our @EXPORT = qw( $crimhelp $evhelp $civhelp $rkhelp);
3 package CaseFactory;
4 require Exporter;
5 use case_constants qw(:DEFAULT btRankSuspects);
6 use strict;
7 use warnings;
8 #($crimhelp, $evhelp, $civhelp) = ("","","");
9 sub mfr {
10  my ($me, %hash )= @_;
11  my $type = %hash->{base_type};
12  if ($type == &case_constants::btRankSuspects ){
13    return RA->new($type, @_); }
14  elsif ($type == &case_constants::btCompareAssertions){
15    return CA->new($type, @_); }
16  elsif ($type == &case_constants::btCriminal){
17    return CR->new($type, @_); }
18  elsif ($type == &case_constants::btEvidenceEvaluation){
19    return EV->new($type, @_); }
20  elsif ($type == &case_constants::btCivil){
21    return CI->new($type, @_); }
22  else{
23    return Case->new($type, @_);
24  }
25 }
26 sub new {
27  my $invocant = shift;
28  my $class = ref($invocant) || $invocant;
29  my $self = { @_ };
30  bless($self, $class);
31  return $self;
32 }
33





--
Perl is my reason for following the Sun;

Scott R. Godin
Alfred Vahau wrote:
QUOTE
10  my ($me, %hash )= @_;
11  my $type = %hash->{base_type};


In 10, is the structure of the hash preserved? What happens if you pass
the hash by reference?
In 11, you are using the hash as a reference. What you want is something
like:

In which case you would also want to use

my ($me, $hashref) = @_;

QUOTE
my $type = $hashref->{base_type};

alfred,

Siegfried Heintze wrote:

I'm getting a warning on line 10 or 11. The program works. I'd like to
get
rid of the warnings however. When I change "%hash" to "$hash" on lines
10-11
then the program does not work at all then.

Thanks,
Siegfried


[snip]
9 sub mfr {
10  my ($me, %hash )= @_;
11  my $type = %hash->{base_type};
12  if ($type == &case_constants::btRankSuspects ){  13    return
RA->new($type, @_); }
14  elsif ($type == &case_constants::btCompareAssertions){  15
return CA->new($type, @_); }
16  elsif ($type == &case_constants::btCriminal){  17    return
CR->new($type, @_); }
18  elsif ($type == &case_constants::btEvidenceEvaluation){  19
return EV->new($type, @_); }
20  elsif ($type == &case_constants::btCivil){  21    return
CI->new($type, @_); }
22  else{  23    return Case->new($type, @_);  24  }
25 }
26 sub new {
27  my $invocant = shift;
28  my $class = ref($invocant) || $invocant;
29  my $self = { @_ };
30  bless($self, $class);
31  return $self;
32 }



--
Scott R. Godin
Laughing Dragon Services
www.webdragon.net

Thomas Btzler
Owen <[Email Removed]> suggested:
QUOTE
Well perhaps for a single debugging line, it doesn't matter
too much, but consider a program where endless things can and
do go wrong. Peppering your script with

or die "Can't open the file Data1 $!n"; or die "Can't open
the file Data2 $!n"; or die "Can't open the file Data3 $!n"; etc

really helps track down where to look

The rule is to always check the return value

I'd go even a step farther and suggest that you make sure of
your arguments, too:

open( IN, $file ) or die "Can't open '$file': $!n";

That helps a lot in tracking down problems that arise
because of wrong assumptions (i.e. that you've got a
filename right).

HTH,
Thomas

Bob Showalter
Christian Stalp wrote:
QUOTE
Does anybody has any experience with making liked lists in perl.
There is an example in "Mastering Alogrithms in Perl" by Orwant,
Hietaniemi and Macdonald. But this works does'nt work:

#!/usr/bin/perl

use warnings;
use strict;

use constant NEXT => 0;
use constant VALU => 1;

my ( $list, $tail );

$list = $tail = undef;

foreach ( 1..5 )
{
my $node = [ undef, $_ * $_ ];
if ( $tail eq undef )

This line is bogus. It should be either

if (defined($tail))

or simply

if ($tail)

QUOTE
{
$list = $tail = $node;
}
else
{
$tail -> [ NEXT ] = $node;
$tail = $node;
}
}

The output is:
Use of uninitialized value in string eq at ./kette.pl line 16.

And it is not clear to me where reverences were build from one node to
another. This should be at $node[0]. But this reverence get nerver
been held in the loop. Each round the new node overrides the old and
only the tail points on the actual element!!!!!?????

This line creates a new node each time through the loop (the [ ] operators
here are an anonymous array constructor):

my $node = [ undef, $_ * $_ ];

$node is a reference to that newly-created node.

These lines hook the node on to the end of the list and move $tail to point
to the new end of the list.

$tail -> [ NEXT ] = $node;
$tail = $node;

Add this to the end of the program to see what it builds:

use Data::Dumper;
print Dumper($list);

($list is a reference to the head node)

Thomas Btzler
Robin <[Email Removed]> suggested:
QUOTE
This will split up the string based on the pattern (in this
case, a single space. You may want to change that to gain
robustness, e.g. /[ t]+/ will split on any number of spaces and tabs)

I suggest /s+/ instead. This splits on any whitespace,
and it'll also remove trailing whitespace like those
pesky trailing n:


#!/usr/bin/perl -w

use strict;

my $string = "foo baz barn";

foreach my $word (split/[ t]+/, $string) {
print "'$word'n";
}

foreach my $word ( split/s+/, $string ) {
print "'$word'n";
}


HTH,
Thomas

Bob Showalter
Doug Essinger-Hileman wrote:
QUOTE
I am just learning Perl, and am having a problem with something which
seems like it should be so easy. Still . . . . I have read through a
couple of books, including _Beginning Perl_ and _Picking Up Perl_, to
no avail.

Welcome!

QUOTE

I am trying to read a file, then assign some information within a
script. The problem comes in assigning. My file has three lines. The
first line contains a list of names seperated by spaces; the next two
lines contain numbers:

Doug Sandy Lois
0
1

In order to isolate the problem, I have created a simplified script:

#read from file

open (CONTROL1, "<test.cont");
@constants = <CONTROL1>;
close (CONTROL1);

#parse

$names = @constants[0];
@group = qw($names);

#print

open (CONTROL2, ">test2.cont");
print CONTROL2 "Names: $names";
print CONTROL2 "Group: @group";
close (CONTROL2);

The test2.cont file shows that $names is being set as I expected: to
a string (Doug Sandy Lois). I assumed that @group = qw($names) would
fill the array with the string of names. However, test2.cont shows
that the value of @group is "$names". Obviously, my assumption was
wrong.

So is there a way to directly fill the @group array with the string
now stored in $names? Or do I have to split the string and fill the
array in that manner?

qw() means "quote words". It's a shortcut for specifying a list of
LITERAL strings without having to use quotes and commas.

What you want is:

@group = split ' ', $names;

qw() is documented in perldoc perlop. For the documentation on split(),
see perldoc -f split

Bryan R Harris
QUOTE
Robin <[Email Removed]> suggested:
This will split up the string based on the pattern (in this
case, a single space. You may want to change that to gain
robustness, e.g. /[ t]+/ will split on any number of spaces and tabs)

I suggest /s+/ instead. This splits on any whitespace,
and it'll also remove trailing whitespace like those
pesky trailing n:


And further, use split(' ',$numbers), which is a special case that splits on
all whitespace, ignoring initial whitespace. Just a bare "split" does that
by default.

Try this:

perl -e '$_ = " 1 2 3 4 5 "; print "method 1: ", join(",",split /s+/),
"n", "method 2: ", join(",",split), "n";'

- B

Hi

I'm trying to download/install perl-authen_smb for perl 5.8.1

Where can I download a copy of perl-module for perl 5.8.1 & and copy
perl-authen_smb for perl 5.8.1?



Dan

Michael Kraus
You don't. You create it with HTML and JavaScript. You use perl to read
the select boxes values.

It's simply that Perl is used server-side, not client-side. Perl can be
used to generate the HTML (and javascript if needed).

Javascript is a client-side technology. The two languages don't directly
compete with each other, but can be used co-operatively.

Perl packages of interest to you would be: CGI, HTML::Template,
CGI::FormBuilder and/or CGI::Untaint

Regards,


Michael S. E. Kraus
B. Info. Tech. (CQU), Dip. Business (Computing)
Software Developer
Wild Technology Pty Ltd
_______________________________
ABN 98 091 470 692
Level 4 Tiara, 306/9 Crystal Street, Waterloo NSW 2017, Australia
Telephone 1300-13-9453 | Facsimile 1300-88-9453
http://www.wildtechnology.net

The information contained in this email message and any attachments may
be confidential information and may also be the subject of client legal
- legal professional privilege. If you are not the intended recipient,
any use, interference with, disclosure or copying of this material is
unauthorised and prohibited. This email and any attachments are also
subject to copyright. No part of them may be reproduced, adapted or
transmitted without the written permission of the copyright owner. If
you have received this email in error, please immediately advise the
sender by return email and delete the message from your system.

QUOTE
-----Original Message-----
From: Maxipoint Rep Office [mailto:[Email Removed]]
Sent: Monday, 17 January 2005 9:39 AM
To: [Email Removed]
Subject: Spam:Triple Combo Box with Perl?


Have someone idea or url how create Triple Combo Box with Perl?

something like here:
http://javascriptkit.com/script/script2/triplecombo.shtml

but not redirection at the end, i need only data submision
after user select combination..


--
To unsubscribe, e-mail: [Email Removed] For
additional commands, e-mail: [Email Removed]
<http://learn.perl.org/> <http://learn.perl.org/first-response





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

Wild Technology Pty Ltd , ABN 98 091 470 692
Sales - Ground Floor, 265/8 Lachlan Street, Waterloo NSW 2017
Admin - Level 4 Tiara, 306/9 Crystal Street, Waterloo NSW 2017
Telephone 1300-13-9453 | Facsimile 1300-88-9453
http://www.wildtechnology.net
DISCLAIMER & CONFIDENTIALITY NOTICE: The information contained in this email message and any attachments may be confidential information and may also be the subject of client legal - legal professional privilege. If you are not the intended recipient, any use, interference with, disclosure or copying of this material is unauthorised and prohibited. This email and any attachments are also subject to copyright. No part of them may be reproduced, adapted or transmitted without the written permission of the copyright owner. If you have received this email in error, please immediately advise the sender by return email and delete the message from your system.

Michael Kraus
G'day...

QUOTE
if ($_ !~ /*{5} InTune/){

This should be:

if ($_ !=~ /*{5} InTune/) {

Should it?

I always thought that !~ was the inverse of =~

I.e.
$var !~ /pattern/
was the equivalent of
!($var =~ /pattern/)

(at least within test conditions anyway)

Is there something I'm missing? :)

Thanks!


Regards,


Michael S. E. Kraus
B. Info. Tech. (CQU), Dip. Business (Computing)
Software Developer
Wild Technology Pty Ltd
_______________________________
ABN 98 091 470 692
Level 4 Tiara, 306/9 Crystal Street, Waterloo NSW 2017, Australia
Telephone 1300-13-9453 | Facsimile 1300-88-9453
http://www.wildtechnology.net

The information contained in this email message and any attachments may
be confidential information and may also be the subject of client legal
- legal professional privilege. If you are not the intended recipient,
any use, interference with, disclosure or copying of this material is
unauthorised and prohibited. This email and any attachments are also
subject to copyright. No part of them may be reproduced, adapted or
transmitted without the written permission of the copyright owner. If
you have received this email in error, please immediately advise the
sender by return email and delete the message from your system.



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

Wild Technology Pty Ltd , ABN 98 091 470 692
Sales - Ground Floor, 265/8 Lachlan Street, Waterloo NSW 2017
Admin - Level 4 Tiara, 306/9 Crystal Street, Waterloo NSW 2017
Telephone 1300-13-9453 | Facsimile 1300-88-9453
http://www.wildtechnology.net
DISCLAIMER & CONFIDENTIALITY NOTICE: The information contained in this email message and any attachments may be confidential information and may also be the subject of client legal - legal professional privilege. If you are not the intended recipient, any use, interference with, disclosure or copying of this material is unauthorised and prohibited. This email and any attachments are also subject to copyright. No part of them may be reproduced, adapted or transmitted without the written permission of the copyright owner. If you have received this email in error, please immediately advise the sender by return email and delete the message from your system.

B McKee
Apologies for the layout and busted thread - I'm on digest mode
QUOTE
From: "JupiterHost.Net" <[Email Removed]
I believe this will do what you want:
next if grep { $rawreport_item =~ /$_/ } @possibleMatches;
Just make sure the regexes in @possibleMatches are not user supplied
or they may try sneaky bad things :)

yep - strictly hardcoded for this useage.

QUOTE
perl -mstrict -we 'my @m = (q(^d+$), q(^w+$)); for my $item (qw(123
abc 1-2we)){ next if grep { $item =~ /$_/ } @m; print "$itemn"; }'
HTH :)
Lee.M - JupiterHost.Net

Thanks Lee - that does look like what I was thinking of.
I'm now using
while (<RAWREPORT>) {
my @linesToDiscard = ( q(f), q(^DATE : ), q(^s{15,}PART ),
q(^COUNTER QTY), q(^s+$) ) ;
my $lineItem = $_ ;
next if grep { $lineItem =~ /$_/ } @linesToDiscard ;
etc.....

QUOTE
From: "John W. Krahn" <[Email Removed]
What you probably want is:
while ( <RAWREPORT> ) {
next if /f|^DATE : |^s{15,}PART |^COUNTER QTY|^s+$/  ;
print ; # debugging purposes - other stuff here
}
Although you should read this first:
perldoc -q "How do I efficiently match many regular expressions at
once"
John

Hi John - I did think of using the | in the regex, but didn't that
wasn't what I was after.
Long term I _may_ use this for different reports, or the report _may_
change, and I wanted
and easy spot to make changes.
I read that FAQ, and I don't understand it...:-) ....yet. Thanks,
I see how it applies,
but I think I'll skip using it until I get how that suggestion works.
I've made a note
to revisit later.

So, now I'm off to figure out this scoping problem I have....
But I'm learning !

Brian

--
"I don't understand," said the scientist, "why you lemmings all rush
down
to the sea and drown yourselves."
"How curious," said the lemming. "The one thing I don't understand is
why
you human beings don't."
-- James Thurber

JupiterHost.Net
QUOTE
From: "JupiterHost.Net" <[Email Removed]
I believe this will do what you want:
next if grep { $rawreport_item =~ /$_/ } @possibleMatches;
Just make sure the regexes in @possibleMatches are not user supplied
or they may try sneaky bad things :)


yep - strictly hardcoded for this useage.

perl -mstrict -we 'my @m = (q(^d+$), q(^w+$)); for my $item (qw(123
abc 1-2we)){ next if grep { $item =~ /$_/ } @m; print "$itemn"; }'
HTH :)
Lee.M - JupiterHost.Net


Thanks Lee - that does look like what I was thinking of.

great ;p

QUOTE
I'm now using
while (<RAWREPORT>) {
my @linesToDiscard = ( q(f), q(^DATE : ), q(^s{15,}PART ),
q(^COUNTER QTY), q(^s+$) ) ;

Why redefine @linesToDiscard which each $_ ?

my @linesToDiscard = ('f','^DATE : ','^s{15,}PART ','^COUNTER
QTY','^s+$');
while(<RAWREPORT>) {
...


PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2005 Invision Power Services, Inc.