[29162] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 406 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 4 18:09:50 2007

Date: Fri, 4 May 2007 15:09:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 4 May 2007     Volume: 11 Number: 406

Today's topics:
        how does one use tuplespaces with perl? link.. <gavcomedy@gmail.com>
    Re: how does one use tuplespaces with perl? link.. <cwilbur@chromatico.net>
        Insert Multiple Lines after a Specified Line -- Please  annie.promthana@gmail.com
    Re: Insert Multiple Lines after a Specified Line -- Ple <someone@example.com>
    Re: Insert Multiple Lines after a Specified Line -- Ple <uri@stemsystems.com>
    Re: Perl code explaination help needed! <bik.mido@tiscalinet.it>
    Re: perl out of memory <bik.mido@tiscalinet.it>
    Re: perl out of memory xlue897@rogers.com
    Re: Populating an array from a mysql select <nikos1337@gmail.com>
    Re: Populating an array from a mysql select (Gary E. Ansok)
    Re: Populating an array from a mysql select <nikos1337@gmail.com>
    Re: Populating an array from a mysql select <nikos1337@gmail.com>
    Re: Populating an array from a mysql select <bik.mido@tiscalinet.it>
    Re: Populating an array from a mysql select <bik.mido@tiscalinet.it>
    Re: Populating an array from a mysql select <nikos1337@gmail.com>
    Re: Populating an array from a mysql select <bik.mido@tiscalinet.it>
    Re: Populating an array from a mysql select <nikos1337@gmail.com>
        Redirecting stdout without the use of IO::String <ilias@lazaridis.com>
    Re: Redirecting stdout without the use of IO::String <bik.mido@tiscalinet.it>
    Re: Redirecting stdout without the use of IO::String <someone@example.com>
    Re: Redirecting stdout without the use of IO::String <ilias@lazaridis.com>
    Re: Web Forms / Perl / SPAM detection <perl4hire@softouch.on.ca>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 4 May 2007 14:27:10 -0700
From: gavino <gavcomedy@gmail.com>
Subject: how does one use tuplespaces with perl? link..
Message-Id: <1178314030.232441.4910@u30g2000hsc.googlegroups.com>

http://www.jini.org/wiki/Main_Page



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

Date: 04 May 2007 17:43:00 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: how does one use tuplespaces with perl? link..
Message-Id: <87y7k4qn8b.fsf@mithril.chromatico.net>

>>>>> "g" == gavino  <gavcomedy@gmail.com> writes:

    g> http://www.jini.org/wiki/Main_Page 

One begins by trolling, apparently.

Charlton


--
Charlton Wilbur
cwilbur@chromatico.net


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

Date: 4 May 2007 13:05:16 -0700
From: annie.promthana@gmail.com
Subject: Insert Multiple Lines after a Specified Line -- Please Help!
Message-Id: <1178309116.841354.43440@p77g2000hsh.googlegroups.com>

I am new to PERL (mostly use UNIX Krn Shell) I am trying to automate
some file manipulation techniques.
I have figured out how to Delete and Append Lines in a file, but I
can't figure out how to insert in this partcular way.

I want to insert a few lines after a line that I specify.

For Example:
The file contains the following contents:
ABCDEFG
HIJKLMNO
PQRSTUV
WXYZ

As a driver file, I have created updates I want to make to my existing
file, where "IA" is the line I want to insert after, and "IL" are the
lines that need to be inserted. The two digit number just helps in
defining the group they belong to. (Maybe to help for looping?)

IA00:HIJKLMNO
IL00:12345
IL00:67890
IA01:PQRSTUV
IL01:24680
IL01:13579

The new file should result as:
ABCDEFG
HIJKLMNO
12345
67890
PQRSTUV
24680
13579
WXYZ

I am sure I am making the script more complicated as it is. For some
reason, I am confused with the variables and generating dynamic ones
to name the arrays. (That is if I split the file into parts).

	# IF THE INSTRUCTIONS ARE TO INSERT A LINE
	if ($update_line =~ /^I\w\d\d:/)
	{
		open (my $INPUT, "<$origfile") or die "$! error.";

		my $group;
		my $afterline;

		if ($line[0] =~ /^IA/) # if matched the first line to be changed
		{
			$group=substr($line[0], 2);
			$afterline=$line[1];

			open (my $update, "<$update_file") or die "$! error.";
			while ( <$update> )
			{
				my @insert_lines =( grep ("IL$group:", $line));
			}

			print "GROUP: $group";
			print "AFTER: $afterline";
			print "INSERT: \n @insert_lines";
			print "LINE: \n @line";

			close $update;

			print $insert_lines[1];

			open (my $OUTPUT, ">$baseline_dir/$dwmm_file.new") or die "$!
error.";

			  while (<$INPUT>) {
			    print $OUTPUT $_;
			    print $OUTPUT @line[1] if $_ =~ /$insert_lines[1]/;
			  }

			while( <$INPUT> )   # print the rest of the lines
			{
				print $OUTPUT $_;
			}

			close $OUTPUT;
       		}

		close $INPUT;
	}


I COULD EASILY DO THIS IN KRN SHELL, because of the lovely grep and
cat. All I do is cut up files.

 total_inserts=`cat $update_file | grep "^IA[0-9][0-9]" | cut -c 3-4 |
paste -s -d" " -`

        # Initialize the Counter
        for i in ${total_inserts}
        do
                # Get the total number of records in the Original File
                total_records=`cat $orig_file | wc -l`
                check_integer $total_records

                # Check that one value of line count is returned
                check_variable $total_records

                # Get the record that the file needs to be inserted
after
                insert_after=`cat $update_file | grep "^IA$i" | cut -
d":" -f2`
                # Check that there is a value in insert_after
                check_variable $insert_after
                check_record_exists "${insert_after}"

                # Find the line number of the record the file needs to
be inserted after
                head_records=`grep -n "^$insert_after" $orig_file |
tail -1 | cut -d":" -f1`

                # Check that there is a value in head records
                check_variable $head_records

                # Calculate the tail lines for splitting PART 2
                tail_records=`expr $total_records - $head_records`
                # Check that there is a value in tail records
                check_variable $tail_records

                # Concatenate PART1(First half of the file) to a file
                cat $orig_gile | head -"$head_records" > part-1-$i
                # Check that part1 exists

                # Concatenate PART2(the new inserts) to a file
                cat $update_file | grep "^IL$i" | cut -d":" -f2 >
part-2-$i
                # Check that part2 exists

                # Concatenate PART3(Bottom half of the file) to a file
                cat $orig_file | tail -"$tail_records" > part-3-$i
                # Check that part3 exists

                # Concatenate all of the files together (Top Half,
Inserts, Bottom Half)
                cat part-1-$i part-2-$i part-3-$i > final-$i.txt
                # Check that all parts exist, then check if final
exists

                # Work with the modified version of the dwmm file
                orig_file=final-$i.txt

        done


Any ideas would be appreciated. Maybe suggestions that my technique is
not right?



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

Date: Fri, 04 May 2007 20:31:20 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Insert Multiple Lines after a Specified Line -- Please Help!
Message-Id: <sKM_h.10827$KN6.92@edtnps89>

annie.promthana@gmail.com wrote:
> I am new to PERL (mostly use UNIX Krn Shell) I am trying to automate
> some file manipulation techniques.
> I have figured out how to Delete and Append Lines in a file, but I
> can't figure out how to insert in this partcular way.
> 
> I want to insert a few lines after a line that I specify.
> 
> For Example:
> The file contains the following contents:
> ABCDEFG
> HIJKLMNO
> PQRSTUV
> WXYZ
> 
> As a driver file, I have created updates I want to make to my existing
> file, where "IA" is the line I want to insert after, and "IL" are the
> lines that need to be inserted. The two digit number just helps in
> defining the group they belong to. (Maybe to help for looping?)
> 
> IA00:HIJKLMNO
> IL00:12345
> IL00:67890
> IA01:PQRSTUV
> IL01:24680
> IL01:13579
> 
> The new file should result as:
> ABCDEFG
> HIJKLMNO
> 12345
> 67890
> PQRSTUV
> 24680
> 13579
> WXYZ

$ echo "ABCDEFG
HIJKLMNO
PQRSTUV
WXYZ" | \
perl -pe'
    $_ .= "12345\n67890\n" if /^HIJKLMNO$/;
    $_ .= "24680\n13579\n" if /^PQRSTUV$/;
'
ABCDEFG
HIJKLMNO
12345
67890
PQRSTUV
24680
13579
WXYZ



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall


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

Date: Fri, 04 May 2007 16:32:42 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Insert Multiple Lines after a Specified Line -- Please Help!
Message-Id: <x78xc4ba8l.fsf@mail.sysarch.com>

>>>>> "ap" == annie promthana <annie.promthana@gmail.com> writes:

  ap> I am new to PERL (mostly use UNIX Krn Shell) I am trying to automate
  ap> some file manipulation techniques.
  ap> I have figured out how to Delete and Append Lines in a file, but I
  ap> can't figure out how to insert in this partcular way.

  ap> I want to insert a few lines after a line that I specify.

  ap> As a driver file, I have created updates I want to make to my existing
  ap> file, where "IA" is the line I want to insert after, and "IL" are the
  ap> lines that need to be inserted. The two digit number just helps in
  ap> defining the group they belong to. (Maybe to help for looping?)

  ap> IA00:HIJKLMNO
  ap> IL00:12345
  ap> IL00:67890
  ap> IA01:PQRSTUV
  ap> IL01:24680
  ap> IL01:13579

  ap> The new file should result as:
  ap> ABCDEFG
  ap> HIJKLMNO
  ap> 12345
  ap> 67890
  ap> PQRSTUV
  ap> 24680
  ap> 13579
  ap> WXYZ

either:

use Tie::File ;
tie @lines, 'Tie::File', $filename or die "can't tie::file  $file $!" ;

that will make your file look like a perl array and you can loop,
delete, splice in new lines with perl's normal array stuff. it would be
much easier than what you are doing now.

another approach is to slurp in the file into an array with:

use File::Slurp ;
my @lines = read_file( $filename ) ;

and then manipulate the array (same as with tie::file) and then write
out the modified array back to the file with:

write_file( $filename, @lines ) ;

either way is so much simpler than yours as you can use splice() to do
all the hard work. find the N lines to be inserted at one point and a
single splice() call will put them there. same for deletions. this
reduces your code to a simple parser of your change lines and a splice
calls for each set of related changes.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 04 May 2007 21:26:54 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Perl code explaination help needed!
Message-Id: <u62n3358e5320bsjgst32u3n4htks52djv@4ax.com>

On 4 May 2007 10:53:09 -0700, Brian McCauley <nobull67@gmail.com>
wrote:

>>       my ($new=$_) =~ s/C$/cc/;
>
>You mean
>
>      (my $new=$_) =~ s/C$/cc/;

And what did I write? (... /me rereads better...) Yep, that's what I
meant.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Fri, 04 May 2007 21:25:02 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: perl out of memory
Message-Id: <jh1n335mb75te2lud64flmm05ts8fs2a18@4ax.com>

On 4 May 2007 10:33:26 -0700, xlue897@rogers.com wrote:

>> ATM! :-)
>>
>> Michele
>> --
>> {$_=3Dpack'B8'x25,unpack'A8'x32,$a^=3Dsub{pop^pop}->(map substr

What's with quoting the .sig? (If not discussing it, that is. But this
is generally the case with Abigail's!)

>Thanks everyone for your help.  The while loop works.  However,  the
>perl code seems much slower than awk code.  For the same file size
>around 5M records, the awk takes only 1 min to loop to find the max
>value, the perl takes around 20 mins.  Does perl slower than awk?

Hard to say, without seeing any code. Find it hard to believe, though:

  cognac:~ [21:23:58]$ perl -le 'print rand for 1..5_000_000' > test
  cognac:~ [21:24:19]$ time perl -ne '$m=$_>$m?$_:$m;END{print $m}'
test
  0.999999995290754
  
  real    0m8.604s
  user    0m7.160s
  sys     0m1.368s


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 4 May 2007 13:33:34 -0700
From: xlue897@rogers.com
Subject: Re: perl out of memory
Message-Id: <1178310814.278227.280360@y5g2000hsa.googlegroups.com>

On May 4, 3:25 pm, Michele Dondi <bik.m...@tiscalinet.it> wrote:
> On 4 May 2007 10:33:26 -0700, xlue...@rogers.com wrote:
>
> >> ATM! :-)
>
> >> Michele
> >> --
> >> {$_=3Dpack'B8'x25,unpack'A8'x32,$a^=3Dsub{pop^pop}->(map substr
>
> What's with quoting the .sig? (If not discussing it, that is. But this
> is generally the case with Abigail's!)
>
> >Thanks everyone for your help.  The while loop works.  However,  the
> >perl code seems much slower than awk code.  For the same file size
> >around 5M records, the awk takes only 1 min to loop to find the max
> >value, the perl takes around 20 mins.  Does perl slower than awk?
>
> Hard to say, without seeing any code. Find it hard to believe, though:
>
>   cognac:~ [21:23:58]$ perl -le 'print rand for 1..5_000_000' > test
>   cognac:~ [21:24:19]$ time perl -ne '$m=$_>$m?$_:$m;END{print $m}'
> test
>   0.999999995290754
>
>   real    0m8.604s
>   user    0m7.160s
>   sys     0m1.368s
>
> Michele
> --
> {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
> (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
> .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
> 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,

Here is the test code with result. test file generated by (perl -le
'print rand for 1..5_000_000' > test.txt)
$time awk -F'.' '{ if($2 > max) {max = $2;} } END{print max;}'
<test.txt
999969482421875

real    0m18.16s
user    0m17.38s
sys     0m0.18s

$time perl  -a -F'\.' -n -e '{ if($F[1] >$max) {$max=$F[1];} }
END{print $max;}'  test.txt
999969482421875

real    0m41.57s
user    0m41.14s
sys     0m0.16s


BTW, why the code below doesn't work?
perl -a -F/\./ -n -e '{print $F[1], "\n";} ' test.txt


Thanks,
Steven



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

Date: 4 May 2007 12:06:09 -0700
From: Nikos <nikos1337@gmail.com>
Subject: Re: Populating an array from a mysql select
Message-Id: <1178305569.317686.113250@y80g2000hsf.googlegroups.com>

On May 4, 6:58 pm, "Mumia W." <paduille.4061.mumia.w
+nos...@earthlink.net> wrote:
> On 05/04/2007 10:24 AM, Nikos wrote:> $select =3D $db->prepare( "SELECT u=
sername FROM users" );
> > $select->execute;
> > my @userlist =3D $select->fetchrow_array;
>
>                            ^^^^^^^^^^^^^^
>
>
>
> > print start_form( action=3D>'/cgi-bin/index.pl' );
> >     print h1( {class=3D>'lime'},  "=C5=F0=DD=EB=E5=EE=E5 =F4=EF =EA=E5=
=DF=EC=E5=ED=EF =F0=EF=F5 =F3=E5 =E5=ED=E4=E9=E1=F6=DD=F1=E5=E9
> > =3D> ",
> >                                 popup_menu( -name=3D>'select', -values=
=3D>
> > \@userlist ),
> >                                 submit('=C5=EC=F6=DC=ED=E9=F3=E7'));
> > print end_form;
>
> > In the above code insteaf od the array filling by all usernmes
> > selected from the dataabse it only populates the 1st one.
>
> > I want all users to be listed on the pop up menu.
>
> Fetchrow_array only gets a single row at a time. Perhaps you want
> something like this (untested):
>
> my @userlist =3D map $_->[0], @{$select->fetchall_arrayref};

Thank you this worked actually:

$select =3D $db->prepare( "SELECT username FROM users" );
$select->execute;
my @userlist =3D map {$_->[0]} @{$select->fetchall_arrayref};

but this didnt which seems simpler as another OP suggested
unfortunately:

my $userlist =3D $db->selectcol_arrayref("SELECT username FROM users");

returns ARRAY(0x11101)blabla instead of the real valeus why?




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

Date: Fri, 4 May 2007 19:15:32 +0000 (UTC)
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: Populating an array from a mysql select
Message-Id: <f1g0oj$82c$1@naig.caltech.edu>

In article <1178305569.317686.113250@y80g2000hsf.googlegroups.com>,
Nikos  <nikos1337@gmail.com> wrote:
>my @userlist = map {$_->[0]} @{$select->fetchall_arrayref};
>
>but this didnt which seems simpler as another OP suggested
>unfortunately:
>
>my $userlist = $db->selectcol_arrayref("SELECT username FROM users");
>
>returns ARRAY(0x11101)blabla instead of the real valeus why?

Because it returns an array reference (as indicated by its name).

To get to the real values you can use @$userlist (where you now
use @userlist) or $userlist->[0] (where you now use $userlist[0]).

Or, if you want to keep the rest of your code unchanged,

my $userlist_ref = $db->selectcol_arrayref("SELECT username FROM users");
my @userlist = @$userlist_ref;

Gary


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

Date: 4 May 2007 12:16:19 -0700
From: Nikos <nikos1337@gmail.com>
Subject: Re: Populating an array from a mysql select
Message-Id: <1178306179.376266.13540@u30g2000hsc.googlegroups.com>

Also this:

my @titlelist;
open FILE, "<$ENV{'DOCUMENT_ROOT'}/data/vault/titlelist.txt" or die
$!;
     @titlelist =3D <FILE>;
close FILE;

print br() x 3;
print start_form( action=3D>'/cgi-bin/admin.pl' );
  print table( {class=3D>'user_form'},
     Tr( td(  '=D0=DD=F2 =EC=EF=F5 =F4=E9 =E8=E1 =DE=E8=E5=EB=E5=F2:'      =
             ),
td( popup_menu( -name=3D>'title' -values=3D>\@titlelist ))),
     Tr( td(  '=CA=DC=F4=E9 =DC=EB=EB=EF =F0=EF=F5 =E8=E1 =DE=E8=E5=EB=E5=
=F2 =ED=E1 =F3=F7=EF=EB=E9=DC=F3=E5=E9=F2?'  ),
td( textarea( -name=3D>'remark', -rows=3D>4, -columns=3D>25 ))),
     Tr( td(  '=D4=EF =F4=E7=EB=DD=F6=F9=ED=EF =E5=F0=E9=EA=EF=E9=ED=F9=ED=
=DF=E1=F2 =F3=EF=F5 =E3=E9=E1 =E5=F0=E9=E2=E5=E2=E1=DF=F9=F3=E7
=E5=DF=ED=E1=E9:'  ),  td( textfield( -name=3D>'phone' ))),

     Tr( td(  a( {href=3D>'/cgi-bin/show.pl?name=3Dshowbook'},
font( {size=3D>3, color=3D>'yellow'},  '=C5=EC=F6=DC=ED=E9=F3=E7!' ))),
     	 td(  submit( '=C1=F0=EF=F3=F4=EF=EB=DE!' )))
  );


      print hidden(-name=3D>'date',  -value=3D>$date);
      print hidden(-name=3D>'host',  -value=3D>$host);
print end_form();

Although @titlelist is filled with all entries from titlelist.txt
file(one entry per line), when it gets printed  with popup_menu  it
displays nothing at all!!



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

Date: 4 May 2007 12:21:36 -0700
From: Nikos <nikos1337@gmail.com>
Subject: Re: Populating an array from a mysql select
Message-Id: <1178306496.077179.193050@c35g2000hsg.googlegroups.com>

On May 4, 10:15 pm, a...@alumni.caltech.edu (Gary E. Ansok) wrote:
> In article <1178305569.317686.113...@y80g2000hsf.googlegroups.com>,
>
> Nikos  <nikos1...@gmail.com> wrote:
> >my @userlist = map {$_->[0]} @{$select->fetchall_arrayref};
>
> >but this didnt which seems simpler as another OP suggested
> >unfortunately:
>
> >my $userlist = $db->selectcol_arrayref("SELECT username FROM users");
>
> >returns ARRAY(0x11101)blabla instead of the real valeus why?
>
> Because it returns an array reference (as indicated by its name).
>
> To get to the real values you can use @$userlist (where you now
> use @userlist) or $userlist->[0] (where you now use $userlist[0]).
>
> Or, if you want to keep the rest of your code unchanged,
>
> my $userlist_ref = $db->selectcol_arrayref("SELECT username FROM users");
> my @userlist = @$userlist_ref;
>
> Gary

Thanks Garry!

An array reference is actually a pointer(as we would have said in C++)
that points to the starting memoery location of the array?!



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

Date: Fri, 04 May 2007 21:42:46 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Populating an array from a mysql select
Message-Id: <143n339uum3pan74hn36onmugt9jnct0jg@4ax.com>

On Fri, 4 May 2007 19:15:32 +0000 (UTC), ansok@alumni.caltech.edu
(Gary E. Ansok) wrote:

>my $userlist_ref = $db->selectcol_arrayref("SELECT username FROM users");
>my @userlist = @$userlist_ref;

Without creating an intermediate variable:

  my @userlist = @{ $db->selectcol_arrayref("SELECT username FROM
users") };


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Fri, 04 May 2007 21:43:48 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Populating an array from a mysql select
Message-Id: <763n3352bne45bnv25docl93f7k3qq8b5h@4ax.com>

On 4 May 2007 12:21:36 -0700, Nikos <nikos1337@gmail.com> wrote:

>An array reference is actually a pointer(as we would have said in C++)
>that points to the starting memoery location of the array?!

Not really. But that is an analogy that may help you to understand.
For more info refer to

  perldoc perlref


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 4 May 2007 12:59:44 -0700
From: Nikos <nikos1337@gmail.com>
Subject: Re: Populating an array from a mysql select
Message-Id: <1178308784.821108.24660@p77g2000hsh.googlegroups.com>

On May 4, 10:43 pm, Michele Dondi <bik.m...@tiscalinet.it> wrote:
> On 4 May 2007 12:21:36 -0700, Nikos <nikos1...@gmail.com> wrote:
>
> >An array reference is actually a pointer(as we would have said in C++)
> >that points to the starting memoery location of the array?!
>
> Not really. But that is an analogy that may help you to understand.
> For more info refer to

Thank you, so now i know that my visualization analogy is not
erroneous.

Can you please help me with the other questions regarding @titlelist
that is not ebing displayed?



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

Date: Fri, 04 May 2007 22:33:58 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Populating an array from a mysql select
Message-Id: <626n33hdelomdamsuo2tbm816i238rgmms@4ax.com>

On 4 May 2007 12:59:44 -0700, Nikos <nikos1337@gmail.com> wrote:

>> Not really. But that is an analogy that may help you to understand.
>> For more info refer to
>
>Thank you, so now i know that my visualization analogy is not
>erroneous.
>
>Can you please help me with the other questions regarding @titlelist
>that is not ebing displayed?

Nope, I saw that post, but I have a hard time only looking at it,
without even trying to read it accurately. And it's by far *not* my
area of expertise, anyway. Now, do I have an area of expertise at all?


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 4 May 2007 13:47:01 -0700
From: Nikos <nikos1337@gmail.com>
Subject: Re: Populating an array from a mysql select
Message-Id: <1178311621.205992.174050@p77g2000hsh.googlegroups.com>

ill ry to make it simpler then:

my @titlelist;
open FILE, "<$ENV{'DOCUMENT_ROOT'}/data/vault/titlelist.txt" or die
$!;
     @titlelist = <FILE>;
close FILE;

i try to print popup_menu( -name=>'title' -values=>\@titlelist ) but
it return nothing.

if i try to print @titlelist is filled though...



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

Date: 4 May 2007 12:59:28 -0700
From: Ilias Lazaridis <ilias@lazaridis.com>
Subject: Redirecting stdout without the use of IO::String
Message-Id: <1178308767.975694.114770@u30g2000hsc.googlegroups.com>

I use the following code to redirect the stdout to a variable, which I
send then via email.

    my $failure;
    my $messages;
    if ($notify_to_email) {

        $self->output($messages); # currently not used

        my $handle = IO::String->new($messages);
        my $handle_old = select($handle);       # redirect STDOUT

        $failure = $self->check_tree($self);    # prints to STDOUT,
either screen or $messages

        select($handle_old) if defined $handle_old; # restore STDOUT
    }else {
        $failure = $self->check_tree($self);
    }

    $self->notify($failure, $notify_to_email, "", $messages);

The code depends on IO::String.

Can I achieve the above without the use of IO::String (and without
changing the programm structure much)?

 .

--
http://lazaridis.com



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

Date: Fri, 04 May 2007 22:09:18 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Redirecting stdout without the use of IO::String
Message-Id: <ej4n33hu1tllkot0v2ro14rt4rlcclce1n@4ax.com>

On 4 May 2007 12:59:28 -0700, Ilias Lazaridis <ilias@lazaridis.com>
wrote:

>I use the following code to redirect the stdout to a variable, which I
>send then via email.
[...]
>Can I achieve the above without the use of IO::String (and without
>changing the programm structure much)?

I didn't know about IO::String. Perl has been able to open() in memory
files for a while.

  open my $fh, '>', \(my $string) or die "D'Oh! $!\n";

should do the job.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Fri, 04 May 2007 20:23:59 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Redirecting stdout without the use of IO::String
Message-Id: <zDM_h.10824$KN6.8698@edtnps89>

Ilias Lazaridis wrote:
> I use the following code to redirect the stdout to a variable, which I
> send then via email.
> 
>     my $failure;
>     my $messages;
>     if ($notify_to_email) {
> 
>         $self->output($messages); # currently not used
> 
>         my $handle = IO::String->new($messages);
>         my $handle_old = select($handle);       # redirect STDOUT

select() doesn't "redirect STDOUT", it changes the default output for print()
if no filehandle is used.


>         $failure = $self->check_tree($self);    # prints to STDOUT,
> either screen or $messages
> 
>         select($handle_old) if defined $handle_old; # restore STDOUT
>     }else {
>         $failure = $self->check_tree($self);
>     }
> 
>     $self->notify($failure, $notify_to_email, "", $messages);
> 
> The code depends on IO::String.
> 
> Can I achieve the above without the use of IO::String (and without
> changing the programm structure much)?


    my $failure;
    my $messages;
    if ( $notify_to_email ) {

        $self->output( $messages );

        open my $handle, '>', \$messages or die "Cannot open \$messages: $!";
        my $handle_old = select $handle;

        $failure = $self->check_tree( $self );

        select $handle_old if fileno $handle_old;
    } else {
        $failure = $self->check_tree( $self );
    }

    $self->notify( $failure, $notify_to_email, '', $messages );




John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall


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

Date: 4 May 2007 14:00:41 -0700
From: Ilias Lazaridis <ilias@lazaridis.com>
Subject: Re: Redirecting stdout without the use of IO::String
Message-Id: <1178312441.735753.125680@c35g2000hsg.googlegroups.com>

On May 4, 11:23 pm, "John W. Krahn" <some...@example.com> wrote:
> Ilias Lazaridis wrote:
> > I use the following code to redirect the stdout to a variable, which I
> > send then via email.
[...]

> >         my $handle_old = select($handle);       # redirect STDOUT
>
> select() doesn't "redirect STDOUT", it changes the default output for print()
> if no filehandle is used.

ok

[...]
> > Can I achieve the above without the use of IO::String (and without
> > changing the programm structure much)?
>
>     my $failure;
>     my $messages;
>     if ( $notify_to_email ) {
>
>         $self->output( $messages );
>
>         open my $handle, '>', \$messages or die "Cannot open \$messages: $!";
>         my $handle_old = select $handle;
>
>         $failure = $self->check_tree( $self );
>
>         select $handle_old if fileno $handle_old;
>     } else {
>         $failure = $self->check_tree( $self );
>     }
>
>     $self->notify( $failure, $notify_to_email, '', $messages );

The code works fine.

Thanks a lot.

 .

--
http://lazaridis.com



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

Date: Fri, 04 May 2007 14:41:08 -0400
From: Amer Neely <perl4hire@softouch.on.ca>
Subject: Re: Web Forms / Perl / SPAM detection
Message-Id: <Q4L_h.9515$WE.1575@read1.cgocable.net>

> Date: Thurs, May 3 2007 1:40 pm 
> From: - Bob -  
> I have some web forms that are getting hit by spammers sending spam
> into the system. They are simple forms, add your name, address, etc.
> Perl code handles the form, of course! 
> 
> I'd like to cut down on the spammers. I was thinking that perhaps I
> could check the person's IP against blacklists... but most of the
> blacklists I know of are mail servers, so I am not sure that is
> practical. I am hoping to avoid the "enter this displayed secret code"
> mechanism as an annoyance for legit users. But, I am open to
> suggestions on existing Perl based solutions (trails blazed before
> me!) or just pointers to good resources on programmable solutions to
> this issue. 

I am working with a client right now with exactly this problem. I am 
going the 'CAPTCHA' route first, as that is the least amount of work 
involved I think. But, I've read that some spam-bots now have OCR 
technology built in, so the images will have to get weirder and better 
processed.

I don't think blocking IP addresses will work very well, as a lot of 
spam is sent from legitimate users who have been compromised into 
relaying spam.

-- 
Amer Neely
w: www.softouch.on.ca/
Perl | MySQL programming for all data entry forms.
"We make web sites work!"


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 406
**************************************


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