Re: How do I use HTML::Stripper without lwp?

2008-07-31 Thread bdy
On Jul 24, 5:57 pm, [EMAIL PROTECTED] (Rob Dixon) wrote:
> bdy wrote:
>
> > My code is as follows:
>
> > use strict; use HTML::Stripper;    useLWP::Simple qw( get );      my
> > $stripper = HTML::Stripper->new(        skip_cdata => 1, strip_ws => 0  );  
> >       my
> > $page_html = get(http://www.google.com/about.html); open(FILE,  ">
> > http___www.google.com.html");   print FILE $stripper->strip_html
> > ($page_html);      close(FILE);
>
> > Unfortunately, I'm not sure how I would run the stripperwithoutLWP.
> > What I would like to accomplish is running a file through
> > HTML::Stripper apart fromLWP.
>
> > Here's what I've produced so far:
>
> >   use strict;
> >   use HTML::Stripper;
>
> >   my $stripper = HTML::Stripper->new(
> >       skip_cdata => 1, strip_ws => 0
> >   );
>
> >   my $page_html = 'H:\test-r-get\google.html';
> >   open(FILE,  ">   google.txt");      print FILE $stripper->strip_html
> > ($page_html);      close(FILE);
>
> > Unfortunately, this produces a blank text file.
>
> useLWP::Simple;
> my $page_html = get('file://localhost/H:/test-r-get/google.html');
>
> ;D
>
> Rob- Hide quoted text -
>
> - Show quoted text -

Thanks; it works. Does the pod for LWP or HTML::Stripper contain
anything about scrubbing HTML from all HTML files in a file directory?
I couldn't find anything.

Thanks,


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Unable to read the string

2008-07-31 Thread Bob McConnell
From: Arun

> Hi this is Arun here, i am new to perl.Here i am trying to read a
> string from the serial port but i am not able to and this is my
> program:

You don't show the initialization for that port. How was it configured
and do all of the settings match the device talking to it? The most
common problem with serial ports is mismatched UART settings.

Bob McConnell

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Unable to read the string

2008-07-31 Thread Rob Dixon
Arun wrote:
>
> Hi this is Arun here, i am new to perl.Here i am trying to read a
> string from the serial port but i am not able to and this is my
> program:
> 
> # Read serial port until message or timeout occurs
> sub ReadPort($$$) {
> (my $String, my $TimeOut, my $Display) = @_;
> $ob->read_const_time($TimeOut); # Setup timeout value in mS
> my $Reply = ""; # Initialize message
> do {
>  ($Count, $Result) = $ob->read(1); # Read serial port
>  $Reply .= $Result; # Build message
>  print "$Result" if ($Display); # Display messages if enabled
> } while($Count > 0 and $Reply !~ m/$String/);
> print "\n" if ($Display); # Put carriage return at end of
> displayed output
> if ($Reply !~ m/$String/) {
> print "ERROR: Read timed out waiting for '$String' \n";
> return(1);
> }
> return($Reply);

You shouldn't use prototypes for Perl subroutines: they don't do what you think
they do, and they are more likely to break things than be useful.

Unless you have your own reasons for naming your variables with mixed case, many
people would thank you if you changed to using all lower-case. Names beginning
with a capital letter are usually package or module names.

What problem are you having? It looks basically alright to me, although it may
not be wise to use the value of $result if $count is zero. How about a loop like
this:

  {
my ($count, $result) = $ob->read(1);
last unless $count;
print $result if $display;
$reply .= $result;
redo unless $reply =~ /\Q$string/;
  }

HTH,

Rob

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: ARGV array regarding

2008-07-31 Thread Mr. Shawn H. Corey
On Thu, 2008-07-31 at 18:00 +0530, suresh kumar wrote:
> Hi,
> 
> This is my part of the script,
> 
> if (($#ARGV == 1) && ($ARGV[0] eq "-f")) {
>..
>
> 
> if ($ARGV[0] ne "-f" ) {
>  ..
>  
> 
> if i run my script i am seeing this kind of warnings.
> 
>  Use of uninitialized value in string eq at ./lineCount line 30.
> Use of uninitialized value in string ne at ./lineCount line 69.
> 
> How can i initialize ARGV array?
> 
> can anyone help me in this issue.

If you're looking to handle command-line options, you should use the
standard packages. See `perldoc Getopt::Std` and `perldoc Getopt::Long`.


-- 
Just my 0.0002 million dollars worth,
  Shawn

"Where there's duct tape, there's hope."

"Perl is the duct tape of the Internet."
Hassan Schroeder, Sun's first webmaster


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: ARGV array regarding

2008-07-31 Thread Rob Dixon
suresh kumar wrote:
> 
> This is my part of the script,
> 
> if (($#ARGV == 1) && ($ARGV[0] eq "-f")) {
>..
>
> 
> if ($ARGV[0] ne "-f" ) {
>  ..
>  
> 
> if i run my script i am seeing this kind of warnings.
> 
>  Use of uninitialized value in string eq at ./lineCount line 30.
> Use of uninitialized value in string ne at ./lineCount line 69.
> 
> How can i initialize ARGV array?
> 
> can anyone help me in this issue.

The @ARGV array holds the whitespace-split contents of the command line used to
start perl. If you run a program with

  perl myprog.pl a b c

then @ARGV will contain ('a', 'b', 'c'). It doesn't normally need initialising,
but you can assign to it if you want to simulate a command line.

$#ARGV is the highest valid index of @ARGV, so

  $#ARGV == 1

is testing whether @ARGV has two elements (at indices 0 and 1). The second test

  $ARGV[0] eq "-f"

will be performed only if the first succeeds, and since you've established that
there are two elements the first can only be undefined if you've explicitly made
it so, with

  delete $ARGV[0];

or something similar.

I can't really tell what the problem might be without seeing your full code.

Rob


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




ARGV array regarding

2008-07-31 Thread suresh kumar
Hi,

This is my part of the script,

if (($#ARGV == 1) && ($ARGV[0] eq "-f")) {
   ..
   

if ($ARGV[0] ne "-f" ) {
 ..
 

if i run my script i am seeing this kind of warnings.

 Use of uninitialized value in string eq at ./lineCount line 30.
Use of uninitialized value in string ne at ./lineCount line 69.

How can i initialize ARGV array?

can anyone help me in this issue.


RE: can perl program do this?

2008-07-31 Thread Thomas Bätzler
Richard Lee <[EMAIL PROTECTED]> asked:

[Full quote deleted. Please quote only the relevant parts of
the mail you're replying to. Thank you!]

> but I am interested in grepping out the pcap file so I cannot 
> simply just do grep

Please use some common sense. You can't use Net::Pcap on host X
to parse a file on host Y without transferring the file from host
Y to X in some way.

Please have a look at the PAR tools to find out how to bundle
a Perl interpreter and all the required libs with your program,
so that you are not dependant on the Perl installation on the
target systems.

HTH,
Thomas

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: can perl program do this?

2008-07-31 Thread Richard Lee

Rob Coops wrote:

Ah, I see...
 
I think you have been misled by the name of the Net::Pcap lib, the lib 
is meant to produce the file you are trying to poke around in.
 
I would do the follwoing.


* Use Net::SSH or similair to connect to the remote machine.
* On the remote machine use grep or similair to pull out the lines
  you are intrested in and store those in an array/file or well
  what ever storage you like on your side.
* Process the data on your own machine.

The advantage of this is that you only move the data you are intrested 
in over the network and not the whole big file, thus reducing the 
network trafic and maning your network admins happy as well. Because 
you have the data on your side you can then do with it what you want 
without having to rely on any software on the remote machine.
 
I hope this helps a bit,
 
Rob
On Thu, Jul 31, 2008 at 9:06 AM, Richard Lee <[EMAIL PROTECTED] 
> wrote:


Rob Coops wrote:

If you can make Net::Pcap connect to a remote server things
will work fine, I am not sure about using Net::Pcap to do this
as I never used it and from the description it seems to be a
packet capture lib not so much a communication one, but as I
said if you can make it reach out and talk to the other side
you should be fine.
 I think you will end up using somehting like Net::SSH or
something like that as these are more aimed at communication
then Net::Pcap seems to be.
 But in the end as long as the other side is listening on a
port and you can produce the required packets to get
communication going you should be fine, there is no need to
have perl, or any perl libs on the other side all that is
needed is an open port that you can communicate with.
The thing that is listening on that port is what determins
what you can do, read email, open and interact with files or
just browse a web page, perl on your machine cannot change
which process is listening on the other machine.
 In short I guess you can if the other machine is listening,
but you might want to use a more suitable lib for it.
 Regards,
 Rob

On Thu, Jul 31, 2008 at 8:41 AM, Richard Lee
<[EMAIL PROTECTED] 
>> wrote:

   say I have big wireshark file based on remote server.

   I want to logon to that server and using Net::Pcap to poke the
   file and only grep out small portion of information which
meets my
   criteria.
   Remote server won't have Net::Pcap installed.

   I wanted to write this program w/ Expect modules and Net::Pcap
   module in my mind.
   But since these things are only located in my local server,
will
   this work on remote server?

   --To unsubscribe, e-mail:
[EMAIL PROTECTED]

   >

   For additional commands, e-mail: [EMAIL PROTECTED]

   >
   http://learn.perl.org/




Hi,

local server(w/ Perl installed) ---> remote
server(with Pcap file I am interested in poking around)

if I launch a perl script from my local server(using say Net::SSH)
and logs onto remote server, my perl can poke around that file on
remote server
using Net::Pcap ? So essentially in order to do this, I need
to use 2 modules(to logon, and then parsing out the pcap file)

I am thinking about writing this but just not sure if it will work
on remote server


but I am interested in grepping out the pcap file so I cannot simply 
just do grep


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: can perl program do this?

2008-07-31 Thread Rob Coops
 Ah, I see...

I think you have been misled by the name of the Net::Pcap lib, the lib is
meant to produce the file you are trying to poke around in.

I would do the follwoing.

   - Use Net::SSH or similair to connect to the remote machine.
   - On the remote machine use grep or similair to pull out the lines you
   are intrested in and store those in an array/file or well what ever storage
   you like on your side.
   - Process the data on your own machine.

The advantage of this is that you only move the data you are intrested in
over the network and not the whole big file, thus reducing the network
trafic and maning your network admins happy as well. Because you have the
data on your side you can then do with it what you want without having to
rely on any software on the remote machine.

I hope this helps a bit,

Rob
 On Thu, Jul 31, 2008 at 9:06 AM, Richard Lee <[EMAIL PROTECTED]> wrote:

> Rob Coops wrote:
>
>> If you can make Net::Pcap connect to a remote server things will work
>> fine, I am not sure about using Net::Pcap to do this as I never used it and
>> from the description it seems to be a packet capture lib not so much a
>> communication one, but as I said if you can make it reach out and talk to
>> the other side you should be fine.
>>  I think you will end up using somehting like Net::SSH or something like
>> that as these are more aimed at communication then Net::Pcap seems to be.
>>  But in the end as long as the other side is listening on a port and you
>> can produce the required packets to get communication going you should be
>> fine, there is no need to have perl, or any perl libs on the other side all
>> that is needed is an open port that you can communicate with.
>> The thing that is listening on that port is what determins what you can
>> do, read email, open and interact with files or just browse a web page, perl
>> on your machine cannot change which process is listening on the other
>> machine.
>>  In short I guess you can if the other machine is listening, but you might
>> want to use a more suitable lib for it.
>>  Regards,
>>  Rob
>>
>> On Thu, Jul 31, 2008 at 8:41 AM, Richard Lee <[EMAIL PROTECTED]> [EMAIL PROTECTED]>> wrote:
>>
>>say I have big wireshark file based on remote server.
>>
>>I want to logon to that server and using Net::Pcap to poke the
>>file and only grep out small portion of information which meets my
>>criteria.
>>Remote server won't have Net::Pcap installed.
>>
>>I wanted to write this program w/ Expect modules and Net::Pcap
>>module in my mind.
>>But since these things are only located in my local server, will
>>this work on remote server?
>>
>>--To unsubscribe, e-mail: [EMAIL PROTECTED]
>>
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>http://learn.perl.org/
>>
>>
>>
>>
> Hi,
>
> local server(w/ Perl installed) ---> remote server(with
> Pcap file I am interested in poking around)
>
> if I launch a perl script from my local server(using say Net::SSH) and logs
> onto remote server, my perl can poke around that file on remote server
> using Net::Pcap ? So essentially in order to do this, I need to use 2
> modules(to logon, and then parsing out the pcap file)
>
> I am thinking about writing this but just not sure if it will work on
> remote server
>
>


Re: can perl program do this?

2008-07-31 Thread Richard Lee

Rob Coops wrote:
If you can make Net::Pcap connect to a remote server things will work 
fine, I am not sure about using Net::Pcap to do this as I never used 
it and from the description it seems to be a packet capture lib not so 
much a communication one, but as I said if you can make it reach out 
and talk to the other side you should be fine.
 
I think you will end up using somehting like Net::SSH or something 
like that as these are more aimed at communication then Net::Pcap 
seems to be.
 
But in the end as long as the other side is listening on a port and 
you can produce the required packets to get communication going you 
should be fine, there is no need to have perl, or any perl libs on the 
other side all that is needed is an open port that you can communicate 
with.
The thing that is listening on that port is what determins what you 
can do, read email, open and interact with files or just browse a web 
page, perl on your machine cannot change which process is listening on 
the other machine.
 
In short I guess you can if the other machine is listening, but you 
might want to use a more suitable lib for it.
 
Regards,
 
Rob


On Thu, Jul 31, 2008 at 8:41 AM, Richard Lee <[EMAIL PROTECTED] 
> wrote:


say I have big wireshark file based on remote server.

I want to logon to that server and using Net::Pcap to poke the
file and only grep out small portion of information which meets my
criteria.
Remote server won't have Net::Pcap installed.

I wanted to write this program w/ Expect modules and Net::Pcap
module in my mind.
But since these things are only located in my local server, will
this work on remote server?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]


For additional commands, e-mail: [EMAIL PROTECTED]

http://learn.perl.org/





Hi,

local server(w/ Perl installed) ---> remote server(with 
Pcap file I am interested in poking around)


if I launch a perl script from my local server(using say Net::SSH) and 
logs onto remote server, my perl can poke around that file on remote server
using Net::Pcap ? So essentially in order to do this, I need to use 
2 modules(to logon, and then parsing out the pcap file)


I am thinking about writing this but just not sure if it will work on 
remote server



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: can perl program do this?

2008-07-31 Thread Rob Coops
If you can make Net::Pcap connect to a remote server things will work fine,
I am not sure about using Net::Pcap to do this as I never used it and from
the description it seems to be a packet capture lib not so much a
communication one, but as I said if you can make it reach out and talk to
the other side you should be fine.

I think you will end up using somehting like Net::SSH or something like that
as these are more aimed at communication then Net::Pcap seems to be.

But in the end as long as the other side is listening on a port and you can
produce the required packets to get communication going you should be fine,
there is no need to have perl, or any perl libs on the other side all that
is needed is an open port that you can communicate with.
The thing that is listening on that port is what determins what you can do,
read email, open and interact with files or just browse a web page, perl on
your machine cannot change which process is listening on the other machine.

In short I guess you can if the other machine is listening, but you might
want to use a more suitable lib for it.

Regards,

Rob

On Thu, Jul 31, 2008 at 8:41 AM, Richard Lee <[EMAIL PROTECTED]> wrote:

> say I have big wireshark file based on remote server.
>
> I want to logon to that server and using Net::Pcap to poke the file and
> only grep out small portion of information which meets my criteria.
> Remote server won't have Net::Pcap installed.
>
> I wanted to write this program w/ Expect modules and Net::Pcap module in my
> mind.
> But since these things are only located in my local server, will this work
> on remote server?
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>