shift

Eugene Tsyrklevich eugene at securityarchitects.com
Mon Aug 14 21:36:18 CDT 2000


~sdpm~
perldoc -f shift
perldoc perldoc


On Mon, Aug 14, 2000 at 04:43:41PM -0700, Vasquez, Mike wrote:
> ~sdpm~
> I'm learning perl, a little at a time, and I have come across this:
> 
> my $idfile = shift
> 
> What does shift represent in this context.
> 
> Michael Vasquez
> Webcast Engineer
> Akamai Technologies
> (858) 909-3106
> (619) 252-4999 (cell)
> mike.vasquez at akamai.com
> http://www.akamai.com/
>   Nasdaq: AKAM
> 
> 
> 
> 
> -----Original Message-----
> From: Eugene Tsyrklevich [mailto:eugene at securityarchitects.com]
> Sent: Saturday, August 12, 2000 3:35 PM
> To: san-diego-pm-list at happyfunball.pm.org
> Subject: Re: Newbie Question
> 
> 
> ~sdpm~
> On Sat, Aug 12, 2000 at 01:01:32PM -0700, Ken Loomis wrote:
> > I just started learning Perl and found the San Diego Perl Mongers group.
> > Trying to re-arrange my schedule to make it to this month's meeting, but I
> > have a challenge today that I need some help that I would be most
> > appreciative of.
> > 
> > I use a small data file to keep the Customer_ID number in. Each time a new
> > customer registers, I increment the number in that file. However, we are
> > getting so many requests, that at time the number gets reset to 1. I am
> > pretty sure this is because of the way the flock works.
> 
> 
> you will need 4294967296 hits in order for your counter to reset
> 
>  
> > I checked out the FAQ's and found this code segment for handling this:
> > 
> >     use Fcntl;
> >     sysopen(FH, "numfile", O_RDWR|O_CREAT)       or die "can't open
> numfile:
> > $!";
> 
> 
> fyi, man perlopentut
> 
> 
> >     flock(FH, 2)                                 or die "can't flock
> numfile:
> > $!";
> >     $num = <FH> || 0;
> >     seek(FH, 0, 0)                               or die "can't rewind
> > numfile: $!";
> >     truncate(FH, 0)                              or die "can't truncate
> > numfile: $!";
> >     (print FH $num+1, "\n")                      or die "can't write
> numfile:
> > $!";
> >     # DO NOT UNLOCK THIS UNTIL YOU CLOSE
> >     close FH                                     or die "can't close
> numfile:
> > $!";
> 
> 
> be careful about using 'or' and '||'.. they have different precedence and
> act differently in different situations.
> man perlop for more
> 
> 
> > I ran a test of this from one domain that I host and it worked fine.
> However
> > when I incorporated it into the client's CGI that collects the customer
> info,
> > I get an error.
> > 
> > Here is the code segment as I placed it into the CGI:
> > 
> >     sysopen(FH, "/www/htdocs/freetitandslcom/CustomerID.dat",
> > O_RDWR|O_CREAT)     or &safe_die("Can't open CustomerID.dat file");
> >     flock(FH, 2)                               or &safe_die("can't flock
> > CustomerID.dat: $!");
> >     $newcustomerid = <FH> || 0;
> >     seek(FH, 0, 0)                             or &safe_die("can't rewind
> > CustomerID.dat: $!");
> >     truncate(FH, 0)                            or &safe_die("can't
> truncate
> > CustomerID.dat: $!");
> >     (print FH $newcustomerid+1, "\n")                    or
> &safe_die("can't
> > write CustomerID.dat: $!");
> >     # DO NOT UNLOCK THIS UNTIL YOU CLOSE
> >     close FH                                   or &safe_die("can't close
> > CustomerID.dat: $!");
> > 
> > The error I get is:
> > 
> >     can't truncate CustomerID.dat: Permission Denied
> > 
> > As a shot in the dark, I tried setting the permission on the
> "CustomerID.dat"
> > file to '766' but that had no effect.
> 
> 
> make the owner of CustomerID.dat file to be the user under which your apache
> processes run (nobody or www or whoever)
> set the permissions on a file to 600
> 
> 
> cheers
> ~sdpm~
> 
> The posting address is: san-diego-pm-list at hfb.pm.org
> 
> List requests should be sent to: majordomo at hfb.pm.org
> 
> If you ever want to remove yourself from this mailing list,
> you can send mail to <majordomo at happyfunball.pm.org> with the following
> command in the body of your email message:
> 
>     unsubscribe san-diego-pm-list
> 
> If you ever need to get in contact with the owner of the list,
> (if you have trouble unsubscribing, or have questions about the
> list itself) send email to <owner-san-diego-pm-list at happyfunball.pm.org> .
> This is the general rule for most mailing lists when you need
> to contact a human.
> ~sdpm~
> 
> The posting address is: san-diego-pm-list at hfb.pm.org
> 
> List requests should be sent to: majordomo at hfb.pm.org
> 
> If you ever want to remove yourself from this mailing list,
> you can send mail to <majordomo at happyfunball.pm.org> with the following
> command in the body of your email message:
> 
>     unsubscribe san-diego-pm-list
> 
> If you ever need to get in contact with the owner of the list,
> (if you have trouble unsubscribing, or have questions about the
> list itself) send email to <owner-san-diego-pm-list at happyfunball.pm.org> .
> This is the general rule for most mailing lists when you need
> to contact a human.
> 
> 
~sdpm~

The posting address is: san-diego-pm-list at hfb.pm.org

List requests should be sent to: majordomo at hfb.pm.org

If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at happyfunball.pm.org> with the following
command in the body of your email message:

    unsubscribe san-diego-pm-list

If you ever need to get in contact with the owner of the list,
(if you have trouble unsubscribing, or have questions about the
list itself) send email to <owner-san-diego-pm-list at happyfunball.pm.org> .
This is the general rule for most mailing lists when you need
to contact a human.




More information about the San-Diego-pm mailing list