Re: Script to prepend text to beginning of file

2011-01-21 Thread Brian Fraser
> > use strict; > use warnings; > use Tie::File; > > my @array; > tie @array, 'Tie::File', FILENAME or die "Couldn't open file: $!" > > unshift @array, <<'END_PREPEND'; > ENTHDR|1|3.0 > STAGEHDR|Barcoded > END_PREPEND > Haven't tested it, but it should work. http://perldoc.perl.org/Tie/File.html

Re: Capture nth element of a file

2011-01-21 Thread jet speed
On Fri, Jan 21, 2011 at 5:35 PM, jet speed wrote: > > > On Fri, Jan 21, 2011 at 5:18 PM, Jim Gibson wrote: > >> On 1/21/11 Fri Jan 21, 2011 8:43 AM, "jet speed" >> scribbled: >> >> > Hi All, >> > I need some help with the blow. >> > >> > I have a an input file with the below data >> > >> > 18

Re: Capture nth element of a file

2011-01-21 Thread Jim Gibson
On 1/21/11 Fri Jan 21, 2011 8:43 AM, "jet speed" scribbled: > Hi All, > I need some help with the blow. > > I have a an input file with the below data > > 1835 > 1836 > 1837 > 1838 > 1839 > 183A > 183B > 183C > 183D > > > #!/usr/bin/perl > use strict; > use warnings; > > my $filename; > $f

Lighttpd + FCGI = Socket not closing?

2011-01-21 Thread perl-list
Hi there, I'm using the FCGI module (version 0.67) and a lighttpd to create an imageserver. But currently I have the problem that if I shutdown the lighttpd server, the perl processes are still there with an open file descriptor to the socket. There are not a child process anymore and are o

Re: Capture nth element of a file

2011-01-21 Thread Rob Coops
On Fri, Jan 21, 2011 at 5:57 PM, Rob Coops wrote: > > > On Fri, Jan 21, 2011 at 5:43 PM, jet speed wrote: > >> Hi All, >> I need some help with the blow. >> >> I have a an input file with the below data >> >> 1835 >> 1836 >> 1837 >> 1838 >> 1839 >> 183A >> 183B >> 183C >> 183D >> >> >> #!/usr/bin

Re: Capture nth element of a file

2011-01-21 Thread Rob Coops
On Fri, Jan 21, 2011 at 5:43 PM, jet speed wrote: > Hi All, > I need some help with the blow. > > I have a an input file with the below data > > 1835 > 1836 > 1837 > 1838 > 1839 > 183A > 183B > 183C > 183D > > > #!/usr/bin/perl > use strict; > use warnings; > > my $filename; > $filename = "input.

Re: Capture nth element of a file

2011-01-21 Thread jbiskofski
sorry! $line_count at the end of the while block should be $line_count++ On Fri, Jan 21, 2011 at 10:54 AM, jbiskofski wrote: > my $line_count = 1; > my @captured_elements; > > open(FILE, $filename) || die 'cant open file'; > while () { > chomp; > push(@captured_elements, $_) unless ($li

Re: Capture nth element of a file

2011-01-21 Thread jbiskofski
my $line_count = 1; my @captured_elements; open(FILE, $filename) || die 'cant open file'; while () { chomp; push(@captured_elements, $_) unless ($line_count % 4); $line_count; } close(FILE); --- % is the modulus operator, it returns the remainder of a division so ... 6 % 4 = 2, 7

Capture nth element of a file

2011-01-21 Thread jet speed
Hi All, I need some help with the blow. I have a an input file with the below data 1835 1836 1837 1838 1839 183A 183B 183C 183D #!/usr/bin/perl use strict; use warnings; my $filename; $filename = "input.txt" ; open (FILE, "< $filename" ) or die "Could not open $filename: $!"; while () { chomp

Re: Script to prepend text to beginning of file

2011-01-21 Thread Shlomi Fish
Hi Ary, On Friday 21 Jan 2011 17:39:48 Ary Kleinerman wrote: > Shlomi, > > On Fri, Jan 21, 2011 at 12:13 PM, Shlomi Fish wrote: > > Hi Ary, > > > > On Friday 21 Jan 2011 16:01:36 Ary Kleinerman wrote: > > > A simple way: > > > > > > #!/usr/bin/perl -w > > > open FILE, ">>file.txt"; > > > print

Re: SDL beginner question

2011-01-21 Thread Sheppy R
I would recommend using the IRC chat or SDL mailing list found here: http://sdl.perl.org/index.html At least one of the members that is working on the development side is coding on a Mac as well (Unfortunately I don't remember the name). kthakore is generally in the IRC channel most of the time a

Re: Script to prepend text to beginning of file

2011-01-21 Thread Ary Kleinerman
Shlomi, On Fri, Jan 21, 2011 at 12:13 PM, Shlomi Fish wrote: > Hi Ary, > > On Friday 21 Jan 2011 16:01:36 Ary Kleinerman wrote: > > A simple way: > > > > #!/usr/bin/perl -w > > open FILE, ">>file.txt"; > > print FILE "line1\n"; > > print FILE "line2\n"; > > print FILE "ENTHDR|1|3.0\n"; > > print

Re: SDL beginner question

2011-01-21 Thread Shlomi Fish
Hi Francesco, On Friday 21 Jan 2011 16:20:51 Francesco Di Lorenzo wrote: > Hi everyone, > I've just finished reading Learning Perl by O'Really and I want to learn > something that can give me something more pleasant to work on, something > funny, I want to program some basic games like pong... > F

Re: Script to prepend text to beginning of file

2011-01-21 Thread Shlomi Fish
Hi Ary, On Friday 21 Jan 2011 16:01:36 Ary Kleinerman wrote: > A simple way: > > #!/usr/bin/perl -w > open FILE, ">>file.txt"; > print FILE "line1\n"; > print FILE "line2\n"; > print FILE "ENTHDR|1|3.0\n"; > print FILE "STAGEHDR|Barcoded\n"; > close FILE; > This script will *append* 4 lines to

Re: Help with script How to prepend 2 lines instead of 1

2011-01-21 Thread Rob Dixon
On 20/01/2011 19:10, steve1040 wrote: Using the script below I need to add a second line with the following text: "STAGEHDR|Barcoded" #!perl use strict; use warnings; my $file = 'path/to/Access.csv'; my $newline = "ENTHDR|1|3.0"; { local @ARGV = ($file); local $^I = '.bac'; while(<>

Re: Reading a value from a hash using a variable for the key

2011-01-21 Thread Rob Dixon
On 21/01/2011 05:50, Erez Schatz wrote: On 20 January 2011 15:38, Eyal B. wrote: I'm getting an error on the line where I should use the TTL variable - and take the right value from the hash (%list) :Use of uninitialized value in print at D:\system\perl\os-rec\os-rec5_.pl line 24 , line 3. A

SDL beginner question

2011-01-21 Thread Francesco Di Lorenzo
Hi everyone, I've just finished reading Learning Perl by O'Really and I want to learn something that can give me something more pleasant to work on, something funny, I want to program some basic games like pong... For this I've found a book that introduces SDL, but I don't know how to install all t

Re: Lines per page $= varible

2011-01-21 Thread Shlomi Fish
On Thursday 20 Jan 2011 19:40:55 Chris Stinemetz wrote: > I am having difficulty using $= correctly to change the number of lines per > page. I would like to set it to 600 but can't seem to get $= =600 to work > correctly. > In addition to what C. DeRykus said, I should note that the book Perl Be

Re: Help with script How to prepend 2 lines instead of 1

2011-01-21 Thread Shlomi Fish
Hi Steve, On Thursday 20 Jan 2011 21:10:39 steve1040 wrote: > Using the script below I need to add a second line with the following > text: > "STAGEHDR|Barcoded" > > #!perl > use strict; > use warnings; > my $file = 'path/to/Access.csv'; > my $newline = "ENTHDR|1|3.0"; > { >local @ARGV = ($fi

Re: Script to prepend text to beginning of file

2011-01-21 Thread Shlomi Fish
Hi Steve, On Thursday 20 Jan 2011 20:57:50 steve1040 wrote: > I need to add 2 lines to a file and add the following text. > > ENTHDR|1|3.0 > STAGEHDR|Barcoded > > I don't have any idea how to do this in Perl > In UNIX and UNIX-like systems (including Windows), it is useful to think of a file

Re: Script to prepend text to beginning of file

2011-01-21 Thread Ary Kleinerman
A simple way: #!/usr/bin/perl -w open FILE, ">>file.txt"; print FILE "line1\n"; print FILE "line2\n"; print FILE "ENTHDR|1|3.0\n"; print FILE "STAGEHDR|Barcoded\n"; close FILE; On Thu, Jan 20, 2011 at 3:57 PM, steve1040 wrote: > I need to add 2 lines to a file and add the following text. > > E

Dereference Links

2011-01-21 Thread Mike Flannigan
I'm trying to dereference the @{$links} produced by WWW::SimpleRobot and am having a heck of a time getting it done. Can anybody help? You can see some of the things I have tried below. I know I can do this link extraction myself with LinkExtor, or at least think I can do it, but I'd like to kn

Re: Reading a value from a hash using a variable for the key

2011-01-21 Thread Eyal B.
On Jan 21, 7:50 am, moonb...@gmail.com (Erez Schatz) wrote: > On 20 January 2011 15:38, Eyal B. wrote: > > > > > I'm writing a scripts that check the TTL of the ping and found the OS. > > According the TTL - the script should let me know which OS it is : > > Linux/ Windows or Unix (Hash table) > >

Help with script How to prepend 2 lines instead of 1

2011-01-21 Thread steve1040
Using the script below I need to add a second line with the following text: "STAGEHDR|Barcoded" #!perl use strict; use warnings; my $file = 'path/to/Access.csv'; my $newline = "ENTHDR|1|3.0"; { local @ARGV = ($file); local $^I = '.bac'; while(<>){ if ($. == 1) { print "$new

Re: Reading a value from a hash using a variable for the key

2011-01-21 Thread Eyal B.
Tried to implement your recommendations step by step . #! C:\Perl\bin\perl use strict; use warnings; my %list = (60=>"linux",61=>"linux",62=>"linux",63=>"linux", 64=>"linux",65=>"linux",125=>"Windows",126=>"Windows",127=>"Windows", 128=>"Windows",250=>"Unix",251=>"Unix",252=>"Unix",253=>

Script to prepend text to beginning of file

2011-01-21 Thread steve1040
I need to add 2 lines to a file and add the following text. ENTHDR|1|3.0 STAGEHDR|Barcoded I don't have any idea how to do this in Perl Thanks Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Reading a value from a hash using a variable for the key

2011-01-21 Thread Shlomi Fish
Hi Eyal, I should note that your plain text message is mal-formatted. It's not clear which parts were said by me, and which parts were said by you. Next time, please configure your mailer (GMail.com?) to format the message as plaintext and to use proper "> " quoting as needed by netiquette rule