Re: parsing Makefiles

2004-02-21 Thread Andrew Gaffney
David le Blanc wrote: I've come up with some *simple* code that seems to work: #!/usr/bin/perl use strict; use warnings; $| = 1; my $total = `make -n | wc -l`; my ($count, $line); open MAKE, "make |"; foreach $line () { $count++; my $percent = int(($count / $total) * 100); print "..$percent

Re: Newbie that needs some help

2004-02-21 Thread Owen
On Sat, 21 Feb 2004 21:23:13 -0600 Perl Mail User <[EMAIL PROTECTED]> wrote: > Hello All, > > I have a basic question, I am new to perl, and I would like to try > and get a basic question answered, if possible. I have a file with > about 63 lines in it, I am running it through a basic perl pro

Re: Newbie that needs some help

2004-02-21 Thread WilliamGunther
I would probably write it like this (Although, I'm not sure what that :58 is about): open(FILE, "file1.txt") or die "Can not open file. ", $!, "\n"; @lines = grep { /:58/ } ; So you can understand and learn, let me just tell you you're mistakes. open(FILE, "file1.txt") or die "Can not open fil

Newbie that needs some help

2004-02-21 Thread Perl Mail User
Hello All, I have a basic question, I am new to perl, and I would like to try and get a basic question answered, if possible. I have a file with about 63 lines in it, I am running it through a basic perl program that reads every line and prints it to the screen. I am trying to get the output

RE: parsing Makefiles

2004-02-21 Thread David le Blanc
> I've come up with some *simple* code that seems to work: > > #!/usr/bin/perl > > use strict; > use warnings; > > $| = 1; > my $total = `make -n | wc -l`; > my ($count, $line); > open MAKE, "make |"; > foreach $line () { >$count++; >my $percent = int(($count / $total) * 100); >prin

Reg. Net::Pcap

2004-02-21 Thread Balaji Thoguluva
Hi, I would like to know if there is a way to get packets from already saved tcpdump output file (tcpdump -w DumpFile.dmp) using Net::Pcap library and thus parse each packet. I know that there is a function Net::Pcap::open_offline() that takes a savefile as input. But the savefile

Re: reading shell variables [Was all confused about a hash]

2004-02-21 Thread Kenton Brede
On Sun, Feb 22, 2004 at 12:30:14AM +, RichT ([EMAIL PROTECTED]) wrote: > My next question is, how can i read in variables from the shell? > > im using Solaris / ksh You can access environment variables though the %ENV hash. I've listed a couple standard ways to do so below. If you are c

reading shell variables [Was all confused about a hash]

2004-02-21 Thread RichT
> >>Use of uninitialized value at ./poller.cfg.search.pl line 22, chunk 5. >> which is happening on the last line of each section which is "[TAB] } \n" or after >> i have " s/["}{]//g; " i guess it would be "[TAB] /n" >>how can ignore this last line? Ok i figgered it out... the problem was th

Re: all confused about a hash

2004-02-21 Thread RichT
At 20:34 21/02/2004, you wrote: >At 14:01 21/02/2004, you wrote: > >>Hi. > >Hello again and thank you > >>I recently questioned whether a rewrite was an appropriate response >>to a question on this group. Now I'm going to do it anyway! > >after seeing you code i have cleaned up mine, >amassing how

Re: Checking about gif

2004-02-21 Thread R. Joseph Newton
John wrote: > I want to test if a file is a gif image or not. print "filename to check: "; my $filename = ; chomp $filename; open IN, $filename or die "Could not open file to check specs: $!"; binmode IN; my $gif_label; read (IN, $gif_label, 6); chomp $gif_label; if ($gif_label =~ /^GIF8[79]a/) {

Re: question plz

2004-02-21 Thread R. Joseph Newton
Jacob Chapa wrote: > what is the difference between > > -> That is the Perl dereferencing operator. You use it to access hash or array elements, or package [class] methods, from a reference. my $keywords_ref = {}; $keywords_ref->{Animal} = 'Movement'; $keywords_ref->{Vegetable} = 'Photosynthe

Re: question plz

2004-02-21 Thread R. Joseph Newton
[EMAIL PROTECTED] wrote: > They're different operators. => is the same thing as the comma. It's sole > difference is readability. For example I agree, I guess, but I'm not sure that amount of detail is helpful at the level of distinction sought in the OP. It might be better to stick to common u

Re: lc

2004-02-21 Thread Stuart White
Thanks everyone. I feel sortof like a dope since I knew that to save the results of a function, I'd have to save it in a variable. I just forgot in the excitement of trying to use all the functions in the same line. Someone, I believe Jenda, brought up that the "useless use of lc" was a warning,

Re: all confused about a hash

2004-02-21 Thread R. Joseph Newton
[EMAIL PROTECTED] wrote: > Hi all, > > I am searching through a large data file and pulling out the data for > elements that match the IP address... > this is at least half working well up to " #just for testing 1" > but not after " #just for testing 2", hash %seg

Re: lc

2004-02-21 Thread R. Joseph Newton
Stuart White wrote: > I want to take input from and then convert it > to lowercase. so I tried this: > > lc(chomp($input = ))); Two things here: 1. It is pointless to lc a numerical value, and the boolean value [1 if a newline was removed, 0 otherwise] returned from chomp will always be expre

Re: all confused about a hash

2004-02-21 Thread RichT
At 14:01 21/02/2004, you wrote: >Hi. Hello again and thank you >I recently questioned whether a rewrite was an appropriate response >to a question on this group. Now I'm going to do it anyway! after seeing you code i have cleaned up mine, amassing how much eazy'er it make it to read. >First

Re: Checking about gif

2004-02-21 Thread Rob Dixon
John wrote: > > I want to test if a file is a gif image or not. > > Is it practicable using a module? You can check whether a file purports to be a GIF file by checking its first three bytes: my $file = 'filename.gif'; my $type; { open my $fh, $file or die $!; read $fh, $type, 3;

Re: Checking about gif

2004-02-21 Thread MAC OS X
I'm going to top post because it is too long. No need to read the whole thing. I see what you're saying.. I'm sorry for my reaction.. I've written quite a few scripts since reading Randal's article and I can assure you that it works as well as file does under UNIX Give it a try, modify my o

Re: quotes in pattern

2004-02-21 Thread Kenton Brede
On Sat, Feb 21, 2004 at 07:44:15PM +0100, Anthony Vanelverdinghe ([EMAIL PROTECTED]) wrote: > Hi > > I want to save the name and the URL of a html hyperlink in an array > (@bookmarks). > > The problem is that the quotes aren't recognized, so it doesn't save only > the URL; > but also the other

Re: Checking about gif

2004-02-21 Thread John
NAME File::MMagic - Guess file type SYNOPSIS use File::MMagic; use FileHandle; $mm = new File::MMagic; # use internal magic file # $mm = File::MMagic::new('/etc/magic'); # use external magic file # $mm = File::MMagic::new('/usr/share/etc/magic'); # if you use Deb

Re: quotes in pattern

2004-02-21 Thread Rob Dixon
Anthony Vanelverdinghe wrote: > > I want to save the name and the URL of a html hyperlink in an array > (@bookmarks). > > The problem is that the quotes aren't recognized, so it doesn't save only > the URL; > but also the other attributes of > How can i make sure only the URL between the quotes is

Re: Checking about gif

2004-02-21 Thread John
Does File::MMagic checks the file headers? I read in the POD that checks the file from the filename :) not deep checking :) - Original Message - From: "MAC OS [EMAIL PROTECTED]" <[EMAIL PROTECTED]> To: "John" <[EMAIL PROTECTED]> Cc: "Perl Beginners" <[EMAIL PROTECTED]> Sent: Saturday, F

Re: Checking about gif

2004-02-21 Thread MAC OS X
On 21 Feb 2004, at 19:03, John wrote: I want to test if a file is a gif image or not. Is it practicable using a module? perldoc File::MMagic #!/usr/bin/perl -w use strict; die "Usage: $0 directory\n" unless @ARGV > 0; use File::Find; use File::MMagic; my $mm = File::MMagic->new; find sub {

Re: Shebang line

2004-02-21 Thread Tim
At 05:38 PM 2/20/04 -0500, you wrote: I am on Windows. Is it okay for me to put a unix style shebang line in my scripts? I would do this for the scripts that I intend to run across platforms. I think the shebang is mostly ignored on Windows. Ex: #!/usr/bin/perl -- To unsubscribe, e-mail: [EMAIL

quotes in pattern

2004-02-21 Thread Anthony Vanelverdinghe
Hi I want to save the name and the URL of a html hyperlink in an array (@bookmarks). The problem is that the quotes aren't recognized, so it doesn't save only the URL; but also the other attributes of How can i make sure only the URL between the quotes is saved? if (/^\s*(.+)<\/A>\s*$/i){

Re: question plz

2004-02-21 Thread Jan Eden
[EMAIL PROTECTED] wrote: >$hash_ref = {key => "value", key2 => "value2"}; >print $hash_ref->{key}; > >It will go and get the 'key' key from the hash that $hash_ref points >to. The print function will actually print "value" here, since you requested the value identified by key. - Jan -- The da

Re: File::Spec::no_upwards(), Absolutes, Alternatives?

2004-02-21 Thread Morbus Iff
>Neither of the above work in a cross-platform sort of way, which is >why I was hoping to use something in File::Spec. But, I'm always >receiving absolute paths, not relative, so I don't believe no_upwards >will work for me. What are other people doing to prevent directory >traversals in an absolut

Re: File::Spec::no_upwards(), Absolutes, Alternatives?

2004-02-21 Thread Morbus Iff
At 1:18 PM -0500 2/21/04, Morbus Iff wrote: >>Neither of the above work in a cross-platform sort of way, which is >>why I was hoping to use something in File::Spec. But, I'm always >>receiving absolute paths, not relative, so I don't believe no_upwards >>will work for me. What are other people doin

Checking about gif

2004-02-21 Thread John
I want to test if a file is a gif image or not. Is it practicable using a module?

File::Spec::no_upwards(), Absolutes, Alternatives?

2004-02-21 Thread Morbus Iff
Evening. File::Spec::no_upwards is supposed to: Given a list of file names, strip out those that refer to a parent directory. (Does not strip symlinks, only '.', '..', and equivalents.) but, I can't seem to get it to work: print "1: $file_path\n"; next unless File::Spec->no_upwards(

Re: parsing Makefiles

2004-02-21 Thread Andrew Gaffney
David le Blanc wrote: From: Andrew Gaffney [mailto:[EMAIL PROTECTED] Sent: Saturday, 21 February 2004 4:53 PM To: beginners Subject: parsing Makefiles I'm looking to write a script that will parse a toplevel Makefile in a source tree and then descend into all the directories and parse those Ma

Re: bless

2004-02-21 Thread James Edward Gray II
On Feb 20, 2004, at 11:29 PM, R. Joseph Newton wrote: Jacob Chapa wrote: what does bless do? It gives the hash reference offered as the first argument access to the methods of the package named by the second argument. there is more, but this is an alright place to start. The effect is to turn

Re: lc

2004-02-21 Thread Randal L. Schwartz
> "Stuart" == Stuart White <[EMAIL PROTECTED]> writes: Stuart> The way it is described makes me think that I am using Stuart> it correctly, but Perl is telling me different. Stuart> So, am I using it incorrectly? Thanks You're confusing functions that return values (like lc) with functions t

Re: "tables" in Perl

2004-02-21 Thread Rob Dixon
Anthony Vanelverdinghe wrote: > > is Java you can do the following: > > int[][] table=new int[4][3]; > int i=table[2][2]; > > is there also something like this in Perl?? my @table; my $i = $table[2][2]; But be careful because the implementation is different. It depends on what you're doing wh

Re: all confused about a hash

2004-02-21 Thread Rob Dixon
<[EMAIL PROTECTED]> wrote: > > I am searching through a large data file and pulling out the data for > elements that match the IP address... > > this is at least half working well up to " #just for testing 1" > but not after " #just for testing 2", hash %segmentFields is > not being populated. > >

"tables" in Perl

2004-02-21 Thread Anthony Vanelverdinghe
Hi is Java you can do the following: int[][] table=new int[4][3]; int i=table[2][2]; is there also something like this in Perl?? Thanks!! _ Online shoppen, niets zo makkelijk http://www.msn.be/shopping -- To unsubscribe, e-mail: [E

Re: list of strings to array

2004-02-21 Thread Rob Dixon
David Le Blanc wrote : > > > Just a note. > > @array = split / /, "one two three four"; > > and > > @array = split " ", "one two three four"; > > are not the same. The second is special-cased inside perl to do the > same as the AWK split command. The first is just a normal regular > expression mat

RE: list of strings to array

2004-02-21 Thread David le Blanc
> From: Jenda Krynicky [mailto:[EMAIL PROTECTED] > Sent: Saturday, 21 February 2004 10:01 AM > To: Perl Beginners > Subject: Re: list of strings to array > > From: Jacob Chapa <[EMAIL PROTECTED]> > > Is there any way to split up a string and put it into an array > > > > something like this:

RE: lc

2004-02-21 Thread David le Blanc
> -Original Message- > From: Stuart White [mailto:[EMAIL PROTECTED] > Sent: Saturday, 21 February 2004 9:21 AM > To: Perl Beginners Mailing List > Subject: lc > > I want to take input from and then convert it > to lowercase. so I tried this: > > lc(chomp($input = ))); > > and I got an

RE: question plz

2004-02-21 Thread David le Blanc
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Saturday, 21 February 2004 2:20 PM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: Re: question plz > > They're different operators. => is the same thing as the > comma. It's sole > difference is readability. For example > > %h

RE: question plz

2004-02-21 Thread David le Blanc
> To: Perl Beginners > Subject: question plz > > what is the difference between > > -> > > and > > => 0b01 ! man perlobj for '->' and man perldata for '=>'. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: $self

2004-02-21 Thread David le Blanc
Would that be ( $me, my$self ) = &I ? sorry. > >> is $self a special scalar? > > actually the simpler solutions is > > sub my_do_foo > { > my ($me, $arg, $other) = @_; > > $me->doOther($arg) unless $other ; > ... > } > > but I am

RE: parsing Makefiles

2004-02-21 Thread David le Blanc
> From: Andrew Gaffney [mailto:[EMAIL PROTECTED] > Sent: Saturday, 21 February 2004 4:53 PM > To: beginners > Subject: parsing Makefiles > > I'm looking to write a script that will parse a toplevel > Makefile in a source tree and > then descend into all the directories and parse those > Makefi