Maybe pass in the directory name to awk (use the -v option) and then include this path name in the commands.
Just a thought ... bed time here really :-)
Hi
I'm not 100% sure what you are trying to achieve.
To print the last field, just print $NF
You probably want to get rid of the quotes, so you could try { last=$NF; gsub( /"/, "", last ); print last }
That will get you the last bit of file 1 but I'm not sure how your file 2 is supposed to...
Oops
Just realised my code was a bit wrong.
Change =~ s/ \s+ \z // to =~ s/ \s+ \z //xms
The x in xms tells Perl to ignore spaces in the regex (the spaces either side of \s+) but it probably worked ok for you in this case but definitely change it.
Just a thought - do you want to print all the fields?
If so, you could put a bit of code at the top to keep track of all the fields ever encountered.
You might also want to replace the tab (\t) with a comma (,) in the print statement if you want CSV-like output.
Keep in mind that CSV output...
No worries
It only prints 3 because I didn't bother typing them all in :-)
This bit is the "culprit" qw( date time release ). Just add more field names if you like, in whatever order you like.
Enjoy! Thanks for the star
...incremented to 0 shortly
LINE:
while (<>) {
chomp;
# Get the field name and rest of the line
my ( $field_name, $field_val ) = unpack 'A20A*', $_;
# Skip blank lines
next LINE if $field_name eq '';
# Strip trailing space from fixed length records
$field_name =~ s/ \s+ \z //...
What sort of errors did you get?
You should be able to download the modules, copy them to the server, extract them and "make" them without much hassle.
I've installed stuff manually before when CPAN had trouble.
Hi Han
I don't use Activestate Perl very often and don't have it installed on this computer to test. But I think that perldoc is a command installed with Perl.
Alternatively, you can get the doco all over the web, eg, http://theoryx5.uwinnipeg.ca/CPAN/perl/pod/perlport.html
A bit of light...
Just as an aside, if all you're trying to do is create a lookup table for that maths function, you should check out the Memoize module.
This allows the return value of subroutines to be cached for efficiency.
So you would write your subroutine to do the int / 2 thing and Memoize would remember...
It looks like it's returning a reference to an array.
So $result->[0]->{created_at} would equal 'Thu Feb 21 02:27:32 +0000 2008'.
This means:
[0] means first element in the array
{created_at} hash entry with key of created_at
Check out the perl man page for perlreftut
On the web, it's at...
It's because min starts off like a 0
So nothing is lower
Try adding something like BEGIN { min = 999 }
but keep in mind that this is a bit of a kludge. If the lowest value is actually 1000 then it will print 999. So pick a big number, or to do it properly set min to the first value of $5 on...
I have a feeling I read somewhere about "free" vs "inactive".
I think inactive is effectively free. See if you can google something along those lines - it might not be the script's problem.
Yeah, assoc array would be my suggestion too.
Also, be careful about stripping spaces and punctuation from the name if you are using the name as an index.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.