Search the web
Sign In
New User? Sign Up
Perl_Official · Perl . CGI . Shell script
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Messages 2033 - 2062 of 2062   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Show Message Summaries   (Group by Topic) Sort by Date ^  
#2033 From: rob_wilson_98
Date: Tue Aug 14, 2007 2:21 pm
Subject: [Perl] Re: Regarding killing process
rob_wilson_98
Online Now Online Now
 
--- In Perl_Official@yahoogroups.com, avinash k <avik1612@...> wrote:
>
> hi,
>
>   i am using the unix opearting system.
>   I have attached the code
>   It is still not able to kill the process
>
>   Thanks in advance
>   Avinash

The code may have gotten stripped as a "non-text attachment".  Try
pasting the relevant portion(s) in-line.

A few things could keep you from being able to kill processes:

* "kill" is not in your path - try running "kill -l" from a command
line, it should result in a list of signals.
* You do not have permission to kill the process being attempted -
modify your script to print the kill statements and try running them
manually.
* You are not providing a process ID - This is going to depend what
you think is in @pid, what is actually in @pid, and what you think is
in $_ and what is actually in $_.  Print is your friend in this case.
  Or you can learn the perl debugger (a wonderful tool!) and inspect
your variables around the kill statement.
* You should check $? for the status of the `` command to see how it
exited.

#2034 From: "Glen" <glen.brydon@...>
Date: Mon Aug 13, 2007 6:10 pm
Subject: [Perl] Re: Regarding killing process
glen_brydon
Offline Offline
Send Email Send Email
 
Avinash,

The last suggestion which surrounded the kill command with grave
accents (`kill -9 PID`) was essentially causing perl to spawn a
process and running UNIX kill command. If this fails to work, then
your problem has nothing to do with perl. Check the following:

1) Make sure that the value that $pid[$_] evaluates to is in fact the
process number of some existing process. You might want to go back to
your original version to verify what the value is. You should get the
word kill (all lower case).

2) The perl kill function takes small positive integer values for the
various signals, whereas with the UNIX shell level kill command, the
signal value is immediately preceded by a dash. Using a negative value
means to send the signal to all the members of a process group which
is likely NOT what you intended to do. Perl documentation cannot tell
you what will happen or exactly what values to use. You MUST consult
your UNIX documentation with the man command (see below).

3) Please be aware that any process in a Unix/Linux system cannot kill
(i.e., send a signal to another process) unless that other process has
permission to do so. If you try typing an explicit kill -9 PID command
at the shell and the process does not die, then you do not have
permission to kill it. I won't attempt to explain how the permission
system works, nor the details of what processes generally are able to
send signals to other processes other than to say that the ROOT (super
user) can do anything, whereas most other processes can only send
signals to other processes created by the same user.

4) If you are not familiar with what signals are or how the
permissions system works with UNIX, then you might want to consult
your online documentation. Type: man kill <return> to get started.

5) Should you want to get better results from using a group like this,
be sure that you have a decent grasp of your problem first and provide
us with the essential information. There is nothing magical about
Perl's kill command, since it most assuredly invokes the local Unix
system kernel using the same system call that the shell's kill command
does. Any properly installed UNIX or UNIX derivative system like
Cygwin or Linux should have manual pages. If the specific manual page
you view doesn't provide you with the clue you need, then go to the
bottom of the manual page and check one or more cross referenced
pages. Also, if you perform any tests, provide us with enough clues of
what happens so that we can be of help to you, otherwise you're just
wasting your time and ours.

Good luck,
Glen

--- In Perl_Official@yahoogroups.com, avinash k <avik1612@...> wrote:
>
> hi,
>
>   i am using the unix opearting system.
>   I have attached the code
>   It is still not able to kill the process
>
>   Thanks in advance
>   Avinash
>
> rob_wilson_98 <no_reply@yahoogroups.com> wrote:
>           --- In Perl_Official@yahoogroups.com, avinash k
<avik1612@> wrote:
> >
> > hi,
> >
> > i am trying this statement but it is not executing i.e. killing
> process
> >
> > $force ="-9";
> >
> > print "Kill $force $pid[$_]\n";
> >
> >
> > Thanks and Regards
> > Avinash
> >
> >
>
> All your script would do is print out a Kill message. It will not
> execute the Kill command. In fact, I am not aware of a "Kill"
> command. If you're on Windows, you must have some sort of unix-like
> toolkit involved and then you'd probably still need the "kill" command
> - note no capitalization. On Unix things are case-sensitive so you
> have to use the "kill" command. It also has to be in your path (it
> normally is by default).
>
> Perhaps you're looking for something like:
>
> $force = "-9";
> `kill $force $pid[$_]`;
>
> If that's not what you want, post more information such as the OS,
> what you're trying to accomplish, and what _exactly_ seems to be the
> problem (error messages, observed behavior, output from "use strict"
> or "-w", etc.
>
>
>
>
>
>
>
>
>
>
>
>
>
> ---------------------------------
>  Once upon a time there was 1 GB storage in your inbox. Click here
for happy ending.
>
> [Non-text portions of this message have been removed]
>

#2035 From: merlyn@...
Date: Tue Aug 14, 2007 4:59 pm
Subject: Re: [Perl] Re: Regarding killing process
merlynstoneh...
Offline Offline
Send Email Send Email
 
>>>>> "Glen" == Glen  <glen.brydon@...> writes:

Glen> The last suggestion which surrounded the kill command with grave
Glen> accents (`kill -9 PID`) was essentially causing perl to spawn a
Glen> process and running UNIX kill command. If this fails to work, then
Glen> your problem has nothing to do with perl. Check the following:

And beyond all that:

     DO NOT USE KILL 9.

That's a *last resort* kill.  Please try to kill the pid nicely first.
kill -9 will BREAK THINGS on your system.  I don't know where people
got the idea to try this first... it's a bit like stopping your engine
by ripping out the ignition wires instead of just turning the key.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

#2036 From: "chipwillis2003" <chipwillis2003@...>
Date: Tue Aug 14, 2007 8:42 pm
Subject: Getting Microsoft SQL data through ODBC and Perl?
chipwillis2003
Offline Offline
Send Email Send Email
 
Hi,
  I am fairly new to Perl and have written some Perl to interface
with an API that comes with an application i am working with. I now
need to bypass the API and go directly to the Microsoft SQL server
data base. The SQl server is the same box that the Perl code is on.
i am Admin on the box. I have set up an ODBC and have gotten some
code from the web to get me started. i have gotten to the following
part where I have note the Perl code stops.
I have two questions.

One is how can i get better debugging than printing out test data on
different lines?

And of course why does this code not work?

See below:

#!/usr/bin/perl -w
use URI::Escape;
use LWP::UserAgent;
use XML::Simple;
use Data::Dumper;
use DBI;

print "Content-type:text/html\n\n";

#print "test 1";

#SQL_test_1.pl

  # Function:     dbh_connect
      # Description:  Creates a connection to a database
      # Arguments:    none
      # Returns:      $db_conn - database connection handle
      #


     $db_user     = "sa";
     $db_pass     = "sa55";
     $dsn_name    = 'dbi:ODBC:iLincEmailAddress';


sub dbh_connect
      {
          my ($dbh);

          $dbh = DBI->connect($dsn_name, $db_user, $db_pass, {
                      PrintError => 0,
                      AutoCommit => 1
                  });

          if (! defined($dbh) )
          {
              print "Error connecting to DSN '$dsn_name'\n";
              print "Error was:\n";
              print "$DBI::errstr\n";         # $DBI::errstr is the
error
                                              # received from the SQL
server

              return 0;
          }

          return $dbh;
  }

dbh_connect;
print"Test 2<BR>";

#Opens DB ODBC connection

  if (! dbh_connect() )
                 {
                     print "Unable to connect to database.\n";

                     exit;   # Unable to reconnect, exit the script
gracefully
                 }
                 else
                 {
                	 print "DSN connected to database.\n <BR>";
                 }

   print"Test 3 <BR>";

   my ($sql, $sth, $rc);

               $sql = shift;

               if (! ($sql) )
  	                 {
  	                     print ("Must pass SQL statement to
db_sql!\n");

  	                     return 0;
               }


print "Test 4 <BR>";

my ($sql, $sth, $href);

$sql = "SELECT EMAIL FROM LMS_USER";
         print "$sql <BR>";







#********************************************************************
****************************************
              # failing here <----------------------------------------
--------------------------->  failing here
$sth = $dbh->prepare($sql);     # Prepare the SQL statement passed
to db_sql

$sth = db_sql($sql);  # Pass the SQL statement to the server
print "Test 5 <BR>";




if ( ! defined( $sth ) || ! ($sth) )
	                     {
	                         print "Unable to prepare SQL
statement:\n";

	                         print "$sql\n";

	                         return 0;

               }

$rc = $sth->execute;
print "Test 6";


         #
         # Check that we received a statement handle
         #
         if (! ($sth) )
         {
             return 0;
         }

while( $href = $sth->fetchrow_hashref )
         {
             print "EMAIL: " . $$href{"EMAIL"} . "\n";

         }

         return 1;

print"Test 7 <BR>";





  print"Test 8<BR>";
             return $sth;

  print"Test 9<BR>";

End of code.
Thanks
Chip

#2037 From: avinash k <avik1612@...>
Date: Thu Aug 16, 2007 9:24 am
Subject: Re: [Perl] Re: Regarding killing process
avik1612
Offline Offline
Send Email Send Email
 
hi,

   i am killing all the process that are displayed using the ps command.
but doing that the particular unix session also terminates.
   so how to prevent the unix session from terminating
  i.e. the unix shell (csh) must not terminate but all the process must
terminate.

   i have pasted the code :

   #!/usr/bin/perl -w
#-------------------------------------------------------------------------------\
----#
# field explanations for the ps -ef command on solaris.
#
#
#
# Field Name  Field description
#
# UID       User ID of the current process (i.e., the user this process belong
to) #
# PID       Process ID of the current process
#
# PPID       Process ID of the parent process
#
# C       Obsolete (processor utilization for scheduling)                       
#
# STIME      Starting time of the process
#
# TTY       Controlling terminal for the process
#
# TIME       Cumulative execution time for the process
#
# CMD       Unix command name
#
#-------------------------------------------------------------------------------\
----#
  
#-----------------------------------------------------------------------------#
#                                                                             #
#  PROGRAM: Killprocess.pl                                                #
#                                                                             #
#  PURPOSE: Track the ancestry/lineage of a given PID.                    #
#  Useful for understandings the parent/grandparent processes    #
#  of a given PID, which can help in understanding and           #
#  debugging process problems.                                   #
#                                                                             #
#  NOTES: This program was written for Sun's Solaris operating system,  #
#               and may not properly read the 'ps -ef' output for other       #
#               versions of Unix.                                             #
#                                                                             #
#-----------------------------------------------------------------------------#
   use strict;
use vars qw($force $help);
sub init {
        use Getopt::Long;
        # process command line options
      GetOptions (
      'force'    => \$force,
      'help'     => \$help,
      );
      usage() if ( $help );
      if ( $force ) {
         $force = "-9";
      } else {
         $force = "";
      }
}

#
# Message about this program and how to use it
#
   sub usage() {
       print STDERR << "EOF";
         This program is used to kill rsync processes on sawfish.
         This program is used as follows...
         usage: $0 [-help] [-force]
         -help                       : this (help) message
       -force : Use the -9 flag while killing the processes.
         example: $0 -force
         Process numbers to be deleted can be specified on\n      the command
line in any of the following formats:

       1 - Single Number
       1 2 3 - Multiple numbers seperated by spaces
       1,2,3 - Multiple numbers seperated by commas
       1, 2, 3 - Multiple numbers seperated by spaces and commas
       rsync - Text strings which are searched for in the running commands
EOF
       exit;
}
#---------------#
#  getPsefData  #
#---------------#
   my @ucmd;   # The array @ucmd holds the running commands.
my @pid;    # The array @pid has pids.
   sub getPsefData {
      open(PSEF_PIPE,"ps -ef| grep -i akrishna|");
      my $i=0;
      while (<PSEF_PIPE>) {
         chomp;
         #-------------------------------------------------#
         # Temporary array to hold the ps -ef data.        #
         #-------------------------------------------------#
           my @psefField      = split(' ', $_, 8);
          
#----------------------------------------------------------------------------#
         # The array @pid contains the PIDs. #
        
#----------------------------------------------------------------------------#
           $pid[$i] = $psefField[1];
          
#----------------------------------------------------------------------------#
         # The array @ucmd has the corresponding running commands. #
        
#----------------------------------------------------------------------------#
           $ucmd[$i] = $psefField[7];
         $i++;
      }
      close(PSEF_PIPE);
     }
   sub Select {
   my($prompt, @choices) = @_;
   my $j = 0; my @out; my $k = 0;
     while(1) {
     my $i = 0;
     print STDERR join("\n", map{++$i.") $_"} @choices), "\n";
     print STDERR ++$i.") All Defunct Processes\n";
     print STDERR ++$i.") All Processes\n";
     print STDERR ++$i.") Quit\n";
     print STDERR << "EOF";
         Process numbers to be deleted can be specified on\n      the command
line in any of the following formats:
         1 - Single Number
       1 2 3 - Multiple numbers seperated by spaces
       1,2,3 - Multiple numbers seperated by commas
       1, 2, 3 - Multiple numbers seperated by spaces and commas
       rsync - Text strings which are searched for in the running commands
EOF
     print STDERR $prompt, "\n";
     my $answer = lc <STDIN>;
     chomp $answer;
     if ($answer =~ /^\d+$/) {
         if($answer == $i) {
           print "Exiting without deleting any processes\n";
           exit;
         } elsif ($answer  == $i-1) {
              print "All processes need to be deleted\n";
              foreach (0..$i-3) {
                 $out[$_] = $_;
              }
         } elsif ($answer  == $i-2) {
           print "All Defunct processes need to be deleted\n";
           my @out = GrepCmd ("defunct", @choices);
         }
     } elsif ($answer =~ /^[\d,\s]+$/) {
         @out = split( /[,\s]+/, $answer );
         @out = map {if($_ == $i || $_ == $i-1 || $_ == $i-2) {} else {--$_;}}
@out;
         # { local $" = '"';
         #   print "The final selection is @out\n";
         # }
     } else {
       # If the user entered some text, match it with the currently running
commands.
       my @out = GrepCmd ($answer, @choices);
     }
     return @out if @out;
   }
}
   sub GrepCmd {
    my($answer, @choices) = @_;
    print "Deleting Processes matching the string $answer\n";
    my $j = 0; my @out; my $k = 0;
    foreach (@choices) {
         if( /$answer/i ) {
           # $j is calculates the actual index of the running cmd in the ucmd
array.
           # $k increments the index of the out array.
           $out[$k] = $j;
           $k++;
         }
         $j++;
    }
    return @out if @out;
}
   #-------------------------  Main  ---------------------------#
   #------------------------------------------------------------#
#  Step 1:  Populate the ps -ef data, and put it in the      #
#           desired arrays and hashes.                       #
#------------------------------------------------------------#
&init;
   &getPsefData;
   #--------------------------------------------------#
#  Step 2:  Show the user all the PIDs to kill.    #
#--------------------------------------------------#
   my @choice = Select('Select the Processes to delete:', @ucmd);

print "The Select routine returned @choice\n";
   foreach (@choice) {
  my $cmd = `kill -9 $pid[$_]`;
  my $result = $cmd;
  print "Kill $result $pid[$_]\n";
   }


   Thanks in Advance
   Avinash

Glen <glen.brydon@...> wrote:
           Avinash,

The last suggestion which surrounded the kill command with grave
accents (`kill -9 PID`) was essentially causing perl to spawn a
process and running UNIX kill command. If this fails to work, then
your problem has nothing to do with perl. Check the following:

1) Make sure that the value that $pid[$_] evaluates to is in fact the
process number of some existing process. You might want to go back to
your original version to verify what the value is. You should get the
word kill (all lower case).

2) The perl kill function takes small positive integer values for the
various signals, whereas with the UNIX shell level kill command, the
signal value is immediately preceded by a dash. Using a negative value
means to send the signal to all the members of a process group which
is likely NOT what you intended to do. Perl documentation cannot tell
you what will happen or exactly what values to use. You MUST consult
your UNIX documentation with the man command (see below).

3) Please be aware that any process in a Unix/Linux system cannot kill
(i.e., send a signal to another process) unless that other process has
permission to do so. If you try typing an explicit kill -9 PID command
at the shell and the process does not die, then you do not have
permission to kill it. I won't attempt to explain how the permission
system works, nor the details of what processes generally are able to
send signals to other processes other than to say that the ROOT (super
user) can do anything, whereas most other processes can only send
signals to other processes created by the same user.

4) If you are not familiar with what signals are or how the
permissions system works with UNIX, then you might want to consult
your online documentation. Type: man kill <return> to get started.

5) Should you want to get better results from using a group like this,
be sure that you have a decent grasp of your problem first and provide
us with the essential information. There is nothing magical about
Perl's kill command, since it most assuredly invokes the local Unix
system kernel using the same system call that the shell's kill command
does. Any properly installed UNIX or UNIX derivative system like
Cygwin or Linux should have manual pages. If the specific manual page
you view doesn't provide you with the clue you need, then go to the
bottom of the manual page and check one or more cross referenced
pages. Also, if you perform any tests, provide us with enough clues of
what happens so that we can be of help to you, otherwise you're just
wasting your time and ours.

Good luck,
Glen

--- In Perl_Official@yahoogroups.com, avinash k <avik1612@...> wrote:
>
> hi,
>
> i am using the unix opearting system.
> I have attached the code
> It is still not able to kill the process
>
> Thanks in advance
> Avinash
>
> rob_wilson_98 <no_reply@yahoogroups.com> wrote:
> --- In Perl_Official@yahoogroups.com, avinash k
<avik1612@> wrote:
> >
> > hi,
> >
> > i am trying this statement but it is not executing i.e. killing
> process
> >
> > $force ="-9";
> >
> > print "Kill $force $pid[$_]\n";
> >
> >
> > Thanks and Regards
> > Avinash
> >
> >
>
> All your script would do is print out a Kill message. It will not
> execute the Kill command. In fact, I am not aware of a "Kill"
> command. If you're on Windows, you must have some sort of unix-like
> toolkit involved and then you'd probably still need the "kill" command
> - note no capitalization. On Unix things are case-sensitive so you
> have to use the "kill" command. It also has to be in your path (it
> normally is by default).
>
> Perhaps you're looking for something like:
>
> $force = "-9";
> `kill $force $pid[$_]`;
>
> If that's not what you want, post more information such as the OS,
> what you're trying to accomplish, and what _exactly_ seems to be the
> problem (error messages, observed behavior, output from "use strict"
> or "-w", etc.
>
>
>
>
>
>
>
>
>
>
>
>
>
> ---------------------------------
> Once upon a time there was 1 GB storage in your inbox. Click here
for happy ending.
>
> [Non-text portions of this message have been removed]
>













---------------------------------
  Once upon a time there was 1 GB storage in your inbox. Click here for happy
ending.

[Non-text portions of this message have been removed]

#2038 From: "Luinrandir Hernsen" <lhernsen1015@...>
Date: Fri Aug 31, 2007 3:24 am
Subject: Backreference question
luinrandir
Offline Offline
Send Email Send Email
 
Example string
$Data=":2-Name1:4-Name2:3-Name3:1-Name4:";

I need to get the following info
:4-Name2:

But All I can search with is
:4-anything:
In other words I know it starts with :4-
then it has a name in the middle
and ends with the next :

my guess is
$Info = ($Data =~ /(:4-*:)/);
$Info if the var assigned the value sought.
$Data is the string I am searching
:4- and the last : are know
* are the unknown characters, if any

here is the program
#!/usr/bin/perl
use strict ;

my $Data=":2-Name1:4-Name2:3-Name3:1-Name4:";
my $Info = ($Data =~ /(:4-*:)/);
print ">$Info<";

#2039 From: "Lou Hernsen" <lhernsen1015@...>
Date: Fri Aug 31, 2007 5:16 am
Subject: I found an answer to BackReference, your input?
luinrandir
Offline Offline
Send Email Send Email
 
#!/usr/bin/perl
use strict ;
my @Name;
my $Name;

my $X = 1;
my $Y = 2;
my $Data=":2-Lou-14:4-Bobby:3-Tine13:1-jack 23:";
my $Info = ($Data =~ /:$Y-(.*?):/);
$Name[$X,$Y] = $1;
print ">$Name[$X,$Y] is at X$X,Y$Y<\n";

[Non-text portions of this message have been removed]

#2040 From: Glen Brydon <glen.brydon@...>
Date: Fri Aug 31, 2007 5:12 pm
Subject: Re: [Perl] Backreference question
glen_brydon
Offline Offline
Send Email Send Email
 
The main problem with your attempted solution is that .* is greedy. This
means that the colon it would find is the last one on the line. Greedy
means that .* wants to maximize the number of characters found. The old
solution to this is to replace .* with [^:]*, which matches as many
non-colons as possible, which obviously will not advance the match
beyond the first colon. The newer and more general solution is to use
the non-greed variant on .*, which is .*? (? modifies the * to make it
non-greedy).

Luinrandir Hernsen wrote:

> Example string
> $Data=":2-Name1:4-Name2:3-Name3:1-Name4:";
>
> I need to get the following info
> :4-Name2:
>
> But All I can search with is
> :4-anything:
> In other words I know it starts with :4-
> then it has a name in the middle
> and ends with the next :
>
> my guess is
> $Info = ($Data =~ /(:4-*:)/);
> $Info if the var assigned the value sought.
> $Data is the string I am searching
> :4- and the last : are know
> * are the unknown characters, if any
>
> here is the program
> #!/usr/bin/perl
> use strict ;
>
> my $Data=":2-Name1:4-Name2:3-Name3:1-Name4:";
> my $Info = ($Data =~ /(:4-*:)/);
> print ">$Info<";
>
>

#2041 From: "Lou Hernsen" <lhernsen1015@...>
Date: Sat Sep 1, 2007 3:24 am
Subject: Re: [Perl] Backreference question
luinrandir
Offline Offline
Send Email Send Email
 
Thanks for the responce Glen
If you going to ask why I don't use MySql... I have not had time to figure
out
who to use it... I am just now begining to grasp RegEx ;)
Lou

Here is what I came up with

    open (READ, "$PlayerFiles/-L1-.DB")||FailPage("I can't READ -L1- <BR> $!
");
    flock (READ,2);
    @DB = <READ>;
    close (READ);

    foreach $DB(@DB)
    {
      chomp $DB;
     @Name = split (/:/,$DB);
     foreach $Name(@Name)
     {
      ($X,$Y,$Value)=($Name =~ /(.*?)#(.*?)#(.*?)#/);
      if ($Value)
      {
       $Position[$X,$Y]=$Value;
      }
     }
    }

#2042 From: avinash k <avik1612@...>
Date: Wed Sep 5, 2007 11:26 am
Subject: How to search particular words in a file
avik1612
Offline Offline
Send Email Send Email
 
hi,

   I am trying to find particular words in text files(i.e. *.txt files)

   Should i use regular expressions in doing?

   Thanks in advance
   Avinash










---------------------------------
  Get the freedom to save as many mails as you wish. Click here to know how.

[Non-text portions of this message have been removed]

#2043 From: pukazhs
Date: Wed Sep 5, 2007 9:51 pm
Subject: how to find about environmental variables in hash table
pukazhs
Offline Offline
 
Hi,


Actually i want to check if a environmental variable in perl script,
which is present in oracle database has been already set its path in
hash table in perl.

that is i have to query the database server and check whether it has
been set as environment variable or not.

so basically i want to check with if statement to database server name
and a loop to check for all variables present in perl by quering the
database....to find those variables has been set as environment
variable or not.....if present it should be in hash table....

so i need the syntax and proper logic to test this......

it would be great if anyone can help me out...

#2044 From: "K. Senthil Kumar" <ksenthil@...>
Date: Sat Sep 8, 2007 2:44 am
Subject: RE: [Perl] How to search particular words in a file
senmal2003
Offline Offline
Send Email Send Email
 
Hello Avinash,

     yes u can easily find the word and its line through regx.  here i have
just given a simple example to your reference.
     im also preparing the perl and working in small tasks. keep in touch
regarding any perl related discussion.


#usr/bin/perl
use warnings;
open(my $sen, "<", "input.txt") or die "cant open input.txt";
my @list = <$sen>;
my $txt;
close $sen;
foreach (@list) {
if ($_ =~ /gmail/) {
   open($txt, ">> utxt.txt")  or die "Can't open input.txt:";
   print $txt $_;
   close $txt;
  }
}

Thanks,
K. Senthil Kumar



   -----Original Message-----
   From: Perl_Official@yahoogroups.com
[mailto:Perl_Official@yahoogroups.com]On Behalf Of avinash k
   Sent: Wednesday, September 05, 2007 4:56 PM
   To: Perl_Official@yahoogroups.com
   Subject: [Perl] How to search particular words in a file


   hi,

   I am trying to find particular words in text files(i.e. *.txt files)

   Should i use regular expressions in doing?

   Thanks in advance
   Avinash


   ---------------------------------
   Get the freedom to save as many mails as you wish. Click here to know how.

   [Non-text portions of this message have been removed]






[Non-text portions of this message have been removed]

#2045 From: "arun5167" <arun5167@...>
Date: Fri Sep 7, 2007 12:33 pm
Subject: pl some one post perl tutorial with examples
arun5167
Offline Offline
Send Email Send Email
 
please someone post perl turorial with examples expecially for
administrators
Thanks in advance

#2046 From: "millerdw2003" <darren@...>
Date: Sat Sep 8, 2007 5:07 pm
Subject: Re: How to search particular words in a file
millerdw2003
Offline Offline
Send Email Send Email
 
Avinash,

Here's one solution.

Darren

====

#!/bin/perl/bin

###
### title:  pgrep
### author: darren miller
###
### perl alternative to UNIX grep command,
### which searches for patterns in a file.
### exhanced version of the program by the same
### name in the camel book from O'Reilly.
###
### usage: pgrep -i -e "html" -e "form" *.html *.htm
###
### -i = ignore case
### -e = identifies a regular expression to search for
###

my @expressions;        # array of regular expressions to search for
my @fileglobs;          # array of filename patterns to search in
my $ignorecase="false"; # ignore case?

while ($param = shift(@ARGV)) {
    if ($param eq "-e") {
       push @expressions, shift(@ARGV);
    } elsif ($param eq "-i") {
       $ignorecase = "true";
    } else {
       push @fileglobs, $param;
    }
}

foreach $fglob (shift(@fileglobs)) {                        # loop
through file name patterns
    foreach $f (glob($fglob)) {                              # loop
through files that match the current pattern
       if (open FH, "<$f") {                                 # open
the file
          my $line=0;                                        #
initialize a line counter
          while (<FH>) {                                     # loop
through the current file
             $line++;                                        #
increment counter
             foreach $expression (@expressions) {            # loop
through expressions
                if ((m/$expression/) or ($ignorecase eq "true" and m/
$expression/i)) { # check for a match
                   printf "%s (%.6d): %s", $f, $line, $_;    # print
the file name, line number, and line
                }
             }
          }
       }
    }
}


--- In Perl_Official@yahoogroups.com, avinash k <avik1612@...> wrote:
>
> hi,
>
>   I am trying to find particular words in text files(i.e. *.txt
files)
>
>   Should i use regular expressions in doing?
>
>   Thanks in advance
>   Avinash

#2047 From: "Yogesh Sawant" <yoga_sawant@...>
Date: Wed Sep 12, 2007 8:35 am
Subject: Re: pl some one post perl tutorial with examples
yoga_sawant
Offline Offline
Send Email Send Email
 
--- In Perl_Official@yahoogroups.com, "arun5167" <arun5167@...> wrote:
>
> please someone post perl turorial with examples expecially for
> administrators
> Thanks in advance
>
Here is a small exercise that I have prepared. This is meant for
someone who wants to learn Perl.

Exercise 1. In a Perl script, accept command line arguements.
Display all the arguements and also the number of arguements.

Expected output:

$ ex1.pl this that
Arguements: this that
Number of arguements: 2
$

===========================

Exercise 2. Accept a filename as command line arguement. Display the
contents of that file.

Expected output:

$ cat > newfile.text
How much is three times humpty-steen?
Elaine, Have you forgotten?
Why does a chicken cross the road?
Who carries home a toper's load?
You are so very stupid, dear!
Elaine, have you forgotten?
(Ctrl+C)$
$
$ ex2.pl newfile.text
How much is three times humpty-steen?
Elaine, Have you forgotten?
Why does a chicken cross the road?
Who carries home a toper's load?
You are so very stupid, dear!
Elaine, have you forgotten?
$

This is similar to displaying the contents of a file using cat
command.

===========================

Exercise 3. Accept a filename as command line arguement. Display all
lines of that file which contain letter d

Expected output:

$ ex3.pl newfile.text
Why does a chicken cross the road?
Who carries home a toper's load?
You are so very stupid, dear!
$

===========================

Exercise 4. Accept a filename as command line arguement. Display a
count of how many lines of that file contain letter d

Expected output:

$ ex4.pl newfile.text
newfile.text contains w 3 times
$

===========================

Exercise 5. Accept a filename as command line arguement. Display all
lines of that file which contain the character ?

Expected output:

$ ex5.pl newfile.text
How much is three times humpty-steen?
Elaine, Have you forgotten?
Why does a chicken cross the road?
Who carries home a toper's load?
Elaine, have you forgotten?
$

===========================

Exercise 6. Accept a filename as command line arguement. Display all
lines of that file which do not contain the letters w and W

Expected output:

$ ex6.pl newfile.text
Elaine, Have you forgotten?
You are so very stupid, dear!
Elaine, have you forgotten?
$

===========================

Exercise 7. Accept a string as first arguement and a filename as
second arguement.  Display all lines of that file which contain the
given string.

Expected output:

$ ex7.pl es newfile.text
How much is three times humpty-steen?
Why does a chicken cross the road?
Who carries home a toper's load?
$

The first steps of making our own grep command!

===========================

Exercise 8. Accept a username as command line arguement.  Display if
that user is currently logged in or not.  Run who or w command and
use its output to determine if the given user is logged in or not.

Expected output:

$ ex8.pl yogesh
yogesh is not logged in
$

$ ex8.pl root
root is logged in
$

===========================

Exercise 9. Accept a username as command line arguement.  Display if
that user is currently logged in or not; and if logged in, then how
many times.

Expected output:
$ ex9.pl root
root is logged in 3 times
$

Additional exercise: show "1 time" if user is logged in only once
and "x times" if user is logged in multiple times (use of s in times
only in case of multiple logins)

===========================

Exercise 10. Accept command line arguements.  Consider all command
line arguements as user names and for all the given user names,
display if they are logged in or not.

Expected output:
$ ex9.pl yogesh sandesh root
yogesh is not logged in
sandesh is not logged in
root is logged in
$

===========================

#2048 From: "Yogesh Sawant" <yoga_sawant@...>
Date: Wed Sep 12, 2007 8:46 am
Subject: Re: Accessing remote registry thru perl script
yoga_sawant
Offline Offline
Send Email Send Email
 
--- In Perl_Official@yahoogroups.com, vittal jadhav <vittalmj@...>
wrote:
>
> Hi
>   can some help me in writing a perl script to access remote registry.
>   Which modules required to installed etc.

If you are referring to Windows Registry, then check out these modules:
Win32::TieRegistry, Win32::TieRegistry::Dump, and Win32::Registry::File

Cheers
Yogesh

#2049 From: "Yogesh Sawant" <yoga_sawant@...>
Date: Wed Sep 12, 2007 8:52 am
Subject: Re: Want to lear Perl
yoga_sawant
Offline Offline
Send Email Send Email
 
--- In Perl_Official@yahoogroups.com, sujaymallesh <no_reply@...> wrote:
>
> Hi,
>
> I want to leanr Perl, can anyone tell me where can i get resources
for
> the same.
>
How do you lear or leanr Perl?
Your best offline resource for learning Perl would be: Programming Perl
3rd edition by Larry Wall, Tom Christiansen, and Jon Orwant (O'REILLY)

Cheers
Yogesh

#2050 From: avinash k <avik1612@...>
Date: Thu Sep 27, 2007 11:51 am
Subject: Unzipping the zip file
avik1612
Offline Offline
Send Email Send Email
 
Hi,
   I have to create a script to read a zip files of a folder and then extract all
those zip files to another destination
inside a folder created with the name of the zip file
  for e.g if the zip file is in D:/ab.zip then it should be extracted to D:/a/ab
where ab is the folder created with the
  name of the zip file

   I have pasted the code till how much i have tried what should i do further

   use Archive::Zip;
use Archive::Tar;
use File::Copy;
use File::Find;
use File::Basename;
   my @ext;
   find(\&search, "D:/aaa");
   sub search
  {
   if ((/\.zip$/) )
   {
   push @ext, $File::Find::name;
   print "@ext\n";
   }

  }

my @name1;
foreach my $fname(@ext)
{
my ($name, $path, $suffix) = fileparse($fname, '\.[^\.]*');
print STDOUT $name, "\n";
   }
print $name;
my $n= "D:/a/";
my $name1= join("/",$n,$name);
print @name1;
print $name;

mkdir $name1, 0755;
   foreach my $in (@ext)
{
open(IN, $in) || die " cannot open the file";
while(<IN>)
{
my $zipname = $_;
my $destinationDirectory = 'D:\a';
   my $zip = Archive::Zip->new($zipname);
foreach my $member ($zip->members)
{
     next if $member->isDirectory;
     (my $extractName = $member->fileName) =~ s{.*/}{};
     $member->extractToFileNamed("$destinationDirectory/$extractName");
}
    }
  close(IN);
}

   thanks in advance
   avi









---------------------------------
  5, 50, 500, 5000 - Store N number of mails in your inbox. Click here.

[Non-text portions of this message have been removed]

#2051 From: avinash k <avik1612@...>
Date: Fri Sep 28, 2007 9:34 am
Subject: problem in extracting the zip file
avik1612
Offline Offline
Send Email Send Email
 
Hi,

I have created a script to extarct a set of zip files in a particular folder to
another destination . In the destination folder a folder would be created with
the name of zip file and it would be extracted in that folder with the name of
zip file.

It is working well but when the zip file have subdirectories i.e folder inside
folder. It in ignore the subdirectory and extract the whole contents into a
single folder

What is wrong with my code

i have pasted the code for ur reference

# Script to unzip the zip files to a particular destination creating the folder
with the name of zip file

use Archive::Zip;
use Archive::Tar;
use File::Copy;
use File::Find;
use File::Basename;

my @ext;

find(\&search, "D:/aaa");

sub search
{
if ((/\.zip$/) )
{
push @ext, $File::Find::name;
#print "@ext\n";
}

}

my @name1;
foreach my $fname(@ext)
{
my ($name, $path, $suffix) = fileparse($fname, '\.[^\.]*');

my $n = "D:/a/";
my $name1 = join("/",$n,$name);
mkdir $name1,0755;
print "\n\n Made Folder ";
print STDOUT $name, "\n";


my $zipname = $fname;

#my $destinationDirectory = 'D:\a';
my $destinationDirectory = $name1;

my $zip = Archive::Zip->new($zipname);
foreach my $member ($zip->members)
{
next if $member->isDirectory;
(my $extractName = $member->fileName) =~ s{.*/}{};
$member->extractToFileNamed("$destinationDirectory/$extractName");
}
print "\n Finished Extraction";
}

Thanks in Advance
Avi








---------------------------------
  Unlimited freedom, unlimited storage. Get it now

[Non-text portions of this message have been removed]

#2052 From: "Shreedhar" <ps_dhar2000@...>
Date: Mon Oct 1, 2007 6:20 am
Subject: Re: Want to lear Perl
ps_dhar2000
Offline Offline
Send Email Send Email
 
If you are completely new to scripts and programs then, PERL in 21
days might help you.. just PRACTICE it before going to Programming
PERL - Larry Wall ..

Sridhar P

--- In Perl_Official@yahoogroups.com, "Yogesh Sawant"
<yoga_sawant@...> wrote:
>
> --- In Perl_Official@yahoogroups.com, sujaymallesh <no_reply@>
wrote:
> >
> > Hi,
> >
> > I want to leanr Perl, can anyone tell me where can i get
resources
> for
> > the same.
> >
> How do you lear or leanr Perl?
> Your best offline resource for learning Perl would be: Programming
Perl
> 3rd edition by Larry Wall, Tom Christiansen, and Jon Orwant
(O'REILLY)
>
> Cheers
> Yogesh
>

#2053 From: "Andy Schafer" <lostgameparts@...>
Date: Wed Oct 24, 2007 8:13 pm
Subject: Submit a form without leaving the page
lostgameparts
Offline Offline
Send Email Send Email
 
Hi,

I'm pretty new to Perl and need some help!

I am working on a project that requires 4 forms on the same page. I
would like to be able to submit each one separately but if the user
has entered information in any of the other 3, that information will
be lost. (I think, and please correct me if I'm wrong!)

What I'm wondering is this: Is there a way to submit a form to the CGI
script without actually leaving the page the form is on?

I thought about using iFrames for each form but really don't like that
idea. I could also use one submit button for all 4 forms but I don't
like that either.

I've hunted through all my books and on the net with no luck. I know
I'm probably overlooking something simple but I can't for the life of
me find it!

If any of you can help me I would really appreciate it!

Thank you very much!
Andy

#2054 From: Marcel Preda <marcel_preda@...>
Date: Fri Oct 26, 2007 7:31 am
Subject: Re: [Perl] Submit a form without leaving the page
marcel_preda
Offline Offline
Send Email Send Email
 
--- Andy Schafer <lostgameparts@...> wrote:

> Hi,
>
> I'm pretty new to Perl and need some help!
>
> I am working on a project that requires 4 forms on the same page. I
> would like to be able to submit each one separately but if the user
> has entered information in any of the other 3, that information will
> be lost. (I think, and please correct me if I'm wrong!)
>
> What I'm wondering is this: Is there a way to submit a form to the CGI
> script without actually leaving the page the form is on?
>
> I thought about using iFrames for each form but really don't like that
> idea. I could also use one submit button for all 4 forms but I don't
> like that either.
>
> I've hunted through all my books and on the net with no luck. I know
> I'm probably overlooking something simple but I can't for the life of
> me find it!
>
> If any of you can help me I would really appreciate it!
>
> Thank you very much!
> Andy
>

Hi,

The solution is HTML related.
All that you have to do is to add "target" attribute to the <form> element:
<form ... target="_blank" >.
In this case the form will be submitted and a new window will be open, keeping
your original
window's content.


regards,
Marcel


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

#2055 From: "millerdw2003" <darren@...>
Date: Fri Oct 26, 2007 2:21 pm
Subject: Re: Submit a form without leaving the page
millerdw2003
Offline Offline
Send Email Send Email
 
Andy,

I think the best way to accomplish what you're trying to do is to
use AJAX.  AJAX allows you to use JavaScript to issue an HTTP POST
or GET without reloading the page.  There's a perl module that makes
this (relatively) easy to do at http://search.cpan.org/~bct/CGI-Ajax-
0.701/lib/CGI/Ajax.pm.  The module includes several examples to get
you started.  If you're trying to anything very complicated, you'll
need to read up on HTML, CGI, Javascript, and (less critically) XML.

I'd recommend three books from O'Reilly and Associates (www.ora.com):
* Programming Perl
* JavaScript: the Definitive Guide 5th edition or later
* CGI Programming with Perl

The JavaScript book contains a whole chapter about AJAX that I found
quite helpful.

AJAX introduces significant additional complexity to your project --
particularly if you haven't dealt with JavaScript much before.  It
might be easier to rethink the way your application works and decide
if four independent forms on one page is worth the effort.

Darren

--- In Perl_Official@yahoogroups.com, "Andy Schafer"
<lostgameparts@...> wrote:
>
> Hi,
>
> I'm pretty new to Perl and need some help!
>
> I am working on a project that requires 4 forms on the same page. I
> would like to be able to submit each one separately but if the user
> has entered information in any of the other 3, that information
will
> be lost. (I think, and please correct me if I'm wrong!)
>
> What I'm wondering is this: Is there a way to submit a form to the
CGI
> script without actually leaving the page the form is on?
>
> I thought about using iFrames for each form but really don't like
that
> idea. I could also use one submit button for all 4 forms but I
don't
> like that either.
>
> I've hunted through all my books and on the net with no luck. I
know
> I'm probably overlooking something simple but I can't for the life
of
> me find it!
>
> If any of you can help me I would really appreciate it!
>
> Thank you very much!
> Andy
>

#2056 From: "kenshail2003" <ken@...>
Date: Fri Oct 26, 2007 7:30 pm
Subject: Re: Submit a form without leaving the page
kenshail2003
Offline Offline
Send Email Send Email
 
--- In Perl_Official@yahoogroups.com, "Andy Schafer"
<lostgameparts@...> wrote:
>
> Hi,
>
> I'm pretty new to Perl and need some help!
>
> I am working on a project that requires 4 forms on the same page. I
> would like to be able to submit each one separately but if the user
> has entered information in any of the other 3, that information will
> be lost. (I think, and please correct me if I'm wrong!)
>
> What I'm wondering is this: Is there a way to submit a form to the CGI
> script without actually leaving the page the form is on?
>
> I thought about using iFrames for each form but really don't like that
> idea. I could also use one submit button for all 4 forms but I don't
> like that either.
>
> I've hunted through all my books and on the net with no luck. I know
> I'm probably overlooking something simple but I can't for the life of
> me find it!
>
> If any of you can help me I would really appreciate it!
>
> Thank you very much!
> Andy
>

You write a script that calls itself.
Here is a simple calculator example, but remember that it has to be
run on a server. It uses cgi to send the entered values from the HTML
  form back to itself. The values from your other forms can be sent
back together with the newly entered ones in a similar way.

#!/usr/bin/perl -w

use strict;
use CGI qw(:standard);
our $q=new CGI;

our ($firstNumber,$secondNumber);

# This perl script calls itself and posts variables back to itself.
our $thisURL =$q->self_url;

our %data; #hash to store cgi params

foreach my $name ($q-> param() )
{
    $data{$name} = param($name);
}


# Get the path values from the query string
if (exists $data{firstNumber}) { $firstNumber=$data{firstNumber};}
else {$firstNumber=0;}
if (exists $data{secondNumber}) {$secondNumber=$data{secondNumber};}
else {$secondNumber=0;}

print $q->header('text/html');

&page1;

&sumsNprint; #do sums and print

print "</b></body>\n </html>\n";

#-------------------------------------------------------------------------------\
-------------------

sub page1  # print the HTML stuff
{
  print "
<html>
<head><TITLE>Mt page</TITLE>
</head>
<body leftmargin='20' marginwidth='10' bgcolor='#FFFFFF'>
<b>
<font face='Verdana,Arial,Helvetica,sans-serif'>

<H2> My page</H2>
Please fill out the following information and press the CALCULATE
button<BR>
</h4>

<form method='GET' action=$thisURL>
<TABLE BORDER=2 FRAME=box CELLPADDING=1 CELLSPACING=0>

<TR>
<TD><B><h5>First number</B>
<INPUT NAME='firstNumber' TYPE='text' SIZE='10'
VALUE=$firstNumber><BR></TD>
</TR>

<TR>
<TD><B><h5>Second Number</B>
<INPUT NAME='secondNumber' TYPE='text' SIZE='10'
VALUE=$secondNumber><BR></TD>
</TR>

</TABLE>
<BR>
<INPUT TYPE='submit' VALUE='CALCULATE'></FORM>

";
}

sub sumsNprint
{
  my $result=$firstNumber * $secondNumber;
  print "$firstNumber times $secondNumber = $result<BR>\n"
}

#2057 From: "kenshail2003" <ken@...>
Date: Sat Oct 27, 2007 1:14 pm
Subject: Re: Submit a form without leaving the page
kenshail2003
Offline Offline
Send Email Send Email
 
--- In Perl_Official@yahoogroups.com, "millerdw2003" <darren@...> wrote:
>
> Andy,
>
> I think the best way to accomplish what you're trying to do is to
> use AJAX.  AJAX allows you to use JavaScript to issue an HTTP POST
> or GET without reloading the page.  There's a perl module that makes
> this (relatively) easy to do at http://search.cpan.org/~bct/CGI-Ajax-
> 0.701/lib/CGI/Ajax.pm.  The module includes several examples to get
> you started.  If you're trying to anything very complicated, you'll
> need to read up on HTML, CGI, Javascript, and (less critically) XML.
>
> I'd recommend three books from O'Reilly and Associates (www.ora.com):
> * Programming Perl
> * JavaScript: the Definitive Guide 5th edition or later
> * CGI Programming with Perl
>
> The JavaScript book contains a whole chapter about AJAX that I found
> quite helpful.
>
> AJAX introduces significant additional complexity to your project --
> particularly if you haven't dealt with JavaScript much before.  It
> might be easier to rethink the way your application works and decide
> if four independent forms on one page is worth the effort.
>
> Darren
>
> --- In Perl_Official@yahoogroups.com, "Andy Schafer"
> <lostgameparts@> wrote:
> >
> > Hi,
> >
> > I'm pretty new to Perl and need some help!
> >
> > I am working on a project that requires 4 forms on the same page. I
> > would like to be able to submit each one separately but if the user
> > has entered information in any of the other 3, that information
> will
> > be lost. (I think, and please correct me if I'm wrong!)
> >
> > What I'm wondering is this: Is there a way to submit a form to the
> CGI
> > script without actually leaving the page the form is on?
> >
> > I thought about using iFrames for each form but really don't like
> that
> > idea. I could also use one submit button for all 4 forms but I
> don't
> > like that either.
> >
> > I've hunted through all my books and on the net with no luck. I
> know
> > I'm probably overlooking something simple but I can't for the life
> of
> > me find it!
> >
> > If any of you can help me I would really appreciate it!
> >
> > Thank you very much!
> > Andy
> >
>

#!/usr/bin/perl -w

use strict;
use CGI qw(:standard);
our $q=new CGI;

our ($firstNumber,$secondNumber);

# This perl script calls itself and posts variables back to itself.
our $thisURL =$q->self_url;

our %data; #hash to store cgi params

foreach my $name ($q-> param() )
{
    $data{$name} = param($name);
}


# Get the path values from the query string
if (exists $data{firstNumber}) { $firstNumber=$data{firstNumber};}
else {$firstNumber=0;}
if (exists $data{secondNumber}) {$secondNumber=$data{secondNumber};}
else {$secondNumber=0;}

print $q->header('text/html');

&page1;

&sumsNprint; #do sums and print

print "</b></body>\n </html>\n";

#-------------------------------------------------------------------------------\
-------------------

sub page1  # print the HTML stuff
{
  print "
<html>
<head><TITLE>Mt page</TITLE>
</head>
<body leftmargin='20' marginwidth='10' bgcolor='#FFFFFF'>
<b>
<font face='Verdana,Arial,Helvetica,sans-serif'>

<H2> My page</H2>
Please fill out the following information and press the CALCULATE
button<BR>
</h4>

<form method='GET' action=$thisURL>
<TABLE BORDER=2 FRAME=box CELLPADDING=1 CELLSPACING=0>

<TR>
<TD><B><h5>First number</B>
<INPUT NAME='firstNumber' TYPE='text' SIZE='10'
VALUE=$firstNumber><BR></TD>
</TR>

<TR>
<TD><B><h5>Second Number</B>
<INPUT NAME='secondNumber' TYPE='text' SIZE='10'
VALUE=$secondNumber><BR></TD>
</TR>

</TABLE>
<BR>
<INPUT TYPE='submit' VALUE='CALCULATE'></FORM>

";
}



sub sumsNprint
{
  my $result=$firstNumber * $secondNumber;
  print "$firstNumber times $secondNumber = $result<BR>\n"
}

#2058 From: "Andy Schafer" <lostgameparts@...>
Date: Sat Oct 27, 2007 1:40 pm
Subject: Re: Submit a form without leaving the page
lostgameparts
Offline Offline
Send Email Send Email
 
Hi,

Thank you both very much for you responses. I will try putting
"target='blank'" in my form tag first since that is the easiest but I
will definitely check into AJAX. I learned some basic Javascript
several years ago but have been finding that knowledge to be pretty
outdated so its time to spruce up my mental library anyway! I actually
got that O'Reilly Javascript book you mentioned a few days ago from
the local library and have it sitting on my desk waiting for me to get
the time to dive in!

Thanks again for your help!
Andy

#2059 From: "Andy Schafer" <lostgameparts@...>
Date: Sat Nov 24, 2007 2:34 am
Subject: Problem with a textbox in a form
lostgameparts
Offline Offline
Send Email Send Email
 
Hi,

I know this isn't strictly a Perl problem but it is in a Perl script
so I thought I would ask anyway.

On my site I have a simple flat file database. Each entry is 10 lines.
One line is the description of the item and contains some html tags to
format the text when it is displayed on my site. There are also some
that contain special characters such as " & $ ( ) etc.

The problem I have is this. I have a Perl script that allows me to
edit a database entry. It gives me a form with a text box for each of
the 10 lines. The "value" parameter of each text box is set to
whatever is currently shown in the database. The problem is that when
the text box for the description line encounters an entry containing
special characters or html tags it doesn't just show the entry "as-is"
from the database. Instead the special characters screw it up. For
instance entries containing a <br> tag jump outside the textbox with
part of the information.

So my question is this, is there a way to force the textbox to display
the information exactly the way it is supposed to be, html tags and all?

I have been hunting through my books and on the net but I don't even
know what to look for. If anyone can help I'd appreciate it very much!

Thanks in advance,
Andy Schafer

#2060 From: "nonapophthegm" <dave@...>
Date: Thu Jan 31, 2008 12:32 pm
Subject: Problem installing Net::Pcap
nonapophthegm
Online Now Online Now
Send Email Send Email
 
make
cc -c -Wall -Wwrite-strings -O2 -march=i486 -mcpu=i686
-DVERSION=\"0.16\" -DXS_VERSION=\"0.16\" -fPIC
"-I/usr/lib/perl5/5.8.7/i486-linux/CORE" -DHAVE_BLANK
-DHAVE_PCAP_LIB_VERSION Pcap.c
`-mcpu=' is deprecated. Use `-mtune=' or '-march=' instead.
In file included from Pcap.xs:43:
stubs.inc:85:2: warning: #warning "the function pcap_findalldevs() is
not available, but will be emulated"
In file included from Pcap.xs:43:
stubs.inc:91: error: redefinition of â&#128;&#152;struct
pcap_ifâ&#128;&#153;
stubs.inc:113:2: warning: #warning "the function pcap_breakloop() is
not available"
stubs.inc:127:2: warning: #warning "the function pcap_setnonblock() is
not available"
stubs.inc:142:2: warning: #warning "the function pcap_getnonblock() is
not available"
stubs.inc:157:2: warning: #warning "the function pcap_dump_file() is
not available"
stubs.inc:172:2: warning: #warning "the function pcap_dump_flush() is
not available"
stubs.inc:187:2: warning: #warning "the function pcap_list_datalinks()
is not available"
stubs.inc:202:2: warning: #warning "the function pcap_set_datalink()
is not available"
stubs.inc:217:2: warning: #warning "the function
pcap_datalink_name_to_val() is not available"
stubs.inc:232:2: warning: #warning "the function
pcap_datalink_val_to_name() is not available"
stubs.inc:247:2: warning: #warning "the function
pcap_datalink_val_to_description() is not available"
stubs.inc:262:2: warning: #warning "the function pcap_compile_nopcap()
is not available"
stubs.inc:267: error: conflicting types for
â&#128;&#152;pcap_compile_nopcapâ&#128;&#153;
/usr/include/pcap.h:245: error: previous declaration of
â&#128;&#152;pcap_compile_nopcapâ&#128;&#153; was here
stubs.inc:268: error: conflicting types for
â&#128;&#152;pcap_compile_nopcapâ&#128;&#153;
/usr/include/pcap.h:245: error: previous declaration of
â&#128;&#152;pcap_compile_nopcapâ&#128;&#153; was here
stubs.inc:277:2: warning: #warning "the function
pcap_get_selectable_fd() is not available"
stubs.inc:292:2: warning: #warning "the function pcap_next_ex() is not
available"
stubs.inc:307:2: warning: #warning "the function pcap_sendpacket() is
not available"
stubs.inc:322:2: warning: #warning "the function pcap_createsrcstr()
is not available"
stubs.inc:337:2: warning: #warning "the function pcap_parsesrcstr() is
not available"
stubs.inc:352:2: warning: #warning "the function pcap_open() is not
available"
stubs.inc:373:2: warning: #warning "the function pcap_setbuff() is not
available"
stubs.inc:388:2: warning: #warning "the function pcap_setuserbuffer()
is not available"
stubs.inc:403:2: warning: #warning "the function pcap_setmode() is not
available"
stubs.inc:418:2: warning: #warning "the function pcap_setmintocopy()
is not available"
stubs.inc:433:2: warning: #warning "the function
pcap_sendqueue_alloc() is not available"
stubs.inc:455:2: warning: #warning "the function
pcap_sendqueue_destroy() is not available"
stubs.inc:469:2: warning: #warning "the function
pcap_sendqueue_queue() is not available"
stubs.inc:484:2: warning: #warning "the function
pcap_sendqueue_transmit() is not available"
stubs.inc:499:2: warning: #warning "the function pcap_event() is not
available"
stubs.inc:514:2: warning: #warning "the function pcap_setsampling() is
not available"
Pcap.xs: In function â&#128;&#152;callback_wrapperâ&#128;&#153;:
Pcap.xs:57: warning: pointer targets in passing argument 1 of
â&#128;&#152;Perl_newSVpvâ&#128;&#153; differ in signedness
Pcap.xs: In function â&#128;&#152;XS_Net__Pcap_next_exâ&#128;&#153;:
Pcap.xs:494: warning: pointer targets in passing argument 2 of
â&#128;&#152;Perl_sv_setpvnâ&#128;&#153; differ in signedness
Pcap.xs: In function â&#128;&#152;XS_Net__Pcap_dumpâ&#128;&#153;:
Pcap.xs:553: warning: pointer targets in passing argument 3 of
â&#128;&#152;pcap_dumpâ&#128;&#153; differ in signedness
Pcap.c: In function â&#128;&#152;XS_Net__Pcap_dump_fileâ&#128;&#153;:
Pcap.c:1060: warning: passing argument 1 of
â&#128;&#152;Perl_newGVgenâ&#128;&#153;
discards qualifiers from pointer target type
Pcap.c:1062: warning: passing argument 2 of
â&#128;&#152;Perl_do_openâ&#128;&#153;
discards qualifiers from pointer target type
Pcap.c: In function â&#128;&#152;XS_Net__Pcap_strerrorâ&#128;&#153;:
Pcap.c:1348: warning: assignment discards qualifiers from pointer
target type
Pcap.c: In function â&#128;&#152;XS_Net__Pcap_fileâ&#128;&#153;:
Pcap.c:1390: warning: passing argument 1 of
â&#128;&#152;Perl_newGVgenâ&#128;&#153;
discards qualifiers from pointer target type
Pcap.c:1392: warning: passing argument 2 of
â&#128;&#152;Perl_do_openâ&#128;&#153;
discards qualifiers from pointer target type
Pcap.xs: In function â&#128;&#152;XS_Net__Pcap_sendpacketâ&#128;&#153;:
Pcap.xs:963: warning: pointer targets in passing argument 2 of
â&#128;&#152;pcap_sendpacketâ&#128;&#153; differ in signedness
Pcap.c: In function â&#128;&#152;boot_Net__Pcapâ&#128;&#153;:
Pcap.c:1996: warning: initialization discards qualifiers from pointer
target type
Pcap.c:1998: warning: assignment discards qualifiers from pointer
target type
Pcap.c:1998: warning: assignment discards qualifiers from pointer
target type
Pcap.c:2000: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2001: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2002: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2003: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2004: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2005: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2006: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2007: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2008: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2009: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2010: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2011: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2012: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2013: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2014: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2015: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2016: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2017: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2018: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2019: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2020: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2021: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2022: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2023: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2024: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2025: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2026: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2027: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2028: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2029: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2030: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2031: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2032: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2033: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2034: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2035: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2036: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2037: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2038: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2039: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2040: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2041: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2042: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2043: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2044: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2045: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2046: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2047: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2048: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2049: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2050: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2051: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2052: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
Pcap.c:2053: warning: passing argument 1 of
â&#128;&#152;Perl_newXSâ&#128;&#153; discards
qualifiers from pointer target type
make: *** [Pcap.o] Error 1

Any ideas?

#2061 From: ragus22
Date: Thu May 29, 2008 5:28 pm
Subject: Service enabling PERL and accessing it from a non-PERL client
ragus22
Offline Offline
 
Hi,
I am basically new to wbeservices using PERL. I have a perl script
that I need to service enable and this service nneeds to be called by
a non-PERL client.
Can someone please walk me through the steps. This is what I have
done so far.
1) Created a class called Demo(.pm) with two methods hello and bye.
---- Demo.pm ----
#! C:\Perl\bin\perl
package Demo;

sub hello {
shift;
$name = shift;
return "Hello there, $name";
}

sub bye {
shift;
$name = shift;
return "Goodbye, $name";
}

sub languages {
return ("Perl", "C", "sh");
}
1;
----

2) Created a SOAP server called TestDemo.cgi
**** TestDemo.cgi ****
#! C:\Perl\bin\perl

use SOAP::Transport::HTTP;
use Demo;

SOAP::Transport::HTTP::CGI
-> dispatch_to('Demo')
-> handle;

****
3) When I call this server using a PerlClient it works fine and
returns the "Hello <NAME>" statement.
******TestDemo.pl*****
    #!C:\Perl\bin

    use SOAP::Lite;

    # Instantiate a new SOAP::Lite object
    my $service = new SOAP::Lite
              ->uri('http://www.myurl.com/Demo')
              ->proxy('http://www.myurl.com/WS/TestDemo.cgi');

    # Remotely call the getTemp method
    $name = shift;

   my $result = $service->hello(SOAP::Data->type(string => $name));

   unless ($result->fault) {
     print $result->result();
  } else {
     print join ', ',
      $result->faultcode,
      $result->faultstring,
      $result->faultdetail;
   }
*********
>TestDemo.pl Joe
>Hello there, Joe
**
4) How to I call this service from a non-PERL(say Java) client.

#2062 From: srinivas reddy <reddysrinivas.k@...>
Date: Tue Oct 20, 2009 5:43 am
Subject: Adding legend in pie charts
reddysrinivas_k
Offline Offline
Send Email Send Email
 
Hi All,
Using GD::Graph::pie, I have created a pie chart. But, I am unable to add a
legend to the chart.
Is there any provision to add legend to a pie chart ?

~SrInIVaS ReDdy


[Non-text portions of this message have been removed]

Messages 2033 - 2062 of 2062   Oldest  |  < Older  |  Newer >  |  Newest
Advanced
Add to My Yahoo!      XML What's This?

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help