I am also very new to Perl! I need to figure out how I could skip a
block of comments in a C header file. For example, if I have something
like the following:
/* This is my block of comments.blah
blah.and
lots more commen
All,
Monumentally basic question here (but hey, this is what this list is for,
yeah?).
I'm working on my first ever useful script (after "Hello World" and "Enter a
number" "Wrong!" type things). It's also my first ever foray into
programming of any kind, so please make sure answers are in layma
Title: RE: Use Strict
What does exactly does use strict do?
...1. I strongly suggest using the pragma
...
... use strict;
...
... It will force you to write less error-prone code.
As an aid to catching implicit references to package variables you can use
the pragma
use strict 'vars';
then any variable reference must be declared correctly.
If you try and use a variable which hasn't been declared then a compilation
error occurs.
This is very handy if you have mis-spelt
I don't know how this works, But I have seen this regexp comparison it in
perlop man pages. It has been very good regexp.
Can anyone explain this for me.
#! /usr/bin/perl
# open the file
open(fileHandle, "Cfile") || die "can't open the file ";
# read the file in scalar
while() {
$program .= $_
[EMAIL PROTECTED] said...
> I don't know how this works, But I have seen this regexp comparison it in
> perlop man pages. It has been very good regexp.
> Can anyone explain this for me.
I'll add some comments that may help explain some of what was left out:
#! /usr/bin/perl
# open the file
op
A hash is a data structure, which assigns a key to value.
In Perl the key is given in the curly braces. A key/value
pair is entered like this: $hash{$key} = $value (assuming
the variables $key and $value, hold the key and value
respectivly).
> open (EXIST, "/tmp/users");
> @exist = ;
>
i know this is not the list but pple bere with me ..I am having problems
with connecting at ATM to the networkanyone familier with os/2 warp
tcp/ip..it only connects when i put oit in the router range ..of 194.12.12.*
but all the pcs are in the range 194.178.6.*
-Original Message-
Fr
Here's some real basic info about hashes...may be useful to newbies...
@ary = ('a', 'b', 'c', 'b', 'a');
%hsh = (); # empty hash
foreach $item (@ary)
{
$hsh{$item} = 1;
}
@ary = keys %hsh;
What does @ary contain now?
You can think of a hash as being like an array that is indexed by st
> What does exactly does use strict do?
Here's a sample:
use strict;
use vars qw( $a $b $c # this is how you declare variables
$myvar ); # for use with "use strict"
$a = 1; #ok
$b = 2; #ok
$c = $a + b; #oops, forgot $ in fro
> foreach $i (@a, @b) # did you know you can combine
> arrays like this?
> :)
Oops, darn line wrap, please ignore the smiley...
On Fri, Apr 20, 2001 at 09:29:04AM -0400, Nutter, Mark wrote:
>bash$ perl -e '
>> @ary = ('a', 'b', 'c', 'b', 'a');
>> %hsh = (); # empty hash
>>
>> foreach $item (@ary)
>> {
>> $hsh{$item} = 1;
>> }
>>
>> @ary = keys %hsh;
>>
>> print (join "\n", @a
Mark Nutter said ...
> > What does exactly does use strict do?
>
> Here's a sample:
>
> use strict;
>
> use vars qw( $a $b $c # this is how you declare variables
>$myvar ); # for use with "use strict"
I've always seen it done this way:
#[code]
my ($a, $b, $c, $myvar);
#[/code
Title: good list
Not quite on topic this - but gotta say this is a really usefull list.
Thanks to all who organised the list and all the kind folks that answer us newbies in a way even I can understand!
Terry
> > use strict;
> >
> > use vars qw( $a $b $c # this is how you declare variables
> >$myvar ); # for use with "use strict"
>
> I've always seen it done this way:
>
> #[code]
> my ($a, $b, $c, $myvar);
> #[/code]
>
> ...so that the variables are part of the current package.
>
On Fri, Apr 20, 2001 at 11:08:44AM -0700, Simba Pangeti wrote:
:
: i know this is not the list but pple bere with me ..I am having problems
: with connecting at ATM to the networkanyone familier with os/2 warp
: tcp/ip..it only connects when i put oit in the router range ..of 194.12.12.*
: bu
Remember you can always check the syntax of a perl script using the -c
option!
perl -c myscript.pl
One thing that frequently gets over looked is that you can run a script
through perl to check the syntax of a script. This quick check will point
out all sorts of details that are hard to see when
Hi, guys,
I need to read a huge two column file; I only need the
data from the second column; I need to asign it a
variable to that column, for example $FILE, how do go
about doing this; I appreciate your help.
the file looks like this
md tony
md ariba
md arpa
I will have a loop going over and
Hi Peter,
>From looking at your example data, it looks like your column seperator is
white space, what you could do is use the split function (see perlfunc
manpage). An example implementation would be someting like.
open (FILE, ") { #read in file a line at a time
my ($column2) =
Peter Lemus wrote:
> I need to read a huge two column file; I only need the
> data from the second column; I need to asign it a
> variable to that column, for example $FILE, how do go
> about doing this; I appreciate your help.
>
> the file looks like this
>
> md tony
> md ariba
> md arpa
in th
Hi all,
has anybody got experience with DBI. I'm retrieving data from Oracle and
running programs quite nicely on te output but after that I need to get my
results back into a table.
My results are in a comma delimited file. I need to read through the file
adding each line as a record in the tabl
Excellent description Collin. I have just a couple of comments to add.
Collin Rogowski wrote:
>
> A hash is a data structure, which assigns a key to value.
> In Perl the key is given in the curly braces. A key/value
> pair is entered like this: $hash{$key} = $value (assuming
> the variables $ke
Paul Johnson wrote:
> But don't go relying on the ordering of the array. Hashes don't
> preserve order. If you need an ordering, impose it. eg
>
> print join "\n", sort @ary;
Should we get into a thread on 'sort' ~8^) ?
I thought I'd throw this in there (in case some of you get adventur
Ok I know what it does ('cause I ran it, see below) but I still don't fully
understand how. Also can you give a little insight into passing arrays to
subroutines/functions. I can pass them alright but have problems accessing
them. I use $_[0] but it doesn't seem to work for arrays. Any help wou
> My results are in a comma delimited file. I need to read
> through the file
> adding each line as a record in the table using the SQL:
>
> my $query1=<<"QUERY";
> INSERT INTO DIFFAMNTS VALUES
> ('PK',9197,171509,'THIS IS A TEST2
> ROW','AA',1,77120,101032)
> QUERY
>
> Obviously
I am quite pleased with the list so far. I have a further challenge
for all the teachers out there:
Let's create mini tutorials. The note about hashes tripped my memory
of wanting to do this. I read about one on sort that should be here
soon. :)
Information like: reading passwords from the c
At 10:57 AM 4/20/2001, you wrote:
>Both approaches will work equally well for most general applications. You
>start to see differences when you get into more specialized applications.
>For example, if you're writing a Perl module, and you want to export
>variables using Exporter.pm, you can't use
"Stout, Joel R" wrote:
>
> Ok I know what it does ('cause I ran it, see below) but I still don't fully
> understand how. Also can you give a little insight into passing arrays to
> subroutines/functions. I can pass them alright but have problems accessing
> them. I use $_[0] but it doesn't see
> Ok I know what it does ('cause I ran it, see below) but I
> still don't fully
> understand how.
Well, it's a trick, based on the "givens" that neither array contained any
duplicates. If each item appears at most once per array, then all we need
to do is count the number of times each item a
howdy...
new to the list and will likely see plenty that will help; but here's
something specific to my explorations now.
I'm doing some development and testing for production and have pretty well
decided Perl-Perl/Tk and Berkeley DB
will best serve my purpose. This after exploring the DBI with D
Gurus,
This was very timely and helpful. I've got another related question,
hence the reply to this. What if I've got a stanza like:
parm: parm1
value : 100
parm: parm2
value : 101
... etc, and I want to keep the name of the parm and the value, and
trash the rest?
Thanks,
Grate
Gang,
I'd like to rename the existing files in a directory to "filename.txt" The
files have no extensions, and have names like:
B0724 B0834 B1236 B1356 B1370
A0012 A0036 A0050 A0120 A0302 A0310 rename1.pl
Y
Z
I pulled a sample of files over to a test directory on my desktop and I'
On Fri, Apr 20, 2001 at 05:00:37PM -0500, Sean C. Phillips wrote:
: Gurus,
:
: This was very timely and helpful. I've got another related question,
: hence the reply to this. What if I've got a stanza like:
:
: parm : parm1
: value : 100
:
: parm : parm2
: value : 101
:
: ... etc, and I w
- Original Message -
From: McCormick, Rob E <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, April 21, 2001 12:08 AM
Subject: renaming files in a directory
> I can print a file listing with this:
>
Try to do the rename in the while loopm cuz it loops over all the files i
On Fri, Apr 20, 2001 at 06:08:47PM -0400, McCormick, Rob E wrote:
[snip]
One thing I find confusing about your example is that you're
using the same variable ($msds_files) twice, for different things.
How about something like:
#!c:/perl/bin/perl -w
use strict;
my $dir = "c:/winnt/profiles/mypro
--- Casey West <[EMAIL PROTECTED]> wrote:
> I am quite pleased with the list so far. I have a further challenge
> for all the teachers out there:
>
> Let's create mini tutorials. The note about hashes tripped my memory
> of wanting to do this. I read about one on sort that should be here
> so
Here's a nice way to do what Stuart Watts recommended
(chomping the array):
open (FILE, "whatever");
chomp (my @array=);
And boom the newlines are killed in one fell swoop.
I've used this with fantastic results. Stuart's way
works well too, but I figured I'd throw this in...very
'perlish'.
~Mat
Hello,
Here is code fragment that I can't seem to solve.
All help, suggestions are appreciated.
Thanks!
Dave
What I want to do is to check for either if the username or password is good:
The $pwfile contains (exactly like it is here):
username1|password1
username2|password2
ect.
# stuff $p
- Original Message -
From: David Gilden <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, April 21, 2001 2:49 AM
Subject: Populating Hashs and checking multi form fields
> # stuff $pwd in to @indata
> open(FILE,$pwfile) || die &dead("Can't find $pwfile. $!");
> @indata = ;
Th
You've got a couple of options:
1) If you're using Cgi.pm (you should!!), you can run
it in "offline mode" and capture the html it produces.
Then just point your IE or Netscape to that html and
it will display.
2) Unless your script was doing something unusual, it
should not have interfered with
Pam -- this is a bit of a shot in the dark, but ensure
that perl is not messing up your http header in it's
buffer by using:
$|=1; # This sets autoflush to flush the buffer after
every print, printf and write (from the Camel).
Hope it helps. We're using your Solaris and Perl
versions at work wit
Set your environment variables in your .profile file
in your home directory, or edit /etc/profile.
Remember that a script will run under the current env.
of the shell calling it...something I've run into with
crontab files not getting the expected env. variables.
I also am not 100% sure about th
Yes -- type " perldoc perl " a the dos or shell prompt
and roll from there.
perldoc -f [function] will give you specific info.
about a function you're interested in...here's a copy
from one of my machines (this one uses win2k, the
others are Solaris and Linux).
C:\Documents and Settings\mcauthor
Hey Jen: This may not be the cleanest way, but you can
setup a regex for each string type you're interested
in and push the results into an array...
If you're running Unix, it may REALLY help you to go
ahead and strip out all of the unwanted crap via a
command-line grep, then pipe the results int
I once saw a command for listing the installed modules, but now cannot
remember it. I am using FreeBSD 4.2 with Apache 1.3.14 and Perl
5.005_03. I want to verify that the module cgi-pm is installed. This is
my own web server at home.
I am new at perl and cgi, but have been building web sites for
If you're looking for a specific module, you can do
this:
perldoc CGI.pm to see if the docs are installed (they
are, as CGI.pm is part of the standard distro.)
Or, you can do this from the command line:
perl -MCGI.pm
...if the prompt then just sits there waiting for you
without messages, it's
On Fri, 20 Apr 2001 20:29:46 -0700 (PDT)
Matt Cauthorn <[EMAIL PROTECTED]> surely must have wrote something
like:
> If you're looking for a specific module, you can do
> this:
> perldoc CGI.pm to see if the docs are installed (they
> are, as CGI.pm is part of the standard distro.)
They are.
> Or
On Fri, Apr 20, 2001 at 09:46:03PM -0700, Chip Wiegand wrote:
> On Fri, 20 Apr 2001 20:29:46 -0700 (PDT)
> Matt Cauthorn <[EMAIL PROTECTED]> surely must have wrote something
> like:
>
> > Or, you can do this from the command line:
> > perl -MCGI.pm
>
> I did this and got the following error:
> s
you just use a different regular expression with split.
In the original example the split was done at the whitespaces
the regex is /\s/. Now you want to split at whitespace colon
whitespace. The regex is /\s:\s/. If you want to allow more
than one whitespace you could /\s*:\s*/ like this. You pro
Peter Lemus asked:
> I need to read a huge two column file; I only need the
> data from the second column; I need to asign it a
> variable to that column, for example $FILE, how do go
> about doing this; I appreciate your help.
>
> the file looks like this
>
> md tony
> md ariba
> md arpa
If the
: I need to read a huge two column file; I only need the
: data from the second column; I need to asign it a
: variable to that column, for example $FILE, how do go
: about doing this; I appreciate your help.
How about:
while (<>) {
$FILE = (split)[1];
...
}
"split" by itself s
51 matches
Mail list logo